Add regression tests for $fmonitor tasks.

Also add a test for multiple $monitor task calls and $monitoron and
$monitoroff.
This commit is contained in:
Martin Whitaker 2025-10-05 12:37:30 +01:00
parent 753a52b56c
commit 1fdeb7b982
10 changed files with 289 additions and 0 deletions

View File

@ -0,0 +1,23 @@
log1:
@0 a = 0
@1 a = 1
@2 a = 2
@3 a = 3
@4 a = 4
log2:
@0 b = 0
@1 b = 1
@2 b = 2
@3 b = 3
@4 b = 4
@5 b = 5
@6 b = 6
@7 b = 7
@8 b = 8
@9 b = 9
log3:
@5 c = 5
@6 c = 6
@7 c = 7
@8 c = 8
@9 c = 9

View File

@ -0,0 +1,46 @@
log1a:
@0 a = 0
@1 a = 1
@2 a = 2
@3 a = 3
@4 a = 4
log1b:
@0 a = 0
@1 a = 1
@2 a = 2
@3 a = 3
@4 a = 4
log2a:
@0 b = 0
@1 b = 1
@2 b = 2
@3 b = 3
@4 b = 4
@5 b = 5
@6 b = 6
@7 b = 7
@8 b = 8
@9 b = 9
log2b:
@0 b = 0
@1 b = 1
@2 b = 2
@3 b = 3
@4 b = 4
@5 b = 5
@6 b = 6
@7 b = 7
@8 b = 8
@9 b = 9
log3a:
@5 c = 5
@6 c = 6
@7 c = 7
@8 c = 8
@9 c = 9
log3b:
@5 c = 5
@6 c = 6
@7 c = 7
@8 c = 8
@9 c = 9

View File

@ -0,0 +1,17 @@
@0 a = 0
@1 a = 1
@2 a = 2
@3 a = 3
@4 a = 4
@5 b = 5
@6 b = 6
@7 b = 7
@8 b = 8
@9 b = 9
@10 b = 10
@15 b = 15
@16 b = 16
@17 b = 17
@18 b = 18
@19 b = 19
@20 b = 20

View File

@ -0,0 +1,59 @@
module test;
integer a, b, c;
integer fd1, fd2, fd3;
reg [64*8:1] str;
initial begin
a = 0;
b = 0;
c = 0;
fd1 = $fopen("log/fmonitor1.log1", "w");
fd2 = $fopen("log/fmonitor1.log2", "w");
$fmonitor(fd1, "@%0t a = %0d", $time, a);
$fmonitor(fd2, "@%0t b = %0d", $time, b);
repeat (5) begin
#1;
a = a + 1;
b = b + 1;
c = c + 1;
end
$fclose(fd1);
fd3 = $fopen("log/fmonitor1.log3", "w");
$fmonitor(fd3, "@%0t c = %0d", $time, c);
repeat (5) begin
#1;
a = a + 1;
b = b + 1;
c = c + 1;
end
$fclose(fd2);
$fclose(fd3);
$display("log1:");
fd1 = $fopen("log/fmonitor1.log1", "r");
while ($fgets(str, fd1)) begin
$write("%0s", str);
end
$fclose(fd1);
$display("log2:");
fd2 = $fopen("log/fmonitor1.log2", "r");
while ($fgets(str, fd2)) begin
$write("%0s", str);
end
$fclose(fd2);
$display("log3:");
fd3 = $fopen("log/fmonitor1.log3", "r");
while ($fgets(str, fd3)) begin
$write("%0s", str);
end
$fclose(fd3);
$finish(0);
end
endmodule

View File

@ -0,0 +1,88 @@
module test;
integer a, b, c;
integer mcd1a, mcd2a, mcd3a;
integer mcd1b, mcd2b, mcd3b;
integer fd;
reg [64*8:1] str;
initial begin
a = 0;
b = 0;
c = 0;
mcd1a = $fopen("log/fmonitor2.log1a"); mcd1b = $fopen("log/fmonitor2.log1b");
mcd2a = $fopen("log/fmonitor2.log2a"); mcd2b = $fopen("log/fmonitor2.log2b");
$fmonitor(mcd1a | mcd1b, "@%0t a = %0d", $time, a);
$fmonitor(mcd2a | mcd2b, "@%0t b = %0d", $time, b);
repeat (5) begin
#1;
a = a + 1;
b = b + 1;
c = c + 1;
end
$fclose(mcd1a);
mcd3a = $fopen("log/fmonitor2.log3a"); mcd3b = $fopen("log/fmonitor2.log3b");
$fmonitor(mcd3a | mcd3b, "@%0t c = %0d", $time, c);
repeat (5) begin
#1;
a = a + 1;
b = b + 1;
c = c + 1;
end
$fclose(mcd2a);
$fclose(mcd3a);
#1;
$fclose(mcd1b);
$fclose(mcd2b);
$fclose(mcd3b);
$display("log1a:");
fd = $fopen("log/fmonitor2.log1a", "r");
while ($fgets(str, fd)) begin
$write("%0s", str);
end
$fclose(fd);
$display("log1b:");
fd = $fopen("log/fmonitor2.log1b", "r");
while ($fgets(str, fd)) begin
$write("%0s", str);
end
$fclose(fd);
$display("log2a:");
fd = $fopen("log/fmonitor2.log2a", "r");
while ($fgets(str, fd)) begin
$write("%0s", str);
end
$fclose(fd);
$display("log2b:");
fd = $fopen("log/fmonitor2.log2b", "r");
while ($fgets(str, fd)) begin
$write("%0s", str);
end
$fclose(fd);
$display("log3a:");
fd = $fopen("log/fmonitor2.log3a", "r");
while ($fgets(str, fd)) begin
$write("%0s", str);
end
$fclose(fd);
$display("log3b:");
fd = $fopen("log/fmonitor2.log3b", "r");
while ($fgets(str, fd)) begin
$write("%0s", str);
end
$fclose(fd);
$finish(0);
end
endmodule

View File

@ -0,0 +1,38 @@
// Test that $monitor correctly cancels a preceding $monitor.
module test;
integer a, b;
initial begin
a = 0;
b = 0;
$monitor("@%0t a = %0d", $time, a);
repeat (5) begin
#1;
a = a + 1;
b = b + 1;
end
$monitor("@%0t b = %0d", $time, b);
repeat (5) begin
#1;
a = a + 1;
b = b + 1;
end
$monitoroff;
repeat (5) begin
#1;
a = a + 1;
b = b + 1;
end
#0;
$monitoron;
repeat (5) begin
#1;
a = a + 1;
b = b + 1;
end
$finish(0);
end
endmodule

View File

@ -121,6 +121,8 @@ eofmt_percent vvp_tests/eofmt_percent.json
eofmt_percent-vlog95 vvp_tests/eofmt_percent-vlog95.json
fdisplay3 vvp_tests/fdisplay3.json
final3 vvp_tests/final3.json
fmonitor1 vvp_tests/fmonitor1.json
fmonitor2 vvp_tests/fmonitor2.json
fread-error vvp_tests/fread-error.json
line_directive vvp_tests/line_directive.json
localparam_type vvp_tests/localparam_type.json
@ -147,6 +149,7 @@ module_ordered_list1 vvp_tests/module_ordered_list1.json
module_ordered_list2 vvp_tests/module_ordered_list2.json
module_port_array1 vvp_tests/module_port_array1.json
module_port_array_init1 vvp_tests/module_port_array_init1.json
monitor4 vvp_tests/monitor4.json
non-polymorphic-abs vvp_tests/non-polymorphic-abs.json
partsel_invalid_idx1 vvp_tests/partsel_invalid_idx1.json
partsel_invalid_idx2 vvp_tests/partsel_invalid_idx2.json

View File

@ -0,0 +1,5 @@
{
"type" : "normal",
"source" : "fmonitor1.v",
"gold" : "fmonitor1"
}

View File

@ -0,0 +1,5 @@
{
"type" : "normal",
"source" : "fmonitor2.v",
"gold" : "fmonitor2"
}

View File

@ -0,0 +1,5 @@
{
"type" : "normal",
"source" : "monitor4.v",
"gold" : "monitor4"
}