aboutsummaryrefslogtreecommitdiffstats
path: root/tests/ice40/macc.v
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ice40/macc.v')
-rw-r--r--tests/ice40/macc.v34
1 files changed, 28 insertions, 6 deletions
diff --git a/tests/ice40/macc.v b/tests/ice40/macc.v
index 6c3676c83..6f68e7500 100644
--- a/tests/ice40/macc.v
+++ b/tests/ice40/macc.v
@@ -13,13 +13,35 @@ reg [(A_WIDTH + B_WIDTH - 1):0] reg_tmp_c;
assign c = reg_tmp_c;
always @(posedge clk)
begin
-if(set)
-begin
-reg_tmp_c <= 0;
+ if(set)
+ begin
+ reg_tmp_c <= 0;
+ end
+ else
+ begin
+ reg_tmp_c <= a * b + c;
+ end
end
-else
+endmodule
+
+module top2(clk,a,b,c,hold);
+parameter A_WIDTH = 6 /*4*/;
+parameter B_WIDTH = 6 /*3*/;
+input hold;
+input clk;
+input signed [(A_WIDTH - 1):0] a;
+input signed [(B_WIDTH - 1):0] b;
+output signed [(A_WIDTH + B_WIDTH - 1):0] c;
+reg signed [A_WIDTH-1:0] reg_a;
+reg signed [B_WIDTH-1:0] reg_b;
+reg [(A_WIDTH + B_WIDTH - 1):0] reg_tmp_c;
+assign c = reg_tmp_c;
+always @(posedge clk)
begin
-reg_tmp_c <= a * b + c;
-end
+ if (!hold) begin
+ reg_a <= a;
+ reg_b <= b;
+ reg_tmp_c <= reg_a * reg_b + c;
+ end
end
endmodule