diff options
Diffstat (limited to 'frontends/aiger')
| -rw-r--r-- | frontends/aiger/aigerparse.cc | 65 | ||||
| -rw-r--r-- | frontends/aiger/aigerparse.h | 2 | 
2 files changed, 27 insertions, 40 deletions
diff --git a/frontends/aiger/aigerparse.cc b/frontends/aiger/aigerparse.cc index bb97c5703..bd0596cc0 100644 --- a/frontends/aiger/aigerparse.cc +++ b/frontends/aiger/aigerparse.cc @@ -30,6 +30,7 @@  #include <libkern/OSByteOrder.h>  #define __builtin_bswap32 OSSwapInt32  #endif +#define __STDC_FORMAT_MACROS  #include <inttypes.h>  #include "kernel/yosys.h" @@ -151,12 +152,12 @@ struct ConstEvalAig  		RTLIL::State eval_ret = RTLIL::Sx;  		if (cell->type == "$_NOT_") { -			if (sig_a == RTLIL::S0) eval_ret = RTLIL::S1; -			else if (sig_a == RTLIL::S1) eval_ret = RTLIL::S0; +			if (sig_a == State::S0) eval_ret = State::S1; +			else if (sig_a == State::S1) eval_ret = State::S0;  		}  		else if (cell->type == "$_AND_") { -			if (sig_a == RTLIL::S0) { -				eval_ret = RTLIL::S0; +			if (sig_a == State::S0) { +				eval_ret = State::S0;  				goto eval_end;  			} @@ -164,15 +165,15 @@ struct ConstEvalAig  				RTLIL::SigBit sig_b = cell->getPort("\\B");  				if (!eval(sig_b))  					return false; -				if (sig_b == RTLIL::S0) { -					eval_ret = RTLIL::S0; +				if (sig_b == State::S0) { +					eval_ret = State::S0;  					goto eval_end;  				} -				if (sig_a != RTLIL::S1 || sig_b != RTLIL::S1) +				if (sig_a != State::S1 || sig_b != State::S1)  					goto eval_end; -				eval_ret = RTLIL::S1; +				eval_ret = State::S1;  			}  		}  		else log_abort(); @@ -256,7 +257,7 @@ end_of_header:  	RTLIL::Wire* n0 = module->wire("\\__0__");  	if (n0) -		module->connect(n0, RTLIL::S0); +		module->connect(n0, State::S0);  	// Parse footer (symbol table, comments, etc.)  	unsigned l1; @@ -337,7 +338,7 @@ static RTLIL::Wire* createWireIfNotExists(RTLIL::Module *module, unsigned litera  	return wire;  } -void AigerReader::parse_xaiger() +void AigerReader::parse_xaiger(const dict<int,IdString> &box_lookup)  {  	std::string header;  	f >> header; @@ -371,22 +372,7 @@ void AigerReader::parse_xaiger()  	RTLIL::Wire* n0 = module->wire("\\__0__");  	if (n0) -		module->connect(n0, RTLIL::S0); - -	dict<int,IdString> box_lookup; -	for (auto m : design->modules()) { -		auto it = m->attributes.find("\\abc_box_id"); -		if (it == m->attributes.end()) -			continue; -		if (m->name.begins_with("$paramod")) -			continue; -		auto id = it->second.as_int(); -		auto r = box_lookup.insert(std::make_pair(id, m->name)); -		if (!r.second) -			log_error("Module '%s' has the same abc_box_id = %d value as '%s'.\n", -					log_id(m), id, log_id(r.first->second)); -		log_assert(r.second); -	} +		module->connect(n0, State::S0);  	// Parse footer (symbol table, comments, etc.)  	std::string s; @@ -535,9 +521,9 @@ void AigerReader::parse_aiger_ascii()  				log_error("Line %u cannot be interpreted as a latch!\n", line_count);  			if (l3 == 0) -				q_wire->attributes["\\init"] = RTLIL::S0; +				q_wire->attributes["\\init"] = State::S0;  			else if (l3 == 1) -				q_wire->attributes["\\init"] = RTLIL::S1; +				q_wire->attributes["\\init"] = State::S1;  			else if (l3 == l1) {  				//q_wire->attributes["\\init"] = RTLIL::Sx;  			} @@ -546,7 +532,7 @@ void AigerReader::parse_aiger_ascii()  		}  		else {  			// AIGER latches are assumed to be initialized to zero -			q_wire->attributes["\\init"] = RTLIL::S0; +			q_wire->attributes["\\init"] = State::S0;  		}  		latches.push_back(q_wire);  	} @@ -660,9 +646,9 @@ void AigerReader::parse_aiger_binary()  				log_error("Line %u cannot be interpreted as a latch!\n", line_count);  			if (l3 == 0) -				q_wire->attributes["\\init"] = RTLIL::S0; +				q_wire->attributes["\\init"] = State::S0;  			else if (l3 == 1) -				q_wire->attributes["\\init"] = RTLIL::S1; +				q_wire->attributes["\\init"] = State::S1;  			else if (l3 == l1) {  				//q_wire->attributes["\\init"] = RTLIL::Sx;  			} @@ -671,7 +657,7 @@ void AigerReader::parse_aiger_binary()  		}  		else {  			// AIGER latches are assumed to be initialized to zero -			q_wire->attributes["\\init"] = RTLIL::S0; +			q_wire->attributes["\\init"] = State::S0;  		}  		latches.push_back(q_wire);  	} @@ -986,15 +972,16 @@ void AigerReader::post_process()  	}  	module->fixup_ports(); -	design->add(module); -	design->selection_stack.emplace_back(false); -	RTLIL::Selection& sel = design->selection_stack.back(); -	sel.select(module); +	// Insert into a new (temporary) design so that "clean" will only +	// operate (and run checks on) this one module +	RTLIL::Design *mapped_design = new RTLIL::Design; +	mapped_design->add(module); +	Pass::call(mapped_design, "clean"); +	mapped_design->modules_.erase(module->name); +	delete mapped_design; -	Pass::call(design, "clean"); - -	design->selection_stack.pop_back(); +	design->add(module);  	for (auto cell : module->cells().to_vector()) {  		if (cell->type != "$lut") continue; diff --git a/frontends/aiger/aigerparse.h b/frontends/aiger/aigerparse.h index de3c3efbc..583c9d0f9 100644 --- a/frontends/aiger/aigerparse.h +++ b/frontends/aiger/aigerparse.h @@ -47,7 +47,7 @@ struct AigerReader      AigerReader(RTLIL::Design *design, std::istream &f, RTLIL::IdString module_name, RTLIL::IdString clk_name, std::string map_filename, bool wideports);      void parse_aiger(); -    void parse_xaiger(); +    void parse_xaiger(const dict<int,IdString> &box_lookup);      void parse_aiger_ascii();      void parse_aiger_binary();      void post_process();  | 
