Skip to content

Commit

Permalink
macc_v2: Fix checks and parameter padding
Browse files Browse the repository at this point in the history
  • Loading branch information
povik committed Jan 27, 2025
1 parent 3184b33 commit aabb4ea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions kernel/macc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion kernel/rtlil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit aabb4ea

Please sign in to comment.