aboutsummaryrefslogtreecommitdiffstats
path: root/backends/cxxrtl
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2020-04-05 07:46:42 +0000
committerwhitequark <whitequark@whitequark.org>2020-04-09 04:08:36 +0000
commit9534b512770063baa48d862a375ec7a924766866 (patch)
treea88db4f297a3cd1dea18453475fa47312cddf77c /backends/cxxrtl
parent01e6850bd3b9c884a0ea9785ff5ff1ffd59b82e2 (diff)
downloadyosys-9534b512770063baa48d862a375ec7a924766866.tar.gz
yosys-9534b512770063baa48d862a375ec7a924766866.tar.bz2
yosys-9534b512770063baa48d862a375ec7a924766866.zip
write_cxxrtl: add support for $slice and $concat cells.
Diffstat (limited to 'backends/cxxrtl')
-rw-r--r--backends/cxxrtl/cxxrtl.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/backends/cxxrtl/cxxrtl.cc b/backends/cxxrtl/cxxrtl.cc
index 6fd63548f..e2c33c3d7 100644
--- a/backends/cxxrtl/cxxrtl.cc
+++ b/backends/cxxrtl/cxxrtl.cc
@@ -189,7 +189,8 @@ static bool is_binary_cell(RTLIL::IdString type)
static bool is_elidable_cell(RTLIL::IdString type)
{
- return is_unary_cell(type) || is_binary_cell(type) || type == ID($mux);
+ return is_unary_cell(type) || is_binary_cell(type) || type.in(
+ ID($mux), ID($concat), ID($slice));
}
static bool is_ff_cell(RTLIL::IdString type)
@@ -672,6 +673,20 @@ struct CxxrtlWorker {
f << " : ";
dump_sigspec_rhs(cell->getPort(ID(A)));
f << ")";
+ // Concats
+ } else if (cell->type == ID($concat)) {
+ dump_sigspec_rhs(cell->getPort(ID(B)));
+ f << ".concat(";
+ dump_sigspec_rhs(cell->getPort(ID(A)));
+ f << ").val()";
+ // Slices
+ } else if (cell->type == ID($slice)) {
+ dump_sigspec_rhs(cell->getPort(ID(A)));
+ f << ".slice<";
+ f << cell->getParam(ID(OFFSET)).as_int() + cell->getParam(ID(Y_WIDTH)).as_int() - 1;
+ f << ",";
+ f << cell->getParam(ID(OFFSET)).as_int();
+ f << ">().val()";
} else {
log_assert(false);
}