Commit 0fb3a41e by Zachary Snow

additional test coverage

- test deprecated flags
- test struct const edge cases
- test implicit net edge cases
- test dump-prefix
parent 6c4ee8f4
...@@ -20,15 +20,18 @@ module top; ...@@ -20,15 +20,18 @@ module top;
and (o1, foo, bar); and (o1, foo, bar);
not (o2, o3, foo); not (o2, o3, foo);
not (u1, u2, u3); not (u1, u2, u3);
and (o4, foo, baz);
Example e (a, b, c); Example e (a, b, c);
initial begin initial begin
`DISPLAY(foo) `DISPLAY(foo)
`DISPLAY(bar) `DISPLAY(bar)
`DISPLAY(baz)
`DISPLAY(o1) `DISPLAY(o1)
`DISPLAY(o2) `DISPLAY(o2)
`DISPLAY(o3) `DISPLAY(o3)
`DISPLAY(o4)
`DISPLAY(u1) `DISPLAY(u1)
`DISPLAY(u2) `DISPLAY(u2)
`DISPLAY(u3) `DISPLAY(u3)
......
...@@ -18,11 +18,13 @@ module top; ...@@ -18,11 +18,13 @@ module top;
wor bar; wor bar;
assign bar = 1; assign bar = 1;
wor o1, o2, o3; wor o1, o2, o3, o4;
wor u1, u2, u3; wor u1, u2, u3;
wor baz;
and (o1, foo, bar); and (o1, foo, bar);
not (o2, o3, foo); not (o2, o3, foo);
not (u1, u2, u3); not (u1, u2, u3);
and (o4, foo, baz);
wor a, b, c; wor a, b, c;
Example e (a, b, c); Example e (a, b, c);
...@@ -30,9 +32,11 @@ module top; ...@@ -30,9 +32,11 @@ module top;
initial begin initial begin
`DISPLAY(foo) `DISPLAY(foo)
`DISPLAY(bar) `DISPLAY(bar)
`DISPLAY(baz)
`DISPLAY(o1) `DISPLAY(o1)
`DISPLAY(o2) `DISPLAY(o2)
`DISPLAY(o3) `DISPLAY(o3)
`DISPLAY(o4)
`DISPLAY(u1) `DISPLAY(u1)
`DISPLAY(u2) `DISPLAY(u2)
`DISPLAY(u3) `DISPLAY(u3)
......
package pkg; package pkg;
typedef struct packed { `define STRUCT \
integer unsigned a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z; struct packed { \
} T; integer unsigned a, b, c, d, e, f, g, h, i, j, k, l, m, \
n, o, p, q, r, s, t, u, v, w, x, y, z; \
}
typedef `STRUCT T;
`define step(b, o, f) f: o.f == "inv" ? b.f : o.f `define step(b, o, f) f: o.f == "inv" ? b.f : o.f
`define extend(_b, _o) '{ \ `define extend(_b, _o) '{ \
...@@ -36,11 +39,14 @@ package pkg; ...@@ -36,11 +39,14 @@ package pkg;
localparam X = 1'd0; localparam X = 1'd0;
localparam Y = 1'd1; localparam Y = 1'd1;
localparam T a_cfg = '{a: X, b: X, c: X, d: X, e: X, f: X, default: Y}; localparam T a1_cfg = '{a: X, b: X, c: X, d: X, e: X, f: X, default: Y};
localparam `STRUCT a2_cfg = a1_cfg;
`define expand(let_a, let_b) \ `define expand(let_a, let_b) \
localparam T let_a``_ext = '{let_a: Y, default: "inv"}; \ localparam T let_a``1_ext = '{let_a: Y, default: "inv"}; \
localparam T let_b``_cfg = `extend(let_a``_cfg, let_a``_ext); localparam T let_b``1_cfg = `extend(let_a``1_cfg, let_a``1_ext); \
localparam `STRUCT let_a``2_ext = '{let_a: Y, default: "inv"}; \
localparam `STRUCT let_b``2_cfg = `extend(let_a``2_cfg, let_a``2_ext);
`expand(a, b) `expand(a, b)
`expand(b, c) `expand(b, c)
...@@ -68,9 +74,11 @@ package pkg; ...@@ -68,9 +74,11 @@ package pkg;
`expand(x, y) `expand(x, y)
`expand(y, z) `expand(y, z)
localparam P = z_cfg.z; localparam P = z1_cfg.z;
localparam Q = 3 * z2_cfg.z;
localparam `STRUCT R = '0;
endpackage endpackage
module top; module top;
initial $display(pkg::P); initial $display(pkg::P, pkg::Q, pkg::R);
endmodule endmodule
module top; module top;
localparam P = 32'd1; localparam P = 32'd1;
initial $display(P); localparam Q = 32'd3;
localparam R = 832'b0;
initial $display(P, Q, R);
endmodule endmodule
module top;
typedef logic T;
T x;
assign x = 1;
endmodule
#!/bin/bash
PHASES=(
parse
initial
main_1
main_2
final
)
test_dump_prefix() {
runAndCapture --dump-prefix=dump_ example.sv
assertTrue "default conversion should succeed" $result
assertNotNull "stdout should not be empty" "$stdout"
assertNull "stderr should be empty" "$stderr"
assertTrue "main_3 dump should not exist" "[ ! -f dump_main_3.sv ]"
for phase in "${PHASES[@]}"; do
path=dump_$phase.sv
assertTrue "$phase dump should be non-empty" "[ -s $path ]"
rm $path
done
}
source ../lib/functions.sh
. shunit2
`default_nettype trireg
module foo;
not (x, y);
endmodule
`default_nettype uwire
module bar;
not (a, b);
endmodule
...@@ -4,6 +4,9 @@ NO_FILES_WARNING="Warning: No input files specified (try \`sv2v --help\`)" ...@@ -4,6 +4,9 @@ NO_FILES_WARNING="Warning: No input files specified (try \`sv2v --help\`)"
PACKAGE_WARNING="Warning: Source includes packages but no modules. Please convert packages alongside the modules that use them." PACKAGE_WARNING="Warning: Source includes packages but no modules. Please convert packages alongside the modules that use them."
INTERFACE_WARNING="Warning: Source includes an interface but output is empty because there is no top-level module which has no ports which are interfaces." INTERFACE_WARNING="Warning: Source includes an interface but output is empty because there is no top-level module which has no ports which are interfaces."
PORT_CONN_ATTR_WARNING="attr.sv:6:11: Warning: Ignored port connection attributes (* foo *)(* bar *)." PORT_CONN_ATTR_WARNING="attr.sv:6:11: Warning: Ignored port connection attributes (* foo *)(* bar *)."
DEPRECATED_D_WARNING="Deprecation warning: -d has been renamed to -D"
DEPRECATED_E_WARNING="Deprecation warning: -e has been renamed to -E"
DEPRECATED_I_WARNING="Deprecation warning: -i has been renamed to -I"
test_default() { test_default() {
runAndCapture interface.sv module.sv package.sv runAndCapture interface.sv module.sv package.sv
...@@ -68,6 +71,27 @@ test_only_localparam_verbose() { ...@@ -68,6 +71,27 @@ test_only_localparam_verbose() {
assertNull "stderr should be empty" "$stderr" assertNull "stderr should be empty" "$stderr"
} }
test_deprecated_d() {
runAndCapture -d FOO -v localparam.sv
assertTrue "conversion should succeed" $result
assertNotNull "stdout should not be empty" "$stdout"
assertEquals "stderr should have warning" "$DEPRECATED_D_WARNING" "$stderr"
}
test_deprecated_e() {
runAndCapture -e assert -v localparam.sv
assertTrue "conversion should succeed" $result
assertNotNull "stdout should not be empty" "$stdout"
assertEquals "stderr should have warning" "$DEPRECATED_E_WARNING" "$stderr"
}
test_deprecated_i() {
runAndCapture -i. -v localparam.sv
assertTrue "conversion should succeed" $result
assertNotNull "stdout should not be empty" "$stdout"
assertEquals "stderr should have warning" "$DEPRECATED_I_WARNING" "$stderr"
}
source ../lib/functions.sh source ../lib/functions.sh
. shunit2 . shunit2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment