From aabb4ea1df3d5ef216b6fce95caf989333a14e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Mon, 27 Jan 2025 13:08:19 +0100 Subject: [PATCH] macc_v2: Fix checks and parameter padding --- kernel/macc.h | 17 +++++++++++++++++ kernel/rtlil.cc | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/kernel/macc.h b/kernel/macc.h index fdd738d45..5cf8d634d 100644 --- a/kernel/macc.h +++ b/kernel/macc.h @@ -228,6 +228,23 @@ struct Macc } } + if (a_signed.empty()) + a_signed = {RTLIL::Sx}; + if (b_signed.empty()) + a_signed = {RTLIL::Sx}; + if (c_signed.empty()) + c_signed = {RTLIL::Sx}; + if (a_widths.empty()) + a_widths = {RTLIL::Sx}; + if (b_widths.empty()) + b_widths = {RTLIL::Sx}; + if (c_widths.empty()) + c_widths = {RTLIL::Sx}; + if (product_negated.empty()) + product_negated = {RTLIL::Sx}; + if (addend_negated.empty()) + addend_negated = {RTLIL::Sx}; + cell->setParam(ID::NPRODUCTS, nproducts); cell->setParam(ID::PRODUCT_NEGATED, product_negated); cell->setParam(ID::NADDENDS, naddends); diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index c10e879c5..d197660bd 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -1470,7 +1470,7 @@ namespace { if (cell->type == ID($macc_v2)) { if (param(ID::NPRODUCTS) <= 0) error(__LINE__); - if (param(ID::NADDENDS) <= 0) + if (param(ID::NADDENDS) < 0) error(__LINE__); param_bits(ID::PRODUCT_NEGATED, max(param(ID::NPRODUCTS), 1)); param_bits(ID::ADDEND_NEGATED, max(param(ID::NADDENDS), 1));