diff options
author | Eddie Hung <eddie@fpgeh.com> | 2019-08-30 16:18:14 -0700 |
---|---|---|
committer | Eddie Hung <eddie@fpgeh.com> | 2019-08-30 16:18:14 -0700 |
commit | 9be9631e5acaa570804e1772caae55f5cfc7a918 (patch) | |
tree | 62211bce2dbdbc46b6afa6d3223e9514f859197c /tests/xilinx/macc.v | |
parent | 8f503fe3e65ba9be2ef7438b2f4143f88ea8a025 (diff) | |
download | yosys-9be9631e5acaa570804e1772caae55f5cfc7a918.tar.gz yosys-9be9631e5acaa570804e1772caae55f5cfc7a918.tar.bz2 yosys-9be9631e5acaa570804e1772caae55f5cfc7a918.zip |
Add macc test, with equiv_opt not currently passing
Diffstat (limited to 'tests/xilinx/macc.v')
-rw-r--r-- | tests/xilinx/macc.v | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/xilinx/macc.v b/tests/xilinx/macc.v new file mode 100644 index 000000000..bae63b5a4 --- /dev/null +++ b/tests/xilinx/macc.v @@ -0,0 +1,37 @@ +// Signed 40-bit streaming accumulator with 16-bit inputs +// File: HDL_Coding_Techniques/multipliers/multipliers4.v +// +module macc # (parameter SIZEIN = /*16*/7, SIZEOUT = 40) + (input clk, ce, sload, + input signed [SIZEIN-1:0] a, b, + output signed [SIZEOUT-1:0] accum_out); + // Declare registers for intermediate values + reg signed [SIZEIN-1:0] a_reg, b_reg; + reg sload_reg; + reg signed [2*SIZEIN:0] mult_reg; + reg signed [SIZEOUT-1:0] adder_out, old_result; + always @(adder_out or sload_reg) begin + //if (sload_reg) + //old_result <= 0; + //else + // 'sload' is now active (=low) and opens the accumulation loop. + // The accumulator takes the next multiplier output in + // the same cycle. + old_result <= adder_out; + a_reg <= a; + b_reg <= b; + end + + always @(posedge clk) + //if (ce) + begin + mult_reg <= a_reg * b_reg; + sload_reg <= sload; + // Store accumulation result into a register + adder_out <= old_result + mult_reg; + end + + // Output accumulation result + assign accum_out = adder_out; + +endmodule // macc |