Vivadoでのテストベンチの流し方
#verilog #fpga #vivado
手元にあるテストベンチをVivadoで走らせてみる。
まず以下のソースをVivadoへ取り込み、
code:nand.v
module NAND(
input in1, in2,
output out
);
assign out = ~(in1 & in2);
endmodule
code:and.v
module AND(
input in1, in2,
output out
);
wire nand1_out;
NAND nand1(in1, in2, nand1_out);
assign out = ~nand1_out;
endmodule
code:and_test.sv
module and_test;
reg in1, in2;
wire out;
AND dut(in1, in2, out);
initial begin
in1 = 0; in2 = 0; #10;
assert(out == 0) $display("PASSED"); else $display("FAILED");
in1 = 1; in2 = 0; #10;
assert(out == 0) $display("PASSED"); else $display("FAILED");
in1 = 0; in2 = 1; #10;
assert(out == 0) $display("PASSED"); else $display("FAILED");
in1 = 1; in2 = 1; #10;
assert(out == 1) $display("PASSED"); else $display("FAILED");
end
endmodule
Flow Navigator / SIMULATION / Run Simulation で and_test が実行される。
code:実行結果のログ
# run 1000ns
PASSED
PASSED
PASSED
PASSED
INFO: USF-XSim-96 XSim completed. Design snapshot 'and_test_behav' loaded.
INFO: USF-XSim-97 XSim simulation ran for 1000ns
それっぽい波形も表示できてる。
https://gyazo.com/f0761dc6a5fac83ac803f72de4b06ded