3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-07 09:55:20 +00:00

Some fixes in tests/asicworld/*_tb.v

This commit is contained in:
Clifford Wolf 2016-05-20 17:13:11 +02:00
parent 1e227caf72
commit 8e9e793126
4 changed files with 41 additions and 50 deletions

View file

@ -1,11 +1,11 @@
module testbench (); module testbench ();
reg clk; reg clk = 0;
reg rst; reg rst = 1;
reg req3; reg req3 = 0;
reg req2; reg req2 = 0;
reg req1; reg req1 = 0;
reg req0; reg req0 = 0;
wire gnt3; wire gnt3;
wire gnt2; wire gnt2;
wire gnt1; wire gnt1;
@ -13,17 +13,15 @@ wire gnt0;
// Clock generator // Clock generator
always #1 clk = ~clk; always #1 clk = ~clk;
integer file;
always @(posedge clk)
$fdisplay(file, "%b", {gnt3, gnt2, gnt1, gnt0});
initial begin initial begin
$dumpfile ("arbiter.vcd"); file = $fopen(`outfile);
$dumpvars(); repeat (5) @ (posedge clk);
clk = 0; rst <= 0;
rst = 1;
req0 = 0;
req1 = 0;
req2 = 0;
req3 = 0;
#10 rst = 0;
repeat (1) @ (posedge clk); repeat (1) @ (posedge clk);
req0 <= 1; req0 <= 1;
repeat (1) @ (posedge clk); repeat (1) @ (posedge clk);

View file

@ -15,9 +15,10 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
module testbench; module testbench;
reg clk, reset, enable; integer file;
reg clk = 0, reset = 0, enable = 0;
wire [3:0] count; wire [3:0] count;
reg dut_error; reg dut_error = 0;
counter U0 ( counter U0 (
.clk (clk), .clk (clk),
@ -30,34 +31,21 @@ event reset_enable;
event terminate_sim; event terminate_sim;
initial initial
begin file = $fopen(`outfile);
$display ("###################################################");
clk = 0;
reset = 0;
enable = 0;
dut_error = 0;
end
always always
#5 clk = !clk; #5 clk = !clk;
initial
begin
$dumpfile ("counter.vcd");
$dumpvars;
end
initial initial
@ (terminate_sim) begin @ (terminate_sim) begin
$display ("Terminating simulation"); $fdisplay (file, "Terminating simulation");
if (dut_error == 0) begin if (dut_error == 0) begin
$display ("Simulation Result : PASSED"); $fdisplay (file, "Simulation Result : PASSED");
end end
else begin else begin
$display ("Simulation Result : FAILED"); $fdisplay (file, "Simulation Result : FAILED");
end end
$display ("###################################################"); $fdisplay (file, "###################################################");
#1 $finish; #1 $finish;
end end
@ -69,11 +57,11 @@ initial
forever begin forever begin
@ (reset_enable); @ (reset_enable);
@ (negedge clk) @ (negedge clk)
$display ("Applying reset"); $fdisplay (file, "Applying reset");
reset = 1; reset = 1;
@ (negedge clk) @ (negedge clk)
reset = 0; reset = 0;
$display ("Came out of Reset"); $fdisplay (file, "Came out of Reset");
-> reset_done; -> reset_done;
end end
@ -103,8 +91,8 @@ else if ( enable == 1'b1)
always @ (negedge clk) always @ (negedge clk)
if (count_compare != count) begin if (count_compare != count) begin
$display ("DUT ERROR AT TIME%d",$time); $fdisplay (file, "DUT ERROR AT TIME%d",$time);
$display ("Expected value %d, Got Value %d", count_compare, count); $fdisplay (file, "Expected value %d, Got Value %d", count_compare, count);
dut_error = 1; dut_error = 1;
#5 -> terminate_sim; #5 -> terminate_sim;
end end

View file

@ -1,16 +1,13 @@
module testbench(); module testbench();
// Declare inputs as regs and outputs as wires // Declare inputs as regs and outputs as wires
reg clock, reset, enable; reg clock = 1, reset = 0, enable = 0;
wire [3:0] counter_out; wire [3:0] counter_out;
integer file;
// Initialize all variables // Initialize all variables
initial begin initial begin
$display ("time\t clk reset enable counter"); file = $fopen(`outfile);
$monitor ("%g\t %b %b %b %b", $fdisplay (file, "time\t clk reset enable counter");
$time, clock, reset, enable, counter_out);
clock = 1; // initial value of clock
reset = 0; // initial value of reset
enable = 0; // initial value of enable
#5 reset = 1; // Assert the reset #5 reset = 1; // Assert the reset
#10 reset = 0; // De-assert the reset #10 reset = 0; // De-assert the reset
#10 enable = 1; // Assert enable #10 enable = 1; // Assert enable
@ -18,6 +15,10 @@ initial begin
#5 $finish; // Terminate simulation #5 $finish; // Terminate simulation
end end
always @(negedge clock)
$fdisplay (file, "%g\t %b %b %b %b",
$time, clock, reset, enable, counter_out);
// Clock generator // Clock generator
initial begin initial begin
#1; #1;

View file

@ -1,14 +1,14 @@
module testbench(); module testbench();
reg clock , reset ; reg clock = 0 , reset ;
reg req_0 , req_1 , req_2 , req_3; reg req_0 , req_1 , req_2 , req_3;
wire gnt_0 , gnt_1 , gnt_2 , gnt_3 ; wire gnt_0 , gnt_1 , gnt_2 , gnt_3 ;
integer file;
initial begin initial begin
// $dumpfile("testbench.vcd"); // $dumpfile("testbench.vcd");
// $dumpvars(0, testbench); // $dumpvars(0, testbench);
$display("Time\t R0 R1 R2 R3 G0 G1 G2 G3"); file = $fopen(`outfile);
$monitor("%g\t %b %b %b %b %b %b %b %b", $fdisplay(file, "Time\t R0 R1 R2 R3 G0 G1 G2 G3");
$time, req_0, req_1, req_2, req_3, gnt_0, gnt_1, gnt_2, gnt_3);
clock = 0; clock = 0;
reset = 1; reset = 1;
req_0 = 0; req_0 = 0;
@ -28,6 +28,10 @@ initial begin
#10 $finish; #10 $finish;
end end
always @(negedge clock)
$fdisplay(file, "%g\t %b %b %b %b %b %b %b %b",
$time, req_0, req_1, req_2, req_3, gnt_0, gnt_1, gnt_2, gnt_3);
initial begin initial begin
#1; #1;
forever forever