-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7866cf8
commit f52e552
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
extern "stallable.sv" { | ||
// A latency-sensitive multiplier that takes 4 cycles to compute its result. | ||
// If stall is set to a value of 1, the multiplier will stall until the value is | ||
// set back to 0. | ||
static<4> primitive stallable_mult[WIDTH] ( | ||
@clk clk: 1, | ||
@reset reset: 1, | ||
stall: 1, | ||
left: WIDTH, | ||
right: WIDTH | ||
) -> ( | ||
out: WIDTH | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module stallable_mult #( | ||
parameter WIDTH = 32 | ||
) ( | ||
input wire clk, | ||
input wire reset, | ||
input wire stall, | ||
// inputs | ||
input wire [WIDTH-1:0] left, | ||
input wire [WIDTH-1:0] right, | ||
// The input has been committed | ||
output wire [WIDTH-1:0] out | ||
); | ||
|
||
logic [WIDTH-1:0] lt, rt, buff0, buff1, buff2, tmp_prod; | ||
|
||
assign out = buff2; | ||
assign tmp_prod = lt * rt; | ||
|
||
always_ff @(posedge clk) begin | ||
if (reset) begin | ||
lt <= 0; | ||
rt <= 0; | ||
buff0 <= 0; | ||
buff1 <= 0; | ||
buff2 <= 0; | ||
end else if (!stall) begin | ||
lt <= left; | ||
rt <= right; | ||
buff0 <= tmp_prod; | ||
buff1 <= buff0; | ||
buff2 <= buff1; | ||
end | ||
end | ||
|
||
endmodule |