Add comment to clarify that ignoring the MSB in the MAC is safe.

It is not obvious that the MSB in the MAC of the multiplier can safely
be ignored, and it is tedious to derive this from solely studying the
architecture of the multiplier. This comment makes clear that it is
indeed safe and also gives some reasoning.
This commit is contained in:
Pirmin Vogel 2019-05-15 14:56:03 +01:00 committed by Philipp Wagner
parent 29107c5283
commit 5962df278e

View file

@ -118,6 +118,10 @@ module ibex_multdiv_fast (
assign multdiv_result_o = div_en_i ? mac_res_q[31:0] : mac_res_n[31:0];
// The 2 MSBs of mac_res_ext (mac_res_ext[34:33]) are always equal since:
// 1. The 2 MSBs of the multiplicants are always equal, and
// 2. The 16 MSBs of the addend (accum[33:18]) are always equal.
// Thus, it is safe to ignore mac_res_ext[34].
assign mac_res_signed = $signed({sign_a, mult_op_a})*$signed({sign_b, mult_op_b}) + $signed(accum);
assign mac_res_ext = $unsigned(mac_res_signed);
assign mac_res = mac_res_ext[33:0];