-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression tests for early signal elaboration.
- Loading branch information
1 parent
ca30705
commit ef7f0a8
Showing
14 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ivltests/early_sig_elab3.v:8: error: Circular dependency detected in declaration of 'a'. | ||
1 error(s) during elaboration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module test_mod (); | ||
|
||
typedef enum logic [4:0] {ENUM_ELEM1, ENUM_ELEM2} test_enum_t; | ||
|
||
test_enum_t test_mem_addr_e; | ||
logic [1:0] test_mem [test_mem_addr_e.num()]; | ||
|
||
initial begin | ||
test_mem[ENUM_ELEM1] = 1; | ||
test_mem[ENUM_ELEM2] = 2; | ||
$display("ENUM_ELEM1 = %d test_mem[ENUM_ELEM1] = %d", ENUM_ELEM1, test_mem[ENUM_ELEM1]); | ||
$display("ENUM_ELEM2 = %d test_mem[ENUM_ELEM2] = %d", ENUM_ELEM2, test_mem[ENUM_ELEM2]); | ||
if (test_mem[ENUM_ELEM1] === 1 && test_mem[ENUM_ELEM2] === 2) | ||
$display("PASSED"); | ||
else | ||
$display("FAILED"); | ||
end | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Strictly speaking this is illegal as it uses a hierarchical name in a | ||
// constant expression. | ||
module top; | ||
parameter ENABLE = 1; | ||
if (ENABLE) begin : blk | ||
wire [7:0] w; | ||
end | ||
wire [7:0] x; | ||
wire [$bits(blk.w)-1:0] y = 8'h55; | ||
wire [$bits(x)-1:0] z = 8'haa; | ||
initial begin | ||
$display("blk.w: %b (%0d bits)", blk.w, $bits(blk.w)); | ||
$display("x: %b (%0d bits)", x, $bits(x)); | ||
$display("y: %b (%0d bits)", y, $bits(y)); | ||
$display("z: %b (%0d bits)", z, $bits(z)); | ||
if (y === 8'h55 && z === 8'haa) | ||
$display("PASSED"); | ||
else | ||
$display("FAILED"); | ||
end | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Module; | ||
parameter T = 10; | ||
wire [T-1:0] x = 8'h55; | ||
initial $display("Module %b %0d", x, T); | ||
endmodule | ||
|
||
module top; | ||
wire [7:0] x; | ||
Module #($bits(x)) mA(); | ||
Module #(8) mB(); | ||
|
||
initial begin | ||
if (mA.x === 8'h55 && mB.x === 8'h55) | ||
$display("PASSED"); | ||
else | ||
$display("FAILED"); | ||
end | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Icarus elaborates signals in alphabetical order, so force early | ||
// elaboration that way. | ||
|
||
module test; | ||
|
||
localparam LSB = 0; | ||
localparam MSB = 7; | ||
|
||
reg [MSB:LSB] c; | ||
reg [$bits(c):1] a; | ||
|
||
localparam WIDTH = $bits(c); | ||
|
||
reg [WIDTH:1] b; | ||
|
||
initial begin | ||
$display("a = %b", a); | ||
$display("b = %b", b); | ||
if ($bits(a) === 8 && $bits(b) == 8) | ||
$display("PASSED"); | ||
else | ||
$display("FAILED"); | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Strictly speaking this is not legal as it uses a hierarchical name in a | ||
// constant expression, | ||
|
||
module test1; | ||
|
||
reg [$bits(test2.v):1] v; | ||
|
||
endmodule | ||
|
||
module test2; | ||
|
||
reg [7:0] v; | ||
|
||
initial begin | ||
if ($bits(test1.v) === 8 && $bits(test3.v) === 8) | ||
$display("PASSED"); | ||
else | ||
$display("FAILED"); | ||
end | ||
|
||
endmodule | ||
|
||
module test3; | ||
|
||
reg [$bits(test2.v):1] v; | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Test we detect and report circular dependencies. | ||
|
||
// Strictly speaking this is not legal as it uses a hierarchical name in a | ||
// constant expression, | ||
|
||
module test; | ||
|
||
reg [$bits(test.b):1] a; | ||
reg [$bits(test.a):1] b; | ||
|
||
initial begin | ||
// This test is expected to fail at compile time. | ||
$display("FAILED"); | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type" : "normal", | ||
"source" : "br_gh1097.v", | ||
"iverilog-args" : [ "-g2009" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type" : "normal", | ||
"source" : "br_gh483a.v" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type" : "normal", | ||
"source" : "br_gh483b.v" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type" : "normal", | ||
"source" : "early_sig_elab1.v" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type" : "normal", | ||
"source" : "early_sig_elab2.v" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type" : "CE", | ||
"source" : "early_sig_elab3.v", | ||
"gold" : "early_sig_elab3" | ||
} |