diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-01-03 00:22:17 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-01-03 00:22:17 +0100 |
commit | fb2bf934dc6d2c969906b350c9a1b09a972bfdd7 (patch) | |
tree | ea47a664de2af51f09fe43f3040685438f5dd2ec /passes | |
parent | 536e20bde159db3ad8c77aeb9001a8dddde884a8 (diff) | |
download | yosys-fb2bf934dc6d2c969906b350c9a1b09a972bfdd7.tar.gz yosys-fb2bf934dc6d2c969906b350c9a1b09a972bfdd7.tar.bz2 yosys-fb2bf934dc6d2c969906b350c9a1b09a972bfdd7.zip |
Added correct handling of $memwr priority
Diffstat (limited to 'passes')
-rw-r--r-- | passes/memory/memory_collect.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/passes/memory/memory_collect.cc b/passes/memory/memory_collect.cc index ca1a3666f..ad4df228e 100644 --- a/passes/memory/memory_collect.cc +++ b/passes/memory/memory_collect.cc @@ -20,9 +20,19 @@ #include "kernel/register.h" #include "kernel/log.h" #include <sstream> +#include <algorithm> #include <stdlib.h> #include <assert.h> +static bool memcells_cmp(RTLIL::Cell *a, RTLIL::Cell *b) +{ + if (a->type == "$memrd" && b->type == "$memrd") + return a->name < b->name; + if (a->type == "$memrd" || b->type == "$memrd") + return (a->type == "$memrd") < (b->type == "$memrd"); + return a->parameters.at("\\PRIORITY").as_int() < b->parameters.at("\\PRIORITY").as_int(); +} + static void handle_memory(RTLIL::Module *module, RTLIL::Memory *memory) { log("Collecting $memrd and $memwr for memory `%s' in module `%s':\n", @@ -48,11 +58,18 @@ static void handle_memory(RTLIL::Module *module, RTLIL::Memory *memory) RTLIL::SigSpec sig_rd_data; std::vector<std::string> del_cell_ids; + std::vector<RTLIL::Cell*> memcells; - for (auto &cell_it : module->cells) - { + for (auto &cell_it : module->cells) { RTLIL::Cell *cell = cell_it.second; + if ((cell->type == "$memwr" || cell->type == "$memrd") && cell->parameters["\\MEMID"].decode_string() == memory->name) + memcells.push_back(cell); + } + + std::sort(memcells.begin(), memcells.end(), memcells_cmp); + for (auto cell : memcells) + { if (cell->type == "$memwr" && cell->parameters["\\MEMID"].decode_string() == memory->name) { wr_ports++; |