Merge pull request #1200 from larsclausen/class-property-logic-init

vvp: Fix logic class property initialization
This commit is contained in:
Lars-Peter Clausen 2025-01-05 15:52:12 -08:00 committed by GitHub
commit d0327c5eda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,28 @@
// Check that logic class properties are initialized to 'x.
module test;
bit failed = 1'b0;
`define check(val, exp) do \
if (val != exp) begin \
$display("FAILED(%0d). '%s' expected %d, got %d", `__LINE__, `"val`", exp, val); \
failed = 1'b1; \
end \
while(0)
class C;
logic [31:0] x;
endclass
C c;
initial begin
c = new;
`check(c.x, 32'hxx);
if (!failed) begin
$display("PASSED");
end
end
endmodule

View File

@ -222,6 +222,7 @@ sv_chained_constructor2 vvp_tests/sv_chained_constructor2.json
sv_chained_constructor3 vvp_tests/sv_chained_constructor3.json
sv_chained_constructor4 vvp_tests/sv_chained_constructor4.json
sv_chained_constructor5 vvp_tests/sv_chained_constructor5.json
sv_class_prop_logic vvp_tests/sv_class_prop_logic.json
sv_const1 vvp_tests/sv_const1.json
sv_const2 vvp_tests/sv_const2.json
sv_const3 vvp_tests/sv_const3.json

View File

@ -0,0 +1,5 @@
{
"type" : "normal",
"source" : "sv_class_prop_logic.v",
"iverilog-args" : [ "-g2005-sv" ]
}

View File

@ -175,7 +175,7 @@ class property_logic : public class_property_t {
public:
void construct(char*buf) const
{ new (buf+offset_) vvp_vector4_t (0, wid_); }
{ new (buf+offset_) vvp_vector4_t (wid_); }
void destruct(char*buf) const
{ vvp_vector4_t*tmp = reinterpret_cast<vvp_vector4_t*>(buf+offset_);