Download Control/Finite State Machine/sequence_detector/testbench.v from chipagents/RTLLM-verified: direct link, hf CLI and curl.
- Browser
- Download file 6.93 kB
-
https://huggingface.co/datasets/chipagents/RTLLM-verified/resolve/main/Control/Finite%20State%20Machine/sequence_detector/testbench.v
- Command line
-
hf download 'hf://datasets/chipagents/RTLLM-verified/Control/Finite State Machine/sequence_detector/testbench.v'
-
curl -L -o testbench.v https://huggingface.co/datasets/chipagents/RTLLM-verified/resolve/main/Control/Finite%20State%20Machine/sequence_detector/testbench.v
6.93 kB
| module tb_sequence_detector(); | |
| reg clk, rst_n, data_in; | |
| wire sequence_detected; | |
| sequence_detector dut ( | |
| .clk(clk), | |
| .rst_n(rst_n), | |
| .data_in(data_in), | |
| .sequence_detected(sequence_detected) | |
| ); | |
| integer error = 0; | |
| task hard_chk(input exp, input [8*48-1:0] what); | |
| begin | |
| if (sequence_detected !== exp) begin | |
| error = error + 1; | |
| $display("HARD %0t: sequence_detected=%b, expected %b (%0s)", $time, sequence_detected, exp, what); | |
| end | |
| end | |
| endtask | |
| // Clock generation | |
| always #5 clk = ~clk; | |
| initial begin | |
| // Initialize signals | |
| clk = 0; | |
| rst_n = 0; | |
| data_in = 1; | |
| #2 rst_n = 1; | |
| // Sending 1001 | |
| #6 data_in = 1; | |
| #10 data_in = 1; | |
| #10 data_in = 0; | |
| #10 data_in = 0; | |
| #10 data_in = 1; | |
| #10;data_in = 1; | |
| if (!sequence_detected) | |
| error = error+1; | |
| #10;data_in = 1; | |
| #10 data_in = 0; | |
| if (sequence_detected) | |
| error = error+1; | |
| #10 data_in = 0; | |
| #10 data_in = 1; | |
| #10; | |
| if (!sequence_detected) | |
| error = error+1; | |
| // additional check (t=108). clk rises at x5 and falls at x0, data_in changes at x8, rst_n changes at x9 and is | |
| // held low for 10 ns (one rising and one falling edge); outputs are checked at x7.5 (just before data_in changes). | |
| #0 data_in = 1; // t=108: 1 | |
| #10 data_in = 0; // t=118: 0 | |
| #10 data_in = 0; // t=128: 0, sampled while rst_n is low | |
| #1 rst_n = 0; // t=129: low across the edges at 130 and 135 | |
| #8.5 hard_chk(1'b0, "rst_n low"); // t=137.5 | |
| #0.5 data_in = 1; // t=138: 1 | |
| #1 rst_n = 1; // t=139 | |
| #8.5 hard_chk(1'b0, "1,0 + reset + 0,1 must not match"); // t=147.5 | |
| #0.5 data_in = 0; // t=148 | |
| #10 data_in = 0; // t=158 | |
| #10 data_in = 1; // t=168: 4th bit of 1,0,0,1 after reset | |
| #9.5 hard_chk(1'b1, "1,0,0,1 after reset"); // t=177.5 | |
| #1.5 rst_n = 0; // t=179 | |
| #8.5 hard_chk(1'b0, "rst_n low"); // t=187.5 | |
| #0.5 data_in = 0; // t=188: 0 | |
| #1 rst_n = 1; // t=189 | |
| #9 data_in = 1; // t=198 | |
| #10 data_in = 0; // t=208 | |
| #10 data_in = 0; // t=218 | |
| #9.5 hard_chk(1'b0, "1,0,0 only"); // t=227.5 | |
| #0.5 data_in = 1; // t=228: 4th bit | |
| #9.5 hard_chk(1'b1, "0,1,0,0,1 after reset"); // t=237.5 | |
| #1.5 rst_n = 0; // t=239 | |
| #8.5 hard_chk(1'b0, "rst_n low"); // t=247.5 | |
| #0.5 data_in = 0; // t=248 | |
| #1 rst_n = 1; // t=249 | |
| #8.5 hard_chk(1'b0, "no 1001 in stream"); // t=257.5 | |
| #0.5 data_in = 1; // t=258 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=267.5 | |
| #0.5 data_in = 1; // t=268 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=277.5 | |
| #0.5 data_in = 1; // t=278 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=287.5 | |
| #0.5 data_in = 0; // t=288 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=297.5 | |
| #0.5 data_in = 1; // t=298 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=307.5 | |
| #0.5 data_in = 1; // t=308 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=317.5 | |
| #0.5 data_in = 0; // t=318 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=327.5 | |
| #0.5 data_in = 1; // t=328 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=337.5 | |
| #0.5 data_in = 0; // t=338 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=347.5 | |
| #0.5 data_in = 1; // t=348 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=357.5 | |
| #0.5 data_in = 1; // t=358 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=367.5 | |
| #0.5 data_in = 1; // t=368 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=377.5 | |
| #0.5 data_in = 0; // t=378 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=387.5 | |
| #0.5 data_in = 0; // t=388 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=397.5 | |
| #0.5 data_in = 0; // t=398 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=407.5 | |
| #0.5 data_in = 1; // t=408 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=417.5 | |
| #0.5 data_in = 0; // t=418 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=427.5 | |
| #0.5 data_in = 1; // t=428 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=437.5 | |
| #0.5 data_in = 0; // t=438 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=447.5 | |
| #0.5 data_in = 0; // t=448 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=457.5 | |
| #0.5 data_in = 0; // t=458 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=467.5 | |
| #0.5 data_in = 0; // t=468 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=477.5 | |
| #0.5 data_in = 1; // t=478 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=487.5 | |
| #0.5 data_in = 1; // t=488 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=497.5 | |
| #0.5 data_in = 0; // t=498 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=507.5 | |
| #0.5 data_in = 1; // t=508 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=517.5 | |
| #0.5 data_in = 0; // t=518 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=527.5 | |
| #0.5 data_in = 0; // t=528 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=537.5 | |
| #0.5 data_in = 0; // t=538 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=547.5 | |
| #0.5 data_in = 1; // t=548 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=557.5 | |
| #0.5 data_in = 1; // t=558 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=567.5 | |
| #0.5 data_in = 1; // t=568 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=577.5 | |
| #0.5 data_in = 0; // t=578 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=587.5 | |
| #0.5 data_in = 1; // t=588 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=597.5 | |
| #0.5 data_in = 0; // t=598 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=607.5 | |
| #0.5 data_in = 1; // t=608 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=617.5 | |
| #0.5 data_in = 1; // t=618 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=627.5 | |
| #0.5 data_in = 0; // t=628 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=637.5 | |
| #0.5 data_in = 0; // t=638 | |
| #9.5 hard_chk(1'b0, "no 1001 in stream"); // t=647.5 | |
| if (error == 0) begin | |
| $display("=========== Your Design Passed ==========="); | |
| end | |
| else begin | |
| $display("=========== Test completed with %d /3 failures ===========", error); | |
| end | |
| $finish; | |
| end | |
| endmodule |