Skip to content

Instantly share code, notes, and snippets.

@taichi-ishitani
Created October 24, 2019 16:47
Show Gist options
  • Save taichi-ishitani/2f2092be8bb631950d2088f3b9876708 to your computer and use it in GitHub Desktop.
Save taichi-ishitani/2f2092be8bb631950d2088f3b9876708 to your computer and use it in GitHub Desktop.
interface foo_types;
typedef struct packed {
logic foo;
} foo_struct;
endinterface
module sub (
foo_types types,
input logic i_clk,
input logic i_rst_n,
input logic i_a,
output logic o_b
);
typedef types.foo_struct foo_struct;
//typedef struct packed {
// logic foo;
//} foo_struct;
foo_struct foo;
always_ff @(posedge i_clk, negedge i_rst_n) begin
if (!i_rst_n) foo <= '0;
else foo <= '{ foo: i_a };
end
always_comb begin
o_b = foo.foo;
end
endmodule
module top (
input logic i_clk,
input logic i_rst_n,
input logic i_a,
output logic o_b
);
foo_types types();
sub u_sub (types, i_clk, i_rst_n, i_a, o_b);
endmodule
@taichi-ishitani
Copy link
Author

taichi-ishitani commented Oct 24, 2019

このコードを、Vivadoで合成しようとすると、

[Synth 8-2119] illegal context for assignment pattern ["/home/ishitani/workspace/test/illegal_assignment/illegal_assignment.sv":22]

が起きて、合成に失敗する。

foo_structtypes インターフェースポートから導入する代わりに、module sub 内で定義すると、上記のエラーは起きない。

また、以下のように、構造体リテラルではなく、メンバーを指定して代入する場合も、エラーは起きない。

always_ff @(posedge i_clk, negedge i_rst_n) begin
  if (!i_rst_n) foo     <= '0;
  else          foo.foo <= i_a;
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment