Skip to content

Commit

Permalink
cxxrtl: include iostream when prints are used
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk authored and mwkmwkmwk committed Aug 17, 2023
1 parent cbd3ff2 commit 4a475fa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions backends/cxxrtl/cxxrtl_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,7 @@ struct CxxrtlWorker {
RTLIL::Module *top_module = nullptr;
std::vector<RTLIL::Module*> modules;
TopoSort<RTLIL::Module*> topo_design;
bool has_prints = false;
for (auto module : design->modules()) {
if (!design->selected_module(module))
continue;
Expand All @@ -2486,6 +2487,8 @@ struct CxxrtlWorker {

topo_design.node(module);
for (auto cell : module->cells()) {
if (cell->type == ID($print))
has_prints = true;
if (is_internal_cell(cell->type) || is_cxxrtl_blackbox_cell(cell))
continue;
RTLIL::Module *cell_module = design->module(cell->type);
Expand Down Expand Up @@ -2544,6 +2547,8 @@ struct CxxrtlWorker {
f << "#include \"" << intf_filename << "\"\n";
else
f << "#include <backends/cxxrtl/cxxrtl.h>\n";
if (has_prints)
f << "#include <iostream>\n";
f << "\n";
f << "#if defined(CXXRTL_INCLUDE_CAPI_IMPL) || \\\n";
f << " defined(CXXRTL_INCLUDE_VCD_CAPI_IMPL)\n";
Expand Down
1 change: 0 additions & 1 deletion tests/fmt/always_comb_tb.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <iostream>
#include "yosys-always_comb.cc"

int main()
Expand Down
1 change: 0 additions & 1 deletion tests/fmt/always_full_tb.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <iostream>
#include "yosys-always_full.cc"

int main()
Expand Down
5 changes: 2 additions & 3 deletions tests/fmt/display_lm_tb.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include <iostream>
#include "yosys-display_lm.cc"

int main()
{
cxxrtl_design::p_top uut;

uut.step();
return 0;
uut.step();
return 0;
}

0 comments on commit 4a475fa

Please sign in to comment.