diff options
author | Yann Herklotz <git@yannherklotz.com> | 2020-10-09 10:10:10 +0100 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2020-10-09 10:10:10 +0100 |
commit | 81e3160888df02e23fd6ff294cdab3a50f0bf3c1 (patch) | |
tree | d1566ebe3b72dbbf400ba2b87b1ea2279185e493 /data | |
parent | 8cde91d3d3d7cd63c0944f75af749d59b1f35d1a (diff) | |
download | oopsla21_fvhls-81e3160888df02e23fd6ff294cdab3a50f0bf3c1.tar.gz oopsla21_fvhls-81e3160888df02e23fd6ff294cdab3a50f0bf3c1.zip |
Make figures fit onto the page
Diffstat (limited to 'data')
-rw-r--r-- | data/accumulator.c | 4 | ||||
-rw-r--r-- | data/accumulator.rtl | 32 | ||||
-rw-r--r-- | data/accumulator1.v | 32 | ||||
-rw-r--r-- | data/accumulator2.v | 26 |
4 files changed, 77 insertions, 17 deletions
diff --git a/data/accumulator.c b/data/accumulator.c index 7d78a61..007ae2b 100644 --- a/data/accumulator.c +++ b/data/accumulator.c @@ -1,7 +1,9 @@ int main() { int x[3] = {1, 2, 3}; int sum = 0, incr = 1; - for (int i = 0; i < 3; i=i+incr) + for (int i = 0; + i < 3; + i=i+incr) sum += x[i]; return sum; } diff --git a/data/accumulator.rtl b/data/accumulator.rtl index a6b528c..bf0af2f 100644 --- a/data/accumulator.rtl +++ b/data/accumulator.rtl @@ -1,18 +1,18 @@ main() { - 16: x9 = 1 - 15: int32[stack(0)] = x9 - 14: x8 = 2 - 13: int32[stack(4)] = x8 - 12: x7 = 3 - 11: int32[stack(8)] = x7 - 10: x3 = 0 - 9: nop - 8: x1 = 0 - 7: x6 = stack(0) (int) - 6: x5 = int32[x6 + x1 * 4 + 0] - 5: x3 = x3 + x5 + 0 (int) - 4: x1 = x1 + 1 (int) - 3: if (x1 <s 3) goto 7 else goto 2 - 2: x4 = x3 - 1: return x4 +6: x9 = 1 +5: int32[stack(0)] = x9 +4: x8 = 2 +3: int32[stack(4)] = x8 +2: x7 = 3 +1: int32[stack(8)] = x7 +0: x3 = 0 +9: nop +8: x1 = 0 +7: x6 = stack(0) (int) +6: x5 = int32[x6 + x1 * 4 + 0] +5: x3 = x3 + x5 + 0 (int) +4: x1 = x1 + 1 (int) +3: if (x1 <s 3) goto 7 else goto 2 +2: x4 = x3 +1: return x4 } diff --git a/data/accumulator1.v b/data/accumulator1.v new file mode 100644 index 0000000..5e9637a --- /dev/null +++ b/data/accumulator1.v @@ -0,0 +1,32 @@ +module main(reset, clk, finish, return_val); + reg [31:0] stack [2:0]; + input [0:0] clk, reset; + output reg [31:0] return_val; + output reg [0:0] finish; + reg [31:0] reg_8, reg_4, state, + reg_6, reg_1, reg_9, + reg_5, reg_3, reg_7; + always @(posedge clk) + case (state) + 32'd16: reg_9 <= 32'd1; + 32'd15: stack[32'd0] <= reg_9; + 32'd14: reg_8 <= 32'd2; + 32'd13: stack[32'd1] <= reg_8; + 32'd12: reg_7 <= 32'd3; + 32'd11: stack[32'd2] <= reg_7; + 32'd10: reg_3 <= 32'd0; + 32'd9: ; + 32'd8: reg_1 <= 32'd0; + 32'd7: reg_6 <= 32'd0; + 32'd6: reg_5 <= stack[{{{reg_6 + 32'd0} + + {reg_1 * 32'd4}} / 32'd4}]; + 32'd5: reg_3 <= {reg_3 + {reg_5 + 32'd0}}; + 32'd4: reg_1 <= {reg_1 + 32'd1}; + 32'd3: ; + 32'd2: reg_4 <= reg_3; + 32'd1: begin + finish = 1'd1; + return_val = reg_4; + end + default:; + endcase diff --git a/data/accumulator2.v b/data/accumulator2.v new file mode 100644 index 0000000..c7bcc59 --- /dev/null +++ b/data/accumulator2.v @@ -0,0 +1,26 @@ +always @(posedge clk) + if ({reset == 1'd1}) + state <= 32'd16; + else + case (state) + 32'd16: state <= 32'd15; + 32'd15: state <= 32'd14; + 32'd14: state <= 32'd13; + 32'd13: state <= 32'd12; + 32'd12: state <= 32'd11; + 32'd11: state <= 32'd10; + 32'd10: state <= 32'd9; + 32'd9: state <= 32'd8; + 32'd8: state <= 32'd7; + 32'd7: state <= 32'd6; + 32'd6: state <= 32'd5; + 32'd5: state <= 32'd4; + 32'd4: state <= 32'd3; + 32'd3: state <= + ({$signed(reg_1) < $signed(32'd3)} + ? 32'd7 : 32'd2); + 32'd2: state <= 32'd1; + 32'd1: ; + default:; + endcase +endmodule |