mirror of
https://github.com/YosysHQ/yosys
synced 2026-06-01 22:57:54 +00:00
memory_bram: add -register
This commit is contained in:
parent
1ff7d5acc6
commit
b4b5093a14
1 changed files with 49 additions and 0 deletions
|
|
@ -20,6 +20,7 @@
|
||||||
#include "kernel/yosys.h"
|
#include "kernel/yosys.h"
|
||||||
#include "kernel/mem.h"
|
#include "kernel/mem.h"
|
||||||
#include "kernel/ffinit.h"
|
#include "kernel/ffinit.h"
|
||||||
|
#include "kernel/celltypes.h"
|
||||||
|
|
||||||
USING_YOSYS_NAMESPACE
|
USING_YOSYS_NAMESPACE
|
||||||
PRIVATE_NAMESPACE_BEGIN
|
PRIVATE_NAMESPACE_BEGIN
|
||||||
|
|
@ -396,8 +397,49 @@ struct rules_t
|
||||||
|
|
||||||
infile.close();
|
infile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void register_celltypes() const
|
||||||
|
{
|
||||||
|
for (auto& [_, variants] : brams)
|
||||||
|
{
|
||||||
|
for (const bram_t& bram : variants)
|
||||||
|
{
|
||||||
|
auto portinfos = bram.make_portinfos();
|
||||||
|
int clocks_max = 0;
|
||||||
|
for (auto &pi : portinfos)
|
||||||
|
clocks_max = max(clocks_max, pi.clocks);
|
||||||
|
|
||||||
|
pool<IdString> inputs;
|
||||||
|
pool<IdString> outputs;
|
||||||
|
for (auto &pi : portinfos)
|
||||||
|
{
|
||||||
|
string prefix = stringf("%c%d", pi.group + 'A', pi.index + 1);
|
||||||
|
const char *pf = prefix.c_str();
|
||||||
|
if (pi.clocks)
|
||||||
|
inputs.insert(stringf("\\CLK%d", (pi.clocks-1) % clocks_max + 1));
|
||||||
|
inputs.insert(stringf("\\%sADDR", pf));
|
||||||
|
if (pi.wrmode) {
|
||||||
|
inputs.insert(stringf("\\%sDATA", pf));
|
||||||
|
} else {
|
||||||
|
outputs.insert(stringf("\\%sDATA", pf));
|
||||||
|
}
|
||||||
|
if (pi.enable)
|
||||||
|
inputs.insert(stringf("\\%sEN", pf));
|
||||||
|
}
|
||||||
|
|
||||||
|
log_debug("setting up %s\n", bram.name);
|
||||||
|
for (auto input : inputs)
|
||||||
|
log_debug("input %s\n", input);
|
||||||
|
for (auto output : outputs)
|
||||||
|
log_debug("output %s\n", output);
|
||||||
|
yosys_celltypes.setup_type(bram.name, inputs, outputs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Maxima {};
|
||||||
|
|
||||||
bool replace_memory(Mem &mem, const rules_t &rules, FfInitVals *initvals, const rules_t::bram_t &bram, const rules_t::match_t &match, dict<string, int> &match_properties, int mode)
|
bool replace_memory(Mem &mem, const rules_t &rules, FfInitVals *initvals, const rules_t::bram_t &bram, const rules_t::match_t &match, dict<string, int> &match_properties, int mode)
|
||||||
{
|
{
|
||||||
Module *module = mem.module;
|
Module *module = mem.module;
|
||||||
|
|
@ -1311,15 +1353,22 @@ struct MemoryBramPass : public Pass {
|
||||||
log_header(design, "Executing MEMORY_BRAM pass (mapping $mem cells to block memories).\n");
|
log_header(design, "Executing MEMORY_BRAM pass (mapping $mem cells to block memories).\n");
|
||||||
|
|
||||||
size_t argidx;
|
size_t argidx;
|
||||||
|
bool register_mode = false;
|
||||||
for (argidx = 1; argidx < args.size(); argidx++) {
|
for (argidx = 1; argidx < args.size(); argidx++) {
|
||||||
if (args[argidx] == "-rules" && argidx+1 < args.size()) {
|
if (args[argidx] == "-rules" && argidx+1 < args.size()) {
|
||||||
rules.parse(args[++argidx]);
|
rules.parse(args[++argidx]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (args[argidx++] == "-register") {
|
||||||
|
register_mode = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
extra_args(args, argidx, design);
|
extra_args(args, argidx, design);
|
||||||
|
|
||||||
|
if (register_mode)
|
||||||
|
rules.register_celltypes();
|
||||||
|
|
||||||
for (auto mod : design->selected_modules()) {
|
for (auto mod : design->selected_modules()) {
|
||||||
SigMap sigmap(mod);
|
SigMap sigmap(mod);
|
||||||
FfInitVals initvals(&sigmap, mod);
|
FfInitVals initvals(&sigmap, mod);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue