File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -48,19 +48,27 @@ module PE (
4848
4949 // Compute next accumulator value (combinational)
5050 wire signed [17 :0 ] abs_aligned = aligned_prod;
51- wire signed [17 :0 ] acc_next = prod_sign ? (acc - abs_aligned) : (acc + abs_aligned);
51+ wire signed [17 :0 ] signed_prod =
52+ prod_sign ? - aligned_prod : aligned_prod;
53+
54+ // Accumulator input: on clear, load product; else add to accumulator
55+ wire signed [17 :0 ] acc_in =
56+ clear ? signed_prod : (acc + signed_prod);
5257
53- // Register accumulator
5458 always @(posedge clk) begin
5559 a_out <= a_in;
5660 b_out <= b_in;
57- acc <= (rst | clear) ? 18 'sd0 : acc_next;
61+
62+ if (rst)
63+ acc <= 18 'sd0;
64+ else
65+ acc <= acc_in;
5866 end
5967
6068 // ----------------------- INT18 → BF16 (combinational) -----------------------
6169 wire [15 :0 ] bf16_c;
6270 int18_to_bf16_lzd #(.FRAC_BITS(FRAC_BITS)) convert (
63- .acc(acc_next ),
71+ .acc(acc_in ),
6472 .bf16(bf16_c)
6573 );
6674
You can’t perform that action at this time.
0 commit comments