forked from github/verilator
Fix unpacked struct clocking
This commit is contained in:
parent
fc3fdcc71c
commit
9e25c21fed
@ -510,6 +510,11 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
||||
puts(".");
|
||||
puts(nodep->prettyName());
|
||||
}
|
||||
void visit(AstStructSel* nodep) override {
|
||||
iterate(nodep->fromp());
|
||||
puts(".");
|
||||
puts(nodep->prettyName());
|
||||
}
|
||||
void visit(AstAttrOf* nodep) override {
|
||||
putfs(nodep, "$_ATTROF(");
|
||||
iterateAndNextConstNull(nodep->fromp());
|
||||
|
@ -50,6 +50,7 @@ module sub #(
|
||||
initial begin
|
||||
struct_t substruct;
|
||||
substruct.data = '1;
|
||||
`checkh($bits(struct_t), EXP_WIDTH);
|
||||
`checkh(substruct.data, expval);
|
||||
end
|
||||
|
||||
|
21
test_regress/t/t_struct_clk.pl
Executable file
21
test_regress/t/t_struct_clk.pl
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2023 by Wilson Snyder. This program is free software; you
|
||||
# can redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
scenarios(simulator => 1);
|
||||
|
||||
compile(
|
||||
);
|
||||
|
||||
execute(
|
||||
check_finished => 1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
52
test_regress/t/t_struct_clk.v
Normal file
52
test_regress/t/t_struct_clk.v
Normal file
@ -0,0 +1,52 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2023 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); $stop; end while(0);
|
||||
|
||||
typedef struct {
|
||||
logic clk1;
|
||||
logic clk2;
|
||||
logic rst;
|
||||
} clks_t;
|
||||
|
||||
module t(/*AUTOARG*/
|
||||
// Inputs
|
||||
clk, fastclk
|
||||
);
|
||||
input clk;
|
||||
input fastclk;
|
||||
|
||||
int cyc = 0;
|
||||
|
||||
clks_t clks;
|
||||
always_comb begin
|
||||
clks.clk1 = clk;
|
||||
clks.clk2 = fastclk;
|
||||
end
|
||||
|
||||
// verilator lint_off MULTIDRIVEN
|
||||
int cyc1 = 0;
|
||||
int cyc2 = 0;
|
||||
|
||||
always @ (negedge clks.clk1) cyc1 <= cyc1 + 1;
|
||||
always @ (negedge clks.clk2) cyc2 <= cyc2 + 1;
|
||||
|
||||
always @ (posedge clk) begin
|
||||
cyc <= cyc + 1;
|
||||
if (cyc < 10) begin
|
||||
cyc1 <= '0;
|
||||
cyc2 <= '0;
|
||||
end
|
||||
else if (cyc == 99) begin
|
||||
`checkd(cyc1, 90);
|
||||
`checkd(cyc2, 90*5);
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user