mirror of https://github.com/zachjs/sv2v.git
additional test coverage
- test deprecated flags - test struct const edge cases - test implicit net edge cases - test dump-prefix
This commit is contained in:
parent
6c4ee8f4bc
commit
0fb3a41ed3
|
|
@ -20,15 +20,18 @@ module top;
|
|||
and (o1, foo, bar);
|
||||
not (o2, o3, foo);
|
||||
not (u1, u2, u3);
|
||||
and (o4, foo, baz);
|
||||
|
||||
Example e (a, b, c);
|
||||
|
||||
initial begin
|
||||
`DISPLAY(foo)
|
||||
`DISPLAY(bar)
|
||||
`DISPLAY(baz)
|
||||
`DISPLAY(o1)
|
||||
`DISPLAY(o2)
|
||||
`DISPLAY(o3)
|
||||
`DISPLAY(o4)
|
||||
`DISPLAY(u1)
|
||||
`DISPLAY(u2)
|
||||
`DISPLAY(u3)
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@ module top;
|
|||
wor bar;
|
||||
assign bar = 1;
|
||||
|
||||
wor o1, o2, o3;
|
||||
wor o1, o2, o3, o4;
|
||||
wor u1, u2, u3;
|
||||
wor baz;
|
||||
and (o1, foo, bar);
|
||||
not (o2, o3, foo);
|
||||
not (u1, u2, u3);
|
||||
and (o4, foo, baz);
|
||||
|
||||
wor a, b, c;
|
||||
Example e (a, b, c);
|
||||
|
|
@ -30,9 +32,11 @@ module top;
|
|||
initial begin
|
||||
`DISPLAY(foo)
|
||||
`DISPLAY(bar)
|
||||
`DISPLAY(baz)
|
||||
`DISPLAY(o1)
|
||||
`DISPLAY(o2)
|
||||
`DISPLAY(o3)
|
||||
`DISPLAY(o4)
|
||||
`DISPLAY(u1)
|
||||
`DISPLAY(u2)
|
||||
`DISPLAY(u3)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package pkg;
|
||||
typedef struct packed {
|
||||
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;
|
||||
} T;
|
||||
`define STRUCT \
|
||||
struct packed { \
|
||||
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 extend(_b, _o) '{ \
|
||||
|
|
@ -36,11 +39,14 @@ package pkg;
|
|||
localparam X = 1'd0;
|
||||
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) \
|
||||
localparam T let_a``_ext = '{let_a: Y, default: "inv"}; \
|
||||
localparam T let_b``_cfg = `extend(let_a``_cfg, let_a``_ext);
|
||||
localparam T let_a``1_ext = '{let_a: Y, default: "inv"}; \
|
||||
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(b, c)
|
||||
|
|
@ -68,9 +74,11 @@ package pkg;
|
|||
`expand(x, y)
|
||||
`expand(y, z)
|
||||
|
||||
localparam P = z_cfg.z;
|
||||
localparam P = z1_cfg.z;
|
||||
localparam Q = 3 * z2_cfg.z;
|
||||
localparam `STRUCT R = '0;
|
||||
endpackage
|
||||
|
||||
module top;
|
||||
initial $display(pkg::P);
|
||||
initial $display(pkg::P, pkg::Q, pkg::R);
|
||||
endmodule
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
module top;
|
||||
localparam P = 32'd1;
|
||||
initial $display(P);
|
||||
localparam Q = 32'd3;
|
||||
localparam R = 832'b0;
|
||||
initial $display(P, Q, R);
|
||||
endmodule
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
dump_*.sv
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module top;
|
||||
typedef logic T;
|
||||
T x;
|
||||
assign x = 1;
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#!/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
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
`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\`)"
|
|||
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."
|
||||
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() {
|
||||
runAndCapture interface.sv module.sv package.sv
|
||||
|
|
@ -68,6 +71,27 @@ test_only_localparam_verbose() {
|
|||
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
|
||||
|
||||
. shunit2
|
||||
|
|
|
|||
Loading…
Reference in New Issue