Created
October 24, 2019 16:47
-
-
Save taichi-ishitani/2f2092be8bb631950d2088f3b9876708 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
このコードを、Vivadoで合成しようとすると、
が起きて、合成に失敗する。
foo_struct
をtypes
インターフェースポートから導入する代わりに、module sub
内で定義すると、上記のエラーは起きない。また、以下のように、構造体リテラルではなく、メンバーを指定して代入する場合も、エラーは起きない。