Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example involving different but equivalent submodules #49

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/simple/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/ex_amend/
/fsm/
/hierarchy/
/submodules/
7 changes: 5 additions & 2 deletions examples/simple/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
EQY := eqy

test: aliases/PASS combine/PASS counter/PASS ex_amend/PASS ex_bind/PASS ex_group/PASS ex_join/PASS fsm/PASS hierarchy/PASS
test: aliases/PASS combine/PASS counter/PASS ex_amend/PASS ex_bind/PASS ex_group/PASS ex_join/PASS fsm/PASS hierarchy/PASS submodules/PASS

aliases/PASS: aliases.eqy aliases.sv
$(EQY) -f aliases.eqy
Expand Down Expand Up @@ -29,7 +29,10 @@ fsm/PASS: fsm.eqy fsm.sv
hierarchy/PASS: hierarchy.eqy hierarchy.sv
$(EQY) -f hierarchy.eqy

submodules/PASS: submodules.eqy submodules.sv
$(EQY) -f submodules.eqy

clean:
rm -rf aliases/ combine/ counter/ ex_amend/ ex_bind/ ex_group/ ex_join/ fsm/ hierarchy/
rm -rf aliases/ combine/ counter/ ex_amend/ ex_bind/ ex_group/ ex_join/ fsm/ hierarchy/ submodules/

.PHONY: test clean
15 changes: 15 additions & 0 deletions examples/simple/submodules.eqy
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[gold]
read_verilog -sv -DGOLD submodules.sv
[gate]
read_verilog -sv -DGATE submodules.sv

[script]
prep -top top

[strategy sat]
use sat
depth 5

[strategy pdr]
use sby
engine abc pdr -rfi
63 changes: 63 additions & 0 deletions examples/simple/submodules.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
`ifdef GOLD


module submod(input [7:0] a, input [7:0] b, output [7:0] outp);
assign outp = a + b;
endmodule

module top(input clk, input [7:0] a, output [7:0] b);

reg [15:0] counter = 0;

always @(posedge clk)
counter <= counter + a;


wire [7:0] tmp;

submod submod(.a(counter[7:0]), .b(counter[15:8]), .outp(tmp));

reg [7:0] counter2 = 0;

always @(posedge clk)
counter2 <= counter2 + tmp;

assign b = counter2;

endmodule
`endif


`ifdef GATE

module submod(input [7:0] a, input [7:0] b, output [7:0] outp);
assign outp = ((a * 7) + (b * 7)) * 183;
endmodule


module top(input clk, input [7:0] a, output [7:0] b);
reg [15:0] counter_late = 0;
reg [7:0] a_d = 0;


always @(posedge clk)
a_d <= a;

always @(posedge clk)
counter_late <= counter_late + a_d;

wire [15:0] counter = counter_late + a_d;

wire [7:0] tmp;

submod submod(.a(counter[7:0]), .b(counter[15:8]), .outp(tmp));

reg [7:0] neg_counter2 = 0;

always @(posedge clk)
neg_counter2 <= neg_counter2 - tmp;

assign b = -neg_counter2;
endmodule

`endif