Download Arithmetic/Comparator/comparator_4bit/testbench.v from chipagents/RTLLM-verified: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/datasets/chipagents/RTLLM-verified/resolve/main/Arithmetic/Comparator/comparator_4bit/testbench.v
- Command line
-
hf download hf://datasets/chipagents/RTLLM-verified/Arithmetic/Comparator/comparator_4bit/testbench.v
-
curl -L -o testbench.v https://huggingface.co/datasets/chipagents/RTLLM-verified/resolve/main/Arithmetic/Comparator/comparator_4bit/testbench.v
1.64 kB
| module testbench; | |
| reg [3:0] A; // Input A (4 bits) | |
| reg [3:0] B; // Input B (4 bits) | |
| wire A_greater; | |
| wire A_equal; | |
| wire A_less; | |
| integer i; | |
| integer error = 0; | |
| comparator_4bit uut ( | |
| .A(A), | |
| .B(B), | |
| .A_greater(A_greater), | |
| .A_equal(A_equal), | |
| .A_less(A_less) | |
| ); | |
| initial begin | |
| for (i = 0; i < 100; i = i + 1) begin | |
| // Generate random 4-bit inputs | |
| A = $random % 16; | |
| B = $random % 16; | |
| // Wait for the operation to complete | |
| #10; | |
| // Calculate expected results | |
| if (A_greater !== (A > B) || A_equal !== (A == B) || A_less !== (A < B)) begin | |
| error = error + 1; | |
| $display("Test failed: A = %b, B = %b, A_greater = %b, A_equal = %b, A_less = %b", | |
| A, B, A_greater, A_equal, A_less); | |
| end | |
| end | |
| // additional check: exhaustive sweep of all 256 (A,B) pairs (spec: unsigned compare, exactly one output high) | |
| for (i = 0; i < 256; i = i + 1) begin | |
| A = i[7:4]; | |
| B = i[3:0]; | |
| #10; | |
| if (A_greater !== (A > B) || A_equal !== (A == B) || A_less !== (A < B)) begin | |
| error = error + 1; | |
| $display("HARD exhaustive: A = %b, B = %b, A_greater = %b, A_equal = %b, A_less = %b", | |
| A, B, A_greater, A_equal, A_less); | |
| end | |
| end | |
| // Final test result summary | |
| if (error == 0) begin | |
| $display("=========== Your Design Passed ==========="); | |
| end | |
| else begin | |
| $display("=========== Test completed with %d /100 failures ===========", error); | |
| end | |
| $finish; | |
| end | |
| endmodule |