制作struct
packed
并替换{ >> {a} }
为a
:
typedef struct packed {
bit y;
bit x;
} t_my_unpkd_struct;
t_my_unpkd_struct a[1:0];
bit [1:0] bb[1:0];
assign a = { << t_my_unpkd_struct {bb} };
用于证明的简单测试台:
bit clk; always #5ns clk++;
default clocking cb @(posedge clk);
endclocking
initial begin
repeat(20) begin
@(negedge clk);
void'(randomize(bb));
end
#10ns;
$finish(2);
end
assert property (a[0].x == bb[1][0]);
assert property (a[0].y == bb[1][1]);
assert property (a[1].x == bb[0][0]);
assert property (a[1].y == bb[0][1]);
更新:以下适用于未打包的结构:
assign a = { << 2 {bb} };
或者
always_comb { << 2 {a} } = { << t_my_unpkd_struct {bb} };