From a8fe0409062cb214d61d527ad2060c1f3d585026 Mon Sep 17 00:00:00 2001 From: luke whittlesey Date: Thu, 4 Jun 2015 14:56:13 -0400 Subject: [PATCH] Bug fix in $mem verilog backend + changed tests/bram flow of make test. --- backends/verilog/verilog_backend.cc | 30 +++++++++++++++-------------- tests/bram/run-single.sh | 6 ++++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/backends/verilog/verilog_backend.cc b/backends/verilog/verilog_backend.cc index 436bb2b22..c6a8792da 100644 --- a/backends/verilog/verilog_backend.cc +++ b/backends/verilog/verilog_backend.cc @@ -38,7 +38,7 @@ USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN -bool norename, noattr, attr2comment, noexpr; +bool norename, noattr, attr2comment, noexpr, nomem; int auto_name_counter, auto_name_offset, auto_name_digits; std::map auto_name_map; std::set reg_wires, reg_ct; @@ -791,14 +791,13 @@ bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell) return true; } - if (cell->type == "$mem" && false) // FIXME! + if (cell->type == "$mem" && nomem == false) { RTLIL::IdString memid = cell->parameters["\\MEMID"].decode_string(); std::string mem_id = id(cell->parameters["\\MEMID"].decode_string()); int abits = cell->parameters["\\ABITS"].as_int(); int size = cell->parameters["\\SIZE"].as_int(); int width = cell->parameters["\\WIDTH"].as_int(); - int offset = cell->parameters["\\OFFSET"].as_int(); bool use_init = !(RTLIL::SigSpec(cell->parameters["\\INIT"]).is_fully_undef()); // for memory block make something like: @@ -807,12 +806,7 @@ bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell) // memid[0] <= ... // end int mem_val; - RTLIL::Memory memory; - memory.name = memid; - memory.width = width; - memory.start_offset = offset; - memory.size = size; - dump_memory(f, indent.c_str(), &memory); + f << stringf("%s" "reg [%d:%d] %s [%d:%d];\n", indent.c_str(), width-1, 0, mem_id.c_str(), size-1, 0); if (use_init) { f << stringf("%s" "initial begin\n", indent.c_str()); @@ -844,7 +838,7 @@ bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell) // temp_id <= array_reg[r_addr]; // assign r_data = temp_id; std::string temp_id = next_auto_id(); - f << stringf("%s" "reg [%d:0] %s;\n", indent.c_str(), sig_rd_addr.size() - 1, temp_id.c_str()); + f << stringf("%s" "reg [%d:0] %s;\n", indent.c_str(), sig_rd_data.size() - 1, temp_id.c_str()); f << stringf("%s" "always @(%sedge ", indent.c_str(), rd_clk_posedge ? "pos" : "neg"); dump_sigspec(f, sig_rd_clk); f << stringf(")\n"); @@ -886,7 +880,7 @@ bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell) int nwrite_ports = cell->parameters["\\WR_PORTS"].as_int(); RTLIL::SigSpec sig_wr_clk, sig_wr_data, sig_wr_addr, sig_wr_en, sig_wr_en_bit; - RTLIL::SigBit last_bit, current_bit; + RTLIL::SigBit last_bit; bool wr_clk_posedge; RTLIL::SigSpec lof_wen; dict wen_to_width; @@ -910,9 +904,8 @@ bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell) lof_wen = RTLIL::SigSpec(last_bit); wen_to_width.clear(); wen_to_width[last_bit] = 0; - for (int j=0; j args, RTLIL::Design *design) { @@ -1301,6 +1298,7 @@ struct VerilogBackend : public Backend { noattr = false; attr2comment = false; noexpr = false; + nomem = false; bool blackboxes = false; bool selected = false; @@ -1358,6 +1356,10 @@ struct VerilogBackend : public Backend { selected = true; continue; } + if (arg == "-nomem") { + nomem = true; + continue; + } break; } extra_args(f, filename, args, argidx); diff --git a/tests/bram/run-single.sh b/tests/bram/run-single.sh index 19a235c7a..a1d1ec908 100644 --- a/tests/bram/run-single.sh +++ b/tests/bram/run-single.sh @@ -1,7 +1,9 @@ #!/bin/bash set -e -../../yosys -qq -p "proc; opt; memory -nomap -bram temp/brams_${2}.txt; opt -fast -full" \ - -l temp/synth_${1}_${2}.log -o temp/synth_${1}_${2}.v temp/brams_${1}.v +../../yosys -qq -p "proc; opt; memory -nomap -bram temp/brams_${2}.txt; opt -fast -full; write_verilog temp/synth_${1}_${2}_stage0.v" \ + -l temp/synth_${1}_${2}_stage0.log temp/brams_${1}.v +../../yosys -qq -p "proc; opt; memory -nomap; opt -fast -full; write_verilog -nomem temp/synth_${1}_${2}.v" \ + -l temp/synth_${1}_${2}.log temp/synth_${1}_${2}_stage0.v iverilog -Dvcd_file=\"temp/tb_${1}_${2}.vcd\" -DSIMLIB_MEMDELAY=1ns -o temp/tb_${1}_${2}.tb temp/brams_${1}_tb.v \ temp/brams_${1}_ref.v temp/synth_${1}_${2}.v temp/brams_${2}.v ../../techlibs/common/simlib.v temp/tb_${1}_${2}.tb > temp/tb_${1}_${2}.txt -- 2.30.2