mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-06 06:03:23 +00:00
rtlil: Make Process handling more uniform with Cell and Wire.
- add a backlink to module from Process - make constructor and destructor protected, expose Module functions to add and remove processes
This commit is contained in:
parent
726fabd65e
commit
009940f56c
8 changed files with 62 additions and 25 deletions
|
@ -1839,6 +1839,14 @@ void RTLIL::Module::add(RTLIL::Cell *cell)
|
|||
cell->module = this;
|
||||
}
|
||||
|
||||
void RTLIL::Module::add(RTLIL::Process *process)
|
||||
{
|
||||
log_assert(!process->name.empty());
|
||||
log_assert(count_id(process->name) == 0);
|
||||
processes[process->name] = process;
|
||||
process->module = this;
|
||||
}
|
||||
|
||||
void RTLIL::Module::remove(const pool<RTLIL::Wire*> &wires)
|
||||
{
|
||||
log_assert(refcount_wires_ == 0);
|
||||
|
@ -1895,6 +1903,13 @@ void RTLIL::Module::remove(RTLIL::Cell *cell)
|
|||
delete cell;
|
||||
}
|
||||
|
||||
void RTLIL::Module::remove(RTLIL::Process *process)
|
||||
{
|
||||
log_assert(processes.count(process->name) != 0);
|
||||
processes.erase(process->name);
|
||||
delete process;
|
||||
}
|
||||
|
||||
void RTLIL::Module::rename(RTLIL::Wire *wire, RTLIL::IdString new_name)
|
||||
{
|
||||
log_assert(wires_[wire->name] == wire);
|
||||
|
@ -2120,11 +2135,19 @@ RTLIL::Memory *RTLIL::Module::addMemory(RTLIL::IdString name, const RTLIL::Memor
|
|||
return mem;
|
||||
}
|
||||
|
||||
RTLIL::Process *RTLIL::Module::addProcess(RTLIL::IdString name)
|
||||
{
|
||||
RTLIL::Process *proc = new RTLIL::Process;
|
||||
proc->name = name;
|
||||
add(proc);
|
||||
return proc;
|
||||
}
|
||||
|
||||
RTLIL::Process *RTLIL::Module::addProcess(RTLIL::IdString name, const RTLIL::Process *other)
|
||||
{
|
||||
RTLIL::Process *proc = other->clone();
|
||||
proc->name = name;
|
||||
processes[name] = proc;
|
||||
add(proc);
|
||||
return proc;
|
||||
}
|
||||
|
||||
|
@ -2920,6 +2943,13 @@ RTLIL::Memory::Memory()
|
|||
#endif
|
||||
}
|
||||
|
||||
RTLIL::Process::Process() : module(nullptr)
|
||||
{
|
||||
static unsigned int hashidx_count = 123456789;
|
||||
hashidx_count = mkhash_xorshift(hashidx_count);
|
||||
hashidx_ = hashidx_count;
|
||||
}
|
||||
|
||||
RTLIL::Cell::Cell() : module(nullptr)
|
||||
{
|
||||
static unsigned int hashidx_count = 123456789;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue