3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-23 07:32:32 +00:00

twine: fix replayability, reduce TwineSearch usage

This commit is contained in:
Emil J. Tywoniak 2026-06-22 17:53:19 +02:00
parent e9eb3889b7
commit 7c73fd62e4
41 changed files with 273 additions and 272 deletions

View file

@ -79,6 +79,7 @@ struct BtorWorker
dict<SigBit, bool> initbits;
pool<Wire*> statewires;
pool<string> srcsymbols;
TwineSearch src_search;
vector<Mem> memories;
dict<Cell*, Mem*> mem_cells;
@ -125,11 +126,11 @@ struct BtorWorker
string src = module && module->design ? module->design->get_src_attribute(obj) : std::string();
if (srcsym && infostr[0] == '$') {
std::replace(src.begin(), src.end(), ' ', '_');
TwineRef src_ref = TwineSearch(&module->design->twines).find(src);
TwineRef src_ref = src_search.find(src);
if (srcsymbols.count(src) || src_ref != Twine::Null) {
for (int i = 1;; i++) {
string s = stringf("%s-%d", src, i);
TwineRef s_ref = TwineSearch(&module->design->twines).find(s);
TwineRef s_ref = src_search.find(s);
if (!srcsymbols.count(s) && s_ref == Twine::Null) {
src = s;
break;
@ -153,11 +154,11 @@ struct BtorWorker
string src = module && module->design ? module->design->get_src_attribute(mem) : std::string();
if (srcsym && infostr[0] == '$') {
std::replace(src.begin(), src.end(), ' ', '_');
TwineRef src_ref = TwineSearch(&module->design->twines).find(src);
TwineRef src_ref = src_search.find(src);
if (srcsymbols.count(src) || src_ref != Twine::Null) {
for (int i = 1;; i++) {
string s = stringf("%s-%d", src, i);
TwineRef s_ref = TwineSearch(&module->design->twines).find(s);
TwineRef s_ref = src_search.find(s);
if (!srcsymbols.count(s) && s_ref == Twine::Null) {
src = s;
break;
@ -1193,7 +1194,7 @@ struct BtorWorker
}
BtorWorker(std::ostream &f, RTLIL::Module *module, bool verbose, bool single_bad, bool cover_mode, bool print_internal_names, string info_filename, string ywmap_filename) :
f(f), sigmap(module), module(module), verbose(verbose), single_bad(single_bad), cover_mode(cover_mode), print_internal_names(print_internal_names), info_filename(info_filename)
f(f), sigmap(module), module(module), verbose(verbose), single_bad(single_bad), cover_mode(cover_mode), print_internal_names(print_internal_names), src_search(&module->design->twines), info_filename(info_filename)
{
if (!info_filename.empty())
infof("name %s\n", module);

View file

@ -138,8 +138,6 @@ struct JsonWriter
void write_parameters(const dict<IdString, Const> &parameters, bool for_module=false, const RTLIL::AttrObject *src_obj=nullptr)
{
bool first = true;
// Emit the typed src field first if present — it lives outside the
// attribute dict after the typed-src migration.
if (src_obj && design && design->obj_src_id(src_obj) != Twine::Null) {
f << stringf("\n %s%s: ", for_module ? "" : " ", get_name(RTLIL::ID::src));
write_parameter_value(RTLIL::Const(design->get_src_attribute(src_obj)));

View file

@ -34,9 +34,6 @@ YOSYS_NAMESPACE_BEGIN
void RTLIL_BACKEND::dump_attributes(std::ostream &f, std::string indent, const RTLIL::AttrObject *obj, const RTLIL::Design *design, bool stringify)
{
// Emit the typed src field first. It is not stored in obj->attributes
// — the dict no longer holds ID::src under any circumstance. Backends
// that want to materialize the pipe-joined literal pass stringify.
if (design && design->obj_src_id(obj) != Twine::Null) {
TwineRef id = design->obj_src_id(obj);
f << stringf("%s" "attribute \\src ", indent);