Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
ec796ad
WIP remove dead code
jix Oct 4, 2025
7a6c111
WIP half broken snapshot
jix Oct 6, 2025
3d5ee37
mem: fix signorm cell type morph
widlarizer Mar 6, 2026
d8520e2
check: don't fail on $input_port
widlarizer Mar 6, 2026
3faa9b4
tests: adjust to input_port and init behavior (sketchy)
widlarizer Mar 7, 2026
63355cd
rtlil_bufnorm: fix cell deletion deferral bug
widlarizer Mar 7, 2026
57ee228
bug2920: disable
widlarizer Mar 9, 2026
c5839de
rtlil: fix zero width SigSpec crash in signorm setPort unsetPort
widlarizer Mar 9, 2026
92f97bd
tests: adjust to input_port and init behavior (sketchy)
widlarizer Mar 9, 2026
b0c3f3e
ff: fixup initvals with signorm direct drive wire if it's created, no…
widlarizer Mar 9, 2026
42a75ff
wreduce: fixup initvals after setPort
widlarizer Mar 10, 2026
0673455
tests: adjust to input_port and init behavior (sketchy)
widlarizer Mar 10, 2026
66f2d67
tests: adjust to input_port and init behavior (sketchy)
widlarizer Mar 10, 2026
547a715
tests: adjust to input_port and init behavior (sketchy)
widlarizer Mar 10, 2026
4a5ff09
synth_ice40: always read abc9 model to understand port direction
widlarizer Mar 11, 2026
6defcfa
opt_merge_inc: re add initvals deletion
widlarizer Mar 11, 2026
bcf42fc
rtlil: forbid rewrite_sigspecs in signorm
widlarizer Mar 11, 2026
3c1a0d4
timinginfo: disable output wire check due to signorm
widlarizer Mar 11, 2026
d37e0ac
opt_hier: disable signorm
widlarizer Mar 11, 2026
9d98604
techmap: disable signorm
widlarizer Mar 11, 2026
1da5f4d
techmap: disable signorm more
widlarizer Mar 12, 2026
f481b5e
rtlil: add dump_sigmap for hacky signorm debugging
widlarizer Mar 12, 2026
aa52efb
satgen: support $connect
widlarizer Mar 12, 2026
0c9d373
opt_expr: fix invert_map
widlarizer Mar 13, 2026
e8dd486
signorm: disable in passes that use swap_names
widlarizer Mar 16, 2026
6f0ba00
signorm: skip const when fixing fanout
widlarizer Mar 17, 2026
e7bffe1
flatten: skip $input_port cells in template module
widlarizer Mar 17, 2026
d001b40
abstract: skip $input_port cells
widlarizer Mar 17, 2026
e8144f1
signorm: remove $input cells when leaving
widlarizer Mar 17, 2026
99f88aa
check: stitch info about $connect ports together for driver analysis
widlarizer Mar 17, 2026
66af891
aiger: ignore $input_port
widlarizer Mar 17, 2026
e75523b
signorm: disable passes that use rewrite_sigspecs
widlarizer Mar 17, 2026
b8f2dfb
abstract: fix test signorm
widlarizer Mar 17, 2026
80baffb
flatten: redo signormalization to work around fanout issue
widlarizer Mar 17, 2026
992d200
cxxrtl: ignore $input_port
widlarizer Mar 17, 2026
a65d8fb
design: fix signorm commit connectivity to design
widlarizer Mar 17, 2026
451d847
tests: fix rtlil roundtrip test
widlarizer Mar 17, 2026
b58952c
opt_dff: temporarily disable signorm due to muxtree traversal
widlarizer Mar 18, 2026
2748230
ff: add FfDataSigMapped
widlarizer Mar 24, 2026
708bc57
opt_dff: sigma harder, FfDataSigMapped
widlarizer Mar 24, 2026
e4d532b
connect: remove input ports on conflict
widlarizer Mar 24, 2026
d1c463d
opt_expr: with -keepdc disable equality optimization rules that break…
widlarizer Mar 25, 2026
8e0a0db
timinginfo: special-case $specify2 in signorm invariant
widlarizer Mar 26, 2026
e3c428b
ffmerge: initvals signorm compatibility fixup
widlarizer Mar 26, 2026
2352360
memory_bram: add -register
widlarizer Mar 31, 2026
33e5d93
memory: add -bram-register
widlarizer Mar 31, 2026
e78a1a7
tests: use memory -bram-register in tests/bram
widlarizer Mar 31, 2026
38255da
techmap: call hierarchy on map files to determine port directions
widlarizer Apr 1, 2026
0d62ac1
hierarchy: tolerance for apparent recursive instances in techmap files
widlarizer Apr 1, 2026
b4bb200
Revert "techmap: call hierarchy on map files to determine port direct…
widlarizer Apr 2, 2026
1052e89
gowin: replace positional arguments in cells_sim.v with named
widlarizer Apr 2, 2026
16877b6
rtlil_bufnorm: ignore timing info harder
widlarizer Apr 2, 2026
a000a78
intel: register bram celltypes
widlarizer Apr 2, 2026
81617af
rtlil_bufnorm: more xlog
widlarizer Apr 7, 2026
69ff2fb
rtlil: sigNormalize Module when added to Design in signorm mode
widlarizer Apr 7, 2026
441a1f4
rtlil: fix cloneInto in signorm
widlarizer Apr 8, 2026
a39ab42
equiv_make: don't copy $input_port
widlarizer Apr 8, 2026
25d127f
design: properly switch signorm mode when restoring saved designs
widlarizer Apr 9, 2026
a3beac7
rtlil_bufnorm: more xlog
widlarizer Apr 9, 2026
4e4700b
equiv_miter: don't copy $input_port
widlarizer Apr 9, 2026
e218c25
gowin: rebless LUT counts
widlarizer Apr 9, 2026
5d069fc
pmgen: hold sigmap pointer instead of owning it
widlarizer Apr 14, 2026
7c083ff
xilinx_dsp: signorm compatibility
widlarizer Apr 15, 2026
c5ed516
nexus: loosen tests
widlarizer Apr 15, 2026
df791a5
ecp5: loosen tests
widlarizer Apr 15, 2026
b995059
flatten: disable signorm
widlarizer Apr 15, 2026
ec7375d
gowin: loosen tests
widlarizer Apr 16, 2026
12e179b
intel_alm: loosen tests
widlarizer Apr 16, 2026
a2e6647
Revert "memory_bram: add -register"
widlarizer Apr 16, 2026
6bb7221
Revert "memory: add -bram-register"
widlarizer Apr 16, 2026
00437b3
Revert "tests: use memory -bram-register in tests/bram"
widlarizer Apr 16, 2026
b4b774f
Revert "intel: register bram celltypes"
widlarizer Apr 16, 2026
6d37b67
memory_bram: create blackboxes
widlarizer Apr 16, 2026
a52b8d2
check: fix memory bug in $connect
widlarizer Apr 17, 2026
54ef127
rtlil_bufnorm: fix setup_driven_wires constant handling on unknown po…
widlarizer Apr 21, 2026
23de03c
signorm: add timers
widlarizer May 6, 2026
6bff991
opt_expr: replace invert_map with signorm traversal
widlarizer May 6, 2026
54f99ad
opt_merge: factor out hashing code across incremental and parallel
widlarizer May 6, 2026
6997ed2
opt_merge: newcelltypes
widlarizer May 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backends/aiger/aiger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ struct AigerWriter
continue;
}

if (cell->type == ID($scopeinfo))
if (cell->type == ID($scopeinfo) || cell->type == ID($input_port))
continue;

log_error("Unsupported cell type: %s (%s)\n", log_id(cell->type), log_id(cell));
Expand Down
1 change: 1 addition & 0 deletions backends/cxxrtl/cxxrtl_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,7 @@ struct CxxrtlWorker {
f << (cell->getParam(ID::CLR_POLARITY).as_bool() ? "" : ".bit_not()") << ");\n";
}
// Internal cells
} else if (cell->type == ID($input_port)) {
} else if (is_internal_cell(cell->type)) {
log_cmd_error("Unsupported internal cell `%s'.\n", cell->type);
// User cells
Expand Down
3 changes: 3 additions & 0 deletions frontends/aiger/aigerparse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,9 @@ struct AigerFrontend : public Frontend {
}
extra_args(f, filename, args, argidx, true);

// TODO Disabled signorm because swap_names breaks fanout logic
design->sigNormalize(false);

if (module_name.empty()) {
#ifdef _WIN32
char fname[_MAX_FNAME];
Expand Down
4 changes: 4 additions & 0 deletions kernel/driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,10 @@ int main(int argc, char **argv)
total_ns += gc_ns;
timedat.insert(make_tuple(gc_ns,
RTLIL::OwningIdString::garbage_collection_count(), "id_gc"));
total_ns += signorm_ns;
timedat.insert(make_tuple(signorm_ns, signorm_count, "signorm"));
total_ns += signorm_restore_ns;
timedat.insert(make_tuple(signorm_restore_ns, signorm_restore_count, "signorm_restore"));
}

if (timing_details)
Expand Down
4 changes: 2 additions & 2 deletions kernel/ff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,6 @@ Cell *FfData::emit() {
return nullptr;
}
}
if (initvals && !is_anyinit)
initvals->set_init(sig_q, val_init);
if (!is_fine) {
if (has_gclk) {
log_assert(!has_clk);
Expand Down Expand Up @@ -747,6 +745,8 @@ Cell *FfData::emit() {
}
}
cell->attributes = attributes;
if (initvals && !is_anyinit)
initvals->set_init(cell->getPort(ID::Q), val_init);
return cell;
}

Expand Down
37 changes: 37 additions & 0 deletions kernel/ff.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,43 @@ struct FfData : FfTypeData {
void flip_rst_bits(const pool<int> &bits);
};

struct FfDataSigMapped : public FfData {
SigMap& sigmap;
FfDataSigMapped(SigMap& map, Module *module, FfInitVals *initvals = nullptr, IdString name = IdString()) : FfData(module, initvals, name), sigmap(map) {}

void remap() {
sigmap(sig_q);
sigmap(sig_d);
sigmap(sig_ad);
sigmap(sig_clk);
sigmap(sig_ce);
sigmap(sig_aload);
sigmap(sig_arst);
sigmap(sig_srst);
sigmap(sig_clr);
sigmap(sig_set);
}
FfDataSigMapped(SigMap& map, FfInitVals *initvals, Cell *cell_) : FfData(initvals, cell_), sigmap(map) {
remap();
}
FfDataSigMapped(SigMap& map, const FfData& base) : FfData(base), sigmap(map) {
remap();
}
FfDataSigMapped(const FfDataSigMapped& other) : FfData(other), sigmap(other.sigmap) {}
FfDataSigMapped& operator=(const FfDataSigMapped& other) {
FfData::operator=(other);
return *this;
}
Cell* emit() {
Cell* cell = FfData::emit();
remap();
return cell;
}
FfDataSigMapped slice(const std::vector<int> &bits) {
return FfDataSigMapped(sigmap, FfData::slice(bits));
}
};

YOSYS_NAMESPACE_END

#endif
1 change: 1 addition & 0 deletions kernel/ffmerge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ void FfMergeHelper::remove_output_ff(const pool<std::pair<Cell *, int>> &bits) {
dff_driver.erase((*sigmap)(q[idx]));
q[idx] = module->addWire(stringf("$ffmerge_disconnected$%d", autoidx++));
cell->setPort(ID::Q, q);
initvals->set_init(cell->getPort(ID::Q), (*initvals)(q));
}
}

Expand Down
7 changes: 4 additions & 3 deletions kernel/mem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,11 @@ void Mem::emit() {
bool v2 = !init.en.is_fully_ones();
if (!init.cell)
init.cell = module->addCell(NEW_ID, v2 ? ID($meminit_v2) : ID($meminit));
else
else {
if (!v2)
init.cell->unsetPort(ID::EN);
init.cell->type = v2 ? ID($meminit_v2) : ID($meminit);
}
init.cell->attributes = init.attributes;
init.cell->parameters[ID::MEMID] = memid.str();
init.cell->parameters[ID::ABITS] = GetSize(init.addr);
Expand All @@ -361,8 +364,6 @@ void Mem::emit() {
init.cell->setPort(ID::DATA, init.data);
if (v2)
init.cell->setPort(ID::EN, init.en);
else
init.cell->unsetPort(ID::EN);
}
}
}
Expand Down
59 changes: 2 additions & 57 deletions kernel/rtlil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1215,22 +1215,6 @@ RTLIL::Module *RTLIL::Design::top_module() const
return module_count == 1 ? module : nullptr;
}

void RTLIL::Design::add(RTLIL::Module *module)
{
log_assert(modules_.count(module->name) == 0);
log_assert(refcount_modules_ == 0);
modules_[module->name] = module;
module->design = this;

for (auto mon : monitors)
mon->notify_module_add(module);

if (yosys_xtrace) {
log("#X# New Module: %s\n", log_id(module));
log_backtrace("-X- ", yosys_xtrace-1);
}
}

void RTLIL::Design::add(RTLIL::Binding *binding)
{
log_assert(binding != nullptr);
Expand Down Expand Up @@ -1528,6 +1512,7 @@ RTLIL::Module::Module()

RTLIL::Module::~Module()
{
clear_sig_norm_index();
for (auto &pr : wires_)
delete pr.second;
for (auto &pr : memories)
Expand Down Expand Up @@ -2740,7 +2725,7 @@ void RTLIL::Module::cloneInto(RTLIL::Module *new_mod) const
new_mod->avail_parameters = avail_parameters;
new_mod->parameter_default_values = parameter_default_values;

for (auto &conn : connections_)
for (auto &conn : connections())
new_mod->connect(conn);

for (auto &attr : attributes)
Expand Down Expand Up @@ -2948,23 +2933,6 @@ void RTLIL::Module::remove(const pool<RTLIL::Wire*> &wires)
}
}

void RTLIL::Module::remove(RTLIL::Cell *cell)
{
while (!cell->connections_.empty())
cell->unsetPort(cell->connections_.begin()->first);

log_assert(cells_.count(cell->name) != 0);
log_assert(refcount_cells_ == 0);
cells_.erase(cell->name);
if (design && design->flagBufferedNormalized && buf_norm_cell_queue.count(cell)) {
cell->type.clear();
cell->name.clear();
pending_deleted_cells.insert(cell);
} else {
delete cell;
}
}

void RTLIL::Module::remove(RTLIL::Memory *memory)
{
log_assert(memories.count(memory->name) != 0);
Expand Down Expand Up @@ -3108,29 +3076,6 @@ void RTLIL::Module::connect(const RTLIL::SigSpec &lhs, const RTLIL::SigSpec &rhs
connect(RTLIL::SigSig(lhs, rhs));
}

void RTLIL::Module::new_connections(const std::vector<RTLIL::SigSig> &new_conn)
{
for (auto mon : monitors)
mon->notify_connect(this, new_conn);

if (design)
for (auto mon : design->monitors)
mon->notify_connect(this, new_conn);

if (yosys_xtrace) {
log("#X# New connections vector in %s:\n", log_id(this));
for (auto &conn: new_conn)
log("#X# %s = %s (%d bits)\n", log_signal(conn.first), log_signal(conn.second), GetSize(conn.first));
log_backtrace("-X- ", yosys_xtrace-1);
}

connections_ = new_conn;
}

const std::vector<RTLIL::SigSig> &RTLIL::Module::connections() const
{
return connections_;
}

void RTLIL::Module::fixup_ports()
{
Expand Down
58 changes: 58 additions & 0 deletions kernel/rtlil.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,19 @@ namespace RTLIL
struct Binding;
struct IdString;
struct OwningIdString;
struct StaticIdString;
struct SigNormIndex;

typedef std::pair<SigSpec, SigSpec> SigSig;
struct PortBit;
};

// TODO clean up?
extern int64_t signorm_ns;
extern int signorm_count;
extern int64_t signorm_restore_ns;
extern int signorm_restore_count;

struct RTLIL::IdString
{
struct Storage {
Expand Down Expand Up @@ -1892,7 +1901,9 @@ struct RTLIL::Design
dict<std::string, std::string> scratchpad;

bool flagBufferedNormalized = false;
bool flagSigNormalized = false;
void bufNormalize(bool enable=true);
void sigNormalize(bool enable=true);

int refcount_modules_;
dict<RTLIL::IdString, RTLIL::Module*> modules_;
Expand Down Expand Up @@ -2053,6 +2064,10 @@ struct RTLIL::Design

struct RTLIL::Module : public RTLIL::NamedObject
{
friend struct RTLIL::SigNormIndex;
friend struct RTLIL::Cell;
friend struct RTLIL::Design;

Hasher::hash_t hashidx_;
[[nodiscard]] Hasher hash_into(Hasher h) const { h.eat(hashidx_); return h; }

Expand Down Expand Up @@ -2110,6 +2125,19 @@ struct RTLIL::Module : public RTLIL::NamedObject
pool<RTLIL::Cell *> pending_deleted_cells;
dict<RTLIL::Wire *, pool<RTLIL::Cell *>> buf_norm_connect_index;
void bufNormalize();
void dump_sigmap();

protected:
SigNormIndex *sig_norm_index = nullptr;
void clear_sig_norm_index();
int timestamp_ = 0;
public:
void sigNormalize();

int timestamp() const { return timestamp_; }
int next_timestamp();
std::vector<Cell *> dirty_cells(int starting_from);
const pool<PortBit> &fanout(SigBit bit);

template<typename T> void rewrite_sigspecs(T &functor);
template<typename T> void rewrite_sigspecs2(T &functor);
Expand Down Expand Up @@ -2430,6 +2458,7 @@ struct RTLIL::Wire : public RTLIL::NamedObject
protected:
// use module->addWire() and module->remove() to create or destroy wires
friend struct RTLIL::Module;
friend struct RTLIL::SigNormIndex;
Wire();
~Wire();

Expand Down Expand Up @@ -2627,6 +2656,33 @@ struct RTLIL::Process : public RTLIL::NamedObject
std::string to_rtlil_str() const;
};

struct RTLIL::PortBit
{
RTLIL::Cell *cell;
RTLIL::IdString port;
int offset;
PortBit(Cell* c, IdString p, int o) : cell(c), port(p), offset(o) {}

bool operator<(const PortBit &other) const {
if (cell != other.cell)
return cell < other.cell;
if (port != other.port)
return port < other.port;
return offset < other.offset;
}

bool operator==(const PortBit &other) const {
return cell == other.cell && port == other.port && offset == other.offset;
}

[[nodiscard]] Hasher hash_into(Hasher h) const {
h.eat(cell->name);
h.eat(port);
h.eat(offset);
return h;
}
};


inline RTLIL::SigBit::SigBit() : wire(NULL), data(RTLIL::State::S0) { }
inline RTLIL::SigBit::SigBit(RTLIL::State bit) : wire(NULL), data(bit) { }
Expand Down Expand Up @@ -2691,6 +2747,7 @@ inline RTLIL::SigBit::SigBit(const RTLIL::SigSpec &sig) {
template<typename T>
void RTLIL::Module::rewrite_sigspecs(T &functor)
{
log_assert(sig_norm_index == nullptr);
for (auto &it : cells_)
it.second->rewrite_sigspecs(functor);
for (auto &it : processes)
Expand All @@ -2704,6 +2761,7 @@ void RTLIL::Module::rewrite_sigspecs(T &functor)
template<typename T>
void RTLIL::Module::rewrite_sigspecs2(T &functor)
{
log_assert(sig_norm_index == nullptr);
for (auto &it : cells_)
it.second->rewrite_sigspecs2(functor);
for (auto &it : processes)
Expand Down
Loading
Loading