CO is sign extension only if signed multiplier

This commit is contained in:
Eddie Hung 2019-08-01 10:00:49 -07:00
parent e3c39cc450
commit c54a39069d
1 changed files with 6 additions and 1 deletions

View File

@ -147,7 +147,12 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
int O_width = GetSize(O);
if (O_width == 33) {
log_assert(st.addAB);
cell->setPort("\\CO", O[-1]);
// If we have a signed multiply-add, then perform sign extension
// TODO: Need to check CD[31:16] is sign extension of CD[15:0]?
if (st.addAB->getParam("\\A_SIGNED").as_bool() && st.addAB->getParam("\\B_SIGNED").as_bool())
pm.module->connect(O[-1], O[-2]);
else
cell->setPort("\\CO", O[-1]);
O.remove(O_width-1);
}
else