mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-17 04:35:44 +00:00
rtlil: add Module* back-pointer to RTLIL::Memory
This commit is contained in:
parent
9ed93e210b
commit
e70eed3296
7 changed files with 17 additions and 3 deletions
|
|
@ -294,6 +294,7 @@ void Mem::emit() {
|
|||
memid = NEW_ID;
|
||||
mem = new RTLIL::Memory;
|
||||
mem->name = memid;
|
||||
mem->module = module;
|
||||
module->memories[memid] = mem;
|
||||
}
|
||||
mem->width = width;
|
||||
|
|
|
|||
|
|
@ -3611,6 +3611,7 @@ RTLIL::Memory *RTLIL::Module::addMemory(RTLIL::IdString name)
|
|||
{
|
||||
RTLIL::Memory *mem = new RTLIL::Memory;
|
||||
mem->name = std::move(name);
|
||||
mem->module = this;
|
||||
memories[mem->name] = mem;
|
||||
return mem;
|
||||
}
|
||||
|
|
@ -3619,14 +3620,15 @@ RTLIL::Memory *RTLIL::Module::addMemory(RTLIL::IdString name, const RTLIL::Memor
|
|||
{
|
||||
RTLIL::Memory *mem = new RTLIL::Memory;
|
||||
mem->name = std::move(name);
|
||||
mem->module = this;
|
||||
mem->width = other->width;
|
||||
mem->start_offset = other->start_offset;
|
||||
mem->size = other->size;
|
||||
mem->attributes = other->attributes;
|
||||
{
|
||||
// Memory has no module backpointer of its own — we can't know its
|
||||
// source pool from `other` alone. Drop src in the rare clone-of-
|
||||
// memory path; addMemory(name) is the common one and starts fresh.
|
||||
// Clone path drops src for now — caller responsible for migrating
|
||||
// src across the design boundary if needed. addMemory(name) is the
|
||||
// common case.
|
||||
(void)other;
|
||||
}
|
||||
memories[mem->name] = mem;
|
||||
|
|
|
|||
|
|
@ -2286,6 +2286,13 @@ struct RTLIL::Memory : public RTLIL::NamedObject
|
|||
|
||||
Memory();
|
||||
|
||||
// Back-pointer to the owning module — same role as Cell::module /
|
||||
// Wire::module. Set by Module::addMemory / the frontends that
|
||||
// construct Memory free-standing before attaching to a module.
|
||||
// Lets Memory's src access (and the upcoming per-Design meta vector
|
||||
// lookup) resolve uniformly via module->design.
|
||||
RTLIL::Module *module = nullptr;
|
||||
|
||||
int width, start_offset, size;
|
||||
#ifdef YOSYS_ENABLE_PYTHON
|
||||
~Memory();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue