mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-08 07:03:24 +00:00
cxxrtl: Add internal cell "bwmux"
Mirrors the implementation for the smt2 backend Co-authored-by: Martin Povišer <povik@cutebit.org>
This commit is contained in:
parent
c894685f26
commit
04098933c7
2 changed files with 14 additions and 1 deletions
|
@ -200,7 +200,7 @@ bool is_extending_cell(RTLIL::IdString type)
|
||||||
bool is_inlinable_cell(RTLIL::IdString type)
|
bool is_inlinable_cell(RTLIL::IdString type)
|
||||||
{
|
{
|
||||||
return is_unary_cell(type) || is_binary_cell(type) || type.in(
|
return is_unary_cell(type) || is_binary_cell(type) || type.in(
|
||||||
ID($mux), ID($concat), ID($slice), ID($pmux), ID($bmux), ID($demux));
|
ID($mux), ID($concat), ID($slice), ID($pmux), ID($bmux), ID($demux), ID($bwmux));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_ff_cell(RTLIL::IdString type)
|
bool is_ff_cell(RTLIL::IdString type)
|
||||||
|
@ -1198,6 +1198,14 @@ struct CxxrtlWorker {
|
||||||
f << ">(";
|
f << ">(";
|
||||||
dump_sigspec_rhs(cell->getPort(ID::S), for_debug);
|
dump_sigspec_rhs(cell->getPort(ID::S), for_debug);
|
||||||
f << ").val()";
|
f << ").val()";
|
||||||
|
// Bitwise muxes
|
||||||
|
} else if (cell->type == ID($bwmux)) {
|
||||||
|
dump_sigspec_rhs(cell->getPort(ID::A), for_debug);
|
||||||
|
f << ".bwmux(";
|
||||||
|
dump_sigspec_rhs(cell->getPort(ID::B), for_debug);
|
||||||
|
f << ",";
|
||||||
|
dump_sigspec_rhs(cell->getPort(ID::S), for_debug);
|
||||||
|
f << ").val()";
|
||||||
// Demuxes
|
// Demuxes
|
||||||
} else if (cell->type == ID($demux)) {
|
} else if (cell->type == ID($demux)) {
|
||||||
dump_sigspec_rhs(cell->getPort(ID::A), for_debug);
|
dump_sigspec_rhs(cell->getPort(ID::A), for_debug);
|
||||||
|
|
|
@ -498,6 +498,11 @@ struct value : public expr_base<value<Bits>> {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CXXRTL_ALWAYS_INLINE
|
||||||
|
value<Bits> bwmux(const value<Bits> &b, const value<Bits> &s) const {
|
||||||
|
return (bit_and(s.bit_not())).bit_or(b.bit_and(s));
|
||||||
|
}
|
||||||
|
|
||||||
template<size_t ResultBits, size_t SelBits>
|
template<size_t ResultBits, size_t SelBits>
|
||||||
value<ResultBits> demux(const value<SelBits> &sel) const {
|
value<ResultBits> demux(const value<SelBits> &sel) const {
|
||||||
static_assert(Bits << SelBits == ResultBits, "invalid sizes used in demux()");
|
static_assert(Bits << SelBits == ResultBits, "invalid sizes used in demux()");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue