Add regression tests for type casts with type identifiers
Check that type casts using type identifiers works as expected. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
227cf20684
commit
da21c62f29
|
|
@ -0,0 +1,42 @@
|
||||||
|
// Check that type cast works as expected when using type identifiers.
|
||||||
|
|
||||||
|
module test;
|
||||||
|
|
||||||
|
typedef string T_S;
|
||||||
|
typedef real T_R;
|
||||||
|
typedef logic [15:0] T_V;
|
||||||
|
|
||||||
|
string s;
|
||||||
|
real r;
|
||||||
|
logic [15:0] v;
|
||||||
|
|
||||||
|
bit failed;
|
||||||
|
|
||||||
|
`define check(expr, val) \
|
||||||
|
if (expr != val) begin \
|
||||||
|
$display("FAILED: %s, expected %0d, got %0d", `"expr`", val, expr); \
|
||||||
|
failed = 1'b1; \
|
||||||
|
end
|
||||||
|
|
||||||
|
initial begin
|
||||||
|
v = "Hi";
|
||||||
|
s = T_S'(v);
|
||||||
|
|
||||||
|
`check(s, "Hi")
|
||||||
|
|
||||||
|
v = 123;
|
||||||
|
r = T_R'(v);
|
||||||
|
|
||||||
|
`check(r, 123)
|
||||||
|
|
||||||
|
r = 1.23;
|
||||||
|
v = T_V'(r);
|
||||||
|
|
||||||
|
`check(v, 16'd1)
|
||||||
|
|
||||||
|
if (!failed) begin
|
||||||
|
$display("PASSED");
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
||||||
|
|
@ -468,6 +468,7 @@ sv_cast_integer2 normal,-g2005-sv ivltests
|
||||||
sv_cast_packed_array normal,-g2005-sv ivltests
|
sv_cast_packed_array normal,-g2005-sv ivltests
|
||||||
sv_cast_packed_struct normal,-g2005-sv ivltests
|
sv_cast_packed_struct normal,-g2005-sv ivltests
|
||||||
sv_cast_string normal,-g2005-sv ivltests
|
sv_cast_string normal,-g2005-sv ivltests
|
||||||
|
sv_cast_typedef normal,-g2005-sv ivltests
|
||||||
sv_class1 normal,-g2009 ivltests
|
sv_class1 normal,-g2009 ivltests
|
||||||
sv_class2 normal,-g2009 ivltests
|
sv_class2 normal,-g2009 ivltests
|
||||||
sv_class3 normal,-g2009 ivltests
|
sv_class3 normal,-g2009 ivltests
|
||||||
|
|
|
||||||
|
|
@ -285,6 +285,7 @@ plus_arg_string CE,-g2009 ivltests
|
||||||
sformatf CE,-g2009 ivltests
|
sformatf CE,-g2009 ivltests
|
||||||
string_events CE,-g2009 ivltests
|
string_events CE,-g2009 ivltests
|
||||||
string_index CE,-g2005-sv ivltests
|
string_index CE,-g2005-sv ivltests
|
||||||
|
sv_cast_typedef CE,-g2005-sv ivltests
|
||||||
sv_macro CE,-g2009,-pallowsigned=1 ivltests
|
sv_macro CE,-g2009,-pallowsigned=1 ivltests
|
||||||
sv_string1 CE,-g2009 ivltests
|
sv_string1 CE,-g2009 ivltests
|
||||||
sv_string2 CE,-g2009 ivltests
|
sv_string2 CE,-g2009 ivltests
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue