Skip to content

Commit 1097bcc

Browse files
committed
added new dataset
1 parent 135e597 commit 1097bcc

File tree

8 files changed

+435
-0
lines changed

8 files changed

+435
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module not_gate ( input in, output out );
2+
3+
assign out = ~in; // assign input inverted to output
4+
5+
endmodule
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
$date
2+
Tue Aug 19 21:01:04 2025
3+
$end
4+
$version
5+
Icarus Verilog
6+
$end
7+
$timescale
8+
1ps
9+
$end
10+
$scope module tb_not_gate $end
11+
$var wire 1 ! out $end
12+
$var reg 1 " in $end
13+
$var integer 32 # num_tests_passed [31:0] $end
14+
$var integer 32 $ total_tests [31:0] $end
15+
$scope module dut $end
16+
$var wire 1 " in $end
17+
$var wire 1 ! out $end
18+
$upscope $end
19+
$upscope $end
20+
$enddefinitions $end
21+
$comment Show the parameter values. $end
22+
$dumpall
23+
$end
24+
#0
25+
$dumpvars
26+
b0 $
27+
b0 #
28+
0"
29+
1!
30+
$end
31+
#10000
32+
0!
33+
1"
34+
b1 $
35+
b1 #
36+
#20000
37+
1!
38+
0"
39+
b10 $
40+
b10 #
41+
#25000
42+
0!
43+
1"
44+
b11 $
45+
b11 #
46+
#30000
47+
1!
48+
0"
49+
b100 $
50+
b100 #
51+
#35000
52+
0!
53+
1"
54+
b101 $
55+
b101 #
56+
#40000
57+
1!
58+
0"
59+
b110 $
60+
b110 #
61+
#45000
62+
0!
63+
1"
64+
b111 $
65+
b111 #
66+
#50000
67+
1!
68+
0"
69+
b1000 $
70+
b1000 #
71+
#55000
72+
0!
73+
1"
74+
b1001 $
75+
b1001 #
76+
#60000
77+
1!
78+
0"
79+
b1010 $
80+
b1010 #
81+
#65000
82+
0!
83+
1"
84+
b1011 $
85+
b1011 #
86+
#70000
87+
b1100 $
88+
b1100 #
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This a not gate module
2+
module not_gate ( input in, output out);
3+
// Insert code here
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This a not gate module
2+
module not_gate ( input in, output out);
3+
// Invert input when assigning to output
4+
// Insert code here
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This a not gate module
2+
module not_gate ( input in, output out);
3+
// Invert input while assigning to output
4+
// Use the invert symbol (~)
5+
// Insert code here
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
`timescale 1ns/1ps
2+
3+
module tb_not_gate();
4+
// Inputs (driven by testbench)
5+
reg in;
6+
7+
// Outputs (driven by DUT)
8+
wire out;
9+
10+
// Instantiate the Design Under Test (DUT)
11+
not_gate dut (
12+
.in(in),
13+
.out(out)
14+
);
15+
16+
// Test variables
17+
integer num_tests_passed;
18+
integer total_tests;
19+
20+
initial begin
21+
// Initialize test tracking
22+
num_tests_passed = 0;
23+
total_tests = 0;
24+
25+
// Display header
26+
$display("=========================================");
27+
$display("Testing not_gate module");
28+
$display("=========================================");
29+
$display("Time | Input | Expected | Output | Result");
30+
$display("-----------------------------------------");
31+
32+
// Test both possible input values (0 and 1)
33+
// Test 1: Input = 0
34+
in = 1'b0;
35+
#10;
36+
if (out == 1'b1) begin
37+
$display("%3t | %b | %b | %b | PASS",
38+
$time, in, ~in, out);
39+
num_tests_passed = num_tests_passed + 1;
40+
end else begin
41+
$display("%3t | %b | %b | %b | FAIL",
42+
$time, in, ~in, out);
43+
end
44+
total_tests = total_tests + 1;
45+
46+
// Test 2: Input = 1
47+
in = 1'b1;
48+
#10;
49+
if (out == 1'b0) begin
50+
$display("%3t | %b | %b | %b | PASS",
51+
$time, in, ~in, out);
52+
num_tests_passed = num_tests_passed + 1;
53+
end else begin
54+
$display("%3t | %b | %b | %b | FAIL",
55+
$time, in, ~in, out);
56+
end
57+
total_tests = total_tests + 1;
58+
59+
// Toggle test
60+
$display("\nToggle test:");
61+
repeat(10) begin
62+
in = ~in; // Toggle input
63+
#5;
64+
65+
if (out == ~in) begin
66+
$display("%3t | %b | %b | %b | PASS",
67+
$time, in, ~in, out);
68+
num_tests_passed = num_tests_passed + 1;
69+
end else begin
70+
$display("%3t | %b | %b | %b | FAIL",
71+
$time, in, ~in, out);
72+
end
73+
total_tests = total_tests + 1;
74+
end
75+
76+
// Final Summary
77+
$display("\n=========================================");
78+
$display("Test Summary: %0d/%0d tests passed", num_tests_passed, total_tests);
79+
if (num_tests_passed == total_tests)
80+
$display("Overall Result: ALL TESTS PASSED ✓");
81+
else
82+
$display("Overall Result: SOME TESTS FAILED ✗");
83+
$display("=========================================");
84+
85+
$finish;
86+
end
87+
88+
// Generate VCD file for waveform viewing
89+
initial begin
90+
$dumpfile("not_gate_tb.vcd");
91+
$dumpvars(0, tb_not_gate);
92+
end
93+
94+
endmodule
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#! /opt/homebrew/Cellar/icarus-verilog/12.0/bin/vvp
2+
:ivl_version "12.0 (stable)";
3+
:ivl_delay_selection "TYPICAL";
4+
:vpi_time_precision - 12;
5+
:vpi_module "/opt/homebrew/Cellar/icarus-verilog/12.0/lib/ivl/system.vpi";
6+
:vpi_module "/opt/homebrew/Cellar/icarus-verilog/12.0/lib/ivl/vhdl_sys.vpi";
7+
:vpi_module "/opt/homebrew/Cellar/icarus-verilog/12.0/lib/ivl/vhdl_textio.vpi";
8+
:vpi_module "/opt/homebrew/Cellar/icarus-verilog/12.0/lib/ivl/v2005_math.vpi";
9+
:vpi_module "/opt/homebrew/Cellar/icarus-verilog/12.0/lib/ivl/va_math.vpi";
10+
S_0x134704080 .scope module, "tb_not_gate" "tb_not_gate" 2 3;
11+
.timescale -9 -12;
12+
v0x6000031d4240_0 .var "in", 0 0;
13+
v0x6000031d42d0_0 .var/i "num_tests_passed", 31 0;
14+
v0x6000031d4360_0 .net "out", 0 0, L_0x6000028d07e0; 1 drivers
15+
v0x6000031d43f0_0 .var/i "total_tests", 31 0;
16+
S_0x1347041f0 .scope module, "dut" "not_gate" 2 11, 3 1 0, S_0x134704080;
17+
.timescale -9 -12;
18+
.port_info 0 /INPUT 1 "in";
19+
.port_info 1 /OUTPUT 1 "out";
20+
L_0x6000028d07e0 .functor NOT 1, v0x6000031d4240_0, C4<0>, C4<0>, C4<0>;
21+
v0x6000031d4120_0 .net "in", 0 0, v0x6000031d4240_0; 1 drivers
22+
v0x6000031d41b0_0 .net "out", 0 0, L_0x6000028d07e0; alias, 1 drivers
23+
.scope S_0x134704080;
24+
T_0 ;
25+
%pushi/vec4 0, 0, 32;
26+
%store/vec4 v0x6000031d42d0_0, 0, 32;
27+
%pushi/vec4 0, 0, 32;
28+
%store/vec4 v0x6000031d43f0_0, 0, 32;
29+
%vpi_call 2 26 "$display", "=========================================" {0 0 0};
30+
%vpi_call 2 27 "$display", "Testing not_gate module" {0 0 0};
31+
%vpi_call 2 28 "$display", "=========================================" {0 0 0};
32+
%vpi_call 2 29 "$display", "Time | Input | Expected | Output | Result" {0 0 0};
33+
%vpi_call 2 30 "$display", "-----------------------------------------" {0 0 0};
34+
%pushi/vec4 0, 0, 1;
35+
%store/vec4 v0x6000031d4240_0, 0, 1;
36+
%delay 10000, 0;
37+
%load/vec4 v0x6000031d4360_0;
38+
%cmpi/e 1, 0, 1;
39+
%jmp/0xz T_0.0, 4;
40+
%load/vec4 v0x6000031d4240_0;
41+
%inv;
42+
%vpi_call 2 37 "$display", "%3t | %b | %b | %b | PASS", $time, v0x6000031d4240_0, S<0,vec4,u1>, v0x6000031d4360_0 {1 0 0};
43+
%load/vec4 v0x6000031d42d0_0;
44+
%addi 1, 0, 32;
45+
%store/vec4 v0x6000031d42d0_0, 0, 32;
46+
%jmp T_0.1;
47+
T_0.0 ;
48+
%load/vec4 v0x6000031d4240_0;
49+
%inv;
50+
%vpi_call 2 41 "$display", "%3t | %b | %b | %b | FAIL", $time, v0x6000031d4240_0, S<0,vec4,u1>, v0x6000031d4360_0 {1 0 0};
51+
T_0.1 ;
52+
%load/vec4 v0x6000031d43f0_0;
53+
%addi 1, 0, 32;
54+
%store/vec4 v0x6000031d43f0_0, 0, 32;
55+
%pushi/vec4 1, 0, 1;
56+
%store/vec4 v0x6000031d4240_0, 0, 1;
57+
%delay 10000, 0;
58+
%load/vec4 v0x6000031d4360_0;
59+
%cmpi/e 0, 0, 1;
60+
%jmp/0xz T_0.2, 4;
61+
%load/vec4 v0x6000031d4240_0;
62+
%inv;
63+
%vpi_call 2 50 "$display", "%3t | %b | %b | %b | PASS", $time, v0x6000031d4240_0, S<0,vec4,u1>, v0x6000031d4360_0 {1 0 0};
64+
%load/vec4 v0x6000031d42d0_0;
65+
%addi 1, 0, 32;
66+
%store/vec4 v0x6000031d42d0_0, 0, 32;
67+
%jmp T_0.3;
68+
T_0.2 ;
69+
%load/vec4 v0x6000031d4240_0;
70+
%inv;
71+
%vpi_call 2 54 "$display", "%3t | %b | %b | %b | FAIL", $time, v0x6000031d4240_0, S<0,vec4,u1>, v0x6000031d4360_0 {1 0 0};
72+
T_0.3 ;
73+
%load/vec4 v0x6000031d43f0_0;
74+
%addi 1, 0, 32;
75+
%store/vec4 v0x6000031d43f0_0, 0, 32;
76+
%vpi_call 2 60 "$display", "\012Toggle test:" {0 0 0};
77+
%pushi/vec4 10, 0, 32;
78+
T_0.4 %dup/vec4;
79+
%pushi/vec4 0, 0, 32;
80+
%cmp/s;
81+
%jmp/1xz T_0.5, 5;
82+
%jmp/1 T_0.5, 4;
83+
%pushi/vec4 1, 0, 32;
84+
%sub;
85+
%load/vec4 v0x6000031d4240_0;
86+
%inv;
87+
%store/vec4 v0x6000031d4240_0, 0, 1;
88+
%delay 5000, 0;
89+
%load/vec4 v0x6000031d4360_0;
90+
%load/vec4 v0x6000031d4240_0;
91+
%inv;
92+
%cmp/e;
93+
%jmp/0xz T_0.6, 4;
94+
%load/vec4 v0x6000031d4240_0;
95+
%inv;
96+
%vpi_call 2 66 "$display", "%3t | %b | %b | %b | PASS", $time, v0x6000031d4240_0, S<0,vec4,u1>, v0x6000031d4360_0 {1 0 0};
97+
%load/vec4 v0x6000031d42d0_0;
98+
%addi 1, 0, 32;
99+
%store/vec4 v0x6000031d42d0_0, 0, 32;
100+
%jmp T_0.7;
101+
T_0.6 ;
102+
%load/vec4 v0x6000031d4240_0;
103+
%inv;
104+
%vpi_call 2 70 "$display", "%3t | %b | %b | %b | FAIL", $time, v0x6000031d4240_0, S<0,vec4,u1>, v0x6000031d4360_0 {1 0 0};
105+
T_0.7 ;
106+
%load/vec4 v0x6000031d43f0_0;
107+
%addi 1, 0, 32;
108+
%store/vec4 v0x6000031d43f0_0, 0, 32;
109+
%jmp T_0.4;
110+
T_0.5 ;
111+
%pop/vec4 1;
112+
%vpi_call 2 77 "$display", "\012=========================================" {0 0 0};
113+
%vpi_call 2 78 "$display", "Test Summary: %0d/%0d tests passed", v0x6000031d42d0_0, v0x6000031d43f0_0 {0 0 0};
114+
%load/vec4 v0x6000031d42d0_0;
115+
%load/vec4 v0x6000031d43f0_0;
116+
%cmp/e;
117+
%jmp/0xz T_0.8, 4;
118+
%vpi_call 2 80 "$display", "Overall Result: ALL TESTS PASSED \342\234\223" {0 0 0};
119+
%jmp T_0.9;
120+
T_0.8 ;
121+
%vpi_call 2 82 "$display", "Overall Result: SOME TESTS FAILED \342\234\227" {0 0 0};
122+
T_0.9 ;
123+
%vpi_call 2 83 "$display", "=========================================" {0 0 0};
124+
%vpi_call 2 85 "$finish" {0 0 0};
125+
%end;
126+
.thread T_0;
127+
.scope S_0x134704080;
128+
T_1 ;
129+
%vpi_call 2 90 "$dumpfile", "not_gate_tb.vcd" {0 0 0};
130+
%vpi_call 2 91 "$dumpvars", 32'sb00000000000000000000000000000000, S_0x134704080 {0 0 0};
131+
%end;
132+
.thread T_1;
133+
# The file index is used to find the file name in the following table.
134+
:file_names 4;
135+
"N/A";
136+
"<interactive>";
137+
"tb_inverter.v";
138+
"answer_inverter.v";

0 commit comments

Comments
 (0)