Recap - Full Testbench
Coddy Verilog 여정의 기초 섹션에 포함된 레슨. 90개 중 78번째.
챌린지
이 과제는 stimulus, display, monitor, dumpfile, dumpvars 및 system tasks를 포함하여 테스트벤치에 대해 배운 모든 내용을 테스트합니다. 테스트할 XOR gate 모듈이 주어집니다.
할 일:
다음 조건을 만족하는 complete testbench를 작성하세요:
- 신호를 선언합니다 (입력에는
reg, 출력에는wire) - 이름이
dut인 XOR gate를 인스턴스화합니다 xor_waveform.vcd라는 이름의 waveform 파일을 생성합니다- testbench의 all 신호를 덤프합니다
- 헤더를 출력합니다: "Testing XOR Gate"
$monitor를 사용하여 time, x, y 및 z를 추적합니다- 각 입력 조합 사이에
#10delay를 두고 all four 입력 조합(00, 01, 10, 11)을 테스트합니다 - 마지막에 "Test complete"를 출력합니다
$finish로 시뮬레이션을 종료합니다
직접 해보기
module xor_gate (
input x,
input y,
output z
);
assign z = x ^ y;
endmodule
module testbench;
// TODO: x와 y를 위한 reg 선언
// TODO: z를 위한 wire 선언
// TODO: dut라는 이름으로 xor_gate 인스턴스화
// .x(x), .y(y), .z(z) 연결
initial begin
// TODO: $dumpfile "xor_waveform.vcd" 추가
// TODO: $dumpvars (0, testbench) 추가
// TODO: $display "Testing XOR Gate" 추가
// TODO: time, x, y, z에 대한 $monitor 추가
// 형식: "Time %0t: x=%b, y=%b, z=%b"
// TODO: 네 가지 모든 조합에 대한 자극 추가
// 00, 01, 10, 11 with #10 delay
// TODO: $display "Test complete" 추가
// TODO: $finish 추가
end
endmodule기초의 모든 레슨
4Operators Part 1
Arithmetic OperatorsModulo OperatorComparison OperatorsRecap - Simple MathBitwise Operators7Assign And Gates
Continuous AssignmentAssign With OperatorsBuilt In Gate PrimitivesAND OR NOT GatesXOR XNOR GatesRecap - Logic Gate Circuit10Decision Making
If StatementIf - ElseRecap - Simple ComparatorCase StatementCasex And CasezRecap - ALU Design5Operators Part 2
Logical OperatorsReduction OperatorsShift OperatorsConcatenation OperatorConditional OperatorRecap - Operator Challenge14Testbench Basics
What Is A TestbenchCreating StimulusDisplay And MonitorDumpfile And DumpvarsUsing System TasksRecap - Full Testbench3Number System
Binary RepresentationSized NumbersUnsized NumbersNegative NumbersSpecial Values X And ZRecap - Number Formats6Modules
Module StructureInput And Output PortsInout PortsModule InstantiationPort Mapping By NamePort Mapping By OrderRecap - Build A Module9Procedural Blocks
Always BlockInitial BlockSensitivity ListBlocking AssignmentNon Blocking AssignmentRecap - Always vs Initial15Traffic Light Controller
Defining The StatesState Machine Logic직접 연습해 보세요: 온라인 Verilog 컴파일러