diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-10-18 10:58:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-18 10:58:47 +0200 |
commit | f24bc1ed0a80e48bc23ae68169b6b0bbce5f113c (patch) | |
tree | 1778829a6932d18730a3a085a80a65205189c7ba /tests | |
parent | 24a5c6585678f89058382fe2c3f36b821b419e90 (diff) | |
parent | 736105b0468f9468f00915cad60949535ce5a496 (diff) | |
download | yosys-f24bc1ed0a80e48bc23ae68169b6b0bbce5f113c.tar.gz yosys-f24bc1ed0a80e48bc23ae68169b6b0bbce5f113c.tar.bz2 yosys-f24bc1ed0a80e48bc23ae68169b6b0bbce5f113c.zip |
Merge pull request #659 from rubund/sv_interfaces
Support for SystemVerilog interfaces and modports
Diffstat (limited to 'tests')
-rw-r--r-- | tests/simple/svinterface1.sv | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/tests/simple/svinterface1.sv b/tests/simple/svinterface1.sv new file mode 100644 index 000000000..64383a06c --- /dev/null +++ b/tests/simple/svinterface1.sv @@ -0,0 +1,90 @@ + + +module TopModule( + input logic clk, + input logic rst, + input logic [1:0] sig, + output logic [1:0] sig_out); + + MyInterface #(.WIDTH(4)) MyInterfaceInstance(); + + SubModule1 u_SubModule1 ( + .clk(clk), + .rst(rst), + .u_MyInterface(MyInterfaceInstance), + .sig (sig) + ); + + assign sig_out = MyInterfaceInstance.mysig_out; + + + assign MyInterfaceInstance.setting = 1; +// assign MyInterfaceInstance.other_setting[2:0] = 3'b101; + +endmodule + +interface MyInterface #( + parameter WIDTH = 3)( + ); + + logic setting; + logic [WIDTH-1:0] other_setting; + + logic [1:0] mysig_out; + + modport submodule1 ( + input setting, + output other_setting, + output mysig_out + ); + + modport submodule2 ( + input setting, + output other_setting, + input mysig_out + ); + +endinterface + + +module SubModule1( + input logic clk, + input logic rst, + MyInterface.submodule1 u_MyInterface, + input logic [1:0] sig + + ); + + always_ff @(posedge clk or posedge rst) + if(rst) + u_MyInterface.mysig_out <= 0; + else begin + if(u_MyInterface.setting) + u_MyInterface.mysig_out <= sig; + else + u_MyInterface.mysig_out <= ~sig; + end + + MyInterface #(.WIDTH(22)) MyInterfaceInstanceInSub(); + + SubModule2 u_SubModule2 ( + .clk(clk), + .rst(rst), + .u_MyInterfaceInSub2(u_MyInterface), + .sig (sig) + ); + +endmodule + +module SubModule2( + + input logic clk, + input logic rst, + MyInterface.submodule2 u_MyInterfaceInSub2, + input logic [1:0] sig + + ); + + assign u_MyInterfaceInSub2.other_setting[2:0] = 9; + +endmodule |