Skip to content

Commit 61c47fd

Browse files
authored
Merge pull request #187 from Silimate/cxxrtl-sim
expose write_cxxrtl into frontend and add support for $buf and $icg
2 parents aa3ebe4 + 30be712 commit 61c47fd

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ include $(YOSYS_SRC)/backends/verilog/Makefile.inc
917917
include $(YOSYS_SRC)/backends/rtlil/Makefile.inc
918918
include $(YOSYS_SRC)/backends/json/Makefile.inc
919919
include $(YOSYS_SRC)/backends/blif/Makefile.inc
920+
include $(YOSYS_SRC)/backends/cxxrtl/Makefile.inc
920921

921922
include $(YOSYS_SRC)/techlibs/common/Makefile.inc
922923

backends/cxxrtl/cxxrtl_backend.cc

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ bool is_extending_cell(RTLIL::IdString type)
200200
bool is_inlinable_cell(RTLIL::IdString type)
201201
{
202202
return is_unary_cell(type) || is_binary_cell(type) || type.in(
203-
ID($mux), ID($concat), ID($slice), ID($pmux), ID($bmux), ID($demux), ID($bwmux));
203+
ID($mux), ID($concat), ID($slice), ID($pmux), ID($bmux), ID($demux), ID($bwmux), ID($buf));
204204
}
205205

206206
bool is_ff_cell(RTLIL::IdString type)
@@ -1133,8 +1133,11 @@ struct CxxrtlWorker {
11331133

11341134
void dump_cell_expr(const RTLIL::Cell *cell, bool for_debug = false)
11351135
{
1136+
// Buffers
1137+
if (cell->type == ID($buf)) {
1138+
dump_sigspec_rhs(cell->getPort(ID::A), for_debug);
11361139
// Unary cells
1137-
if (is_unary_cell(cell->type)) {
1140+
} else if (is_unary_cell(cell->type)) {
11381141
f << cell->type.substr(1);
11391142
if (is_extending_cell(cell->type))
11401143
f << '_' << (cell->getParam(ID::A_SIGNED).as_bool() ? 's' : 'u');
@@ -1517,6 +1520,20 @@ struct CxxrtlWorker {
15171520
dump_sigspec_rhs(cell->getPort(ID::CLR));
15181521
f << (cell->getParam(ID::CLR_POLARITY).as_bool() ? "" : ".bit_not()") << ");\n";
15191522
}
1523+
// ICG cells GCLK = CLK & (EN | SE)
1524+
} else if (cell->type == ID($icg)) {
1525+
f << indent;
1526+
dump_sigspec_lhs(cell->getPort(ID::GCLK), for_debug);
1527+
f << " = ";
1528+
dump_sigspec_rhs(cell->getPort(ID::CLK), for_debug);
1529+
f << ".bit_and(";
1530+
dump_sigspec_rhs(cell->getPort(ID::EN), for_debug);
1531+
if (cell->hasPort(ID::SE)) {
1532+
f << ".bit_or(";
1533+
dump_sigspec_rhs(cell->getPort(ID::SE), for_debug);
1534+
f << ")";
1535+
}
1536+
f << ");\n";
15201537
// Internal cells
15211538
} else if (is_internal_cell(cell->type)) {
15221539
log_cmd_error("Unsupported internal cell `%s'.\n", cell->type);

0 commit comments

Comments
 (0)