From c54a39069d1f536da7a830fa2fa504bc72c20c18 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Thu, 1 Aug 2019 10:00:49 -0700 Subject: [PATCH] CO is sign extension only if signed multiplier --- passes/pmgen/ice40_dsp.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/passes/pmgen/ice40_dsp.cc b/passes/pmgen/ice40_dsp.cc index 00794ca0d..f88cd62dd 100644 --- a/passes/pmgen/ice40_dsp.cc +++ b/passes/pmgen/ice40_dsp.cc @@ -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 -- 2.30.2