diff options
Diffstat (limited to 'frontends')
| -rw-r--r-- | frontends/aiger/aigerparse.cc | 45 | 
1 files changed, 41 insertions, 4 deletions
| diff --git a/frontends/aiger/aigerparse.cc b/frontends/aiger/aigerparse.cc index cf060193d..9374f1ab3 100644 --- a/frontends/aiger/aigerparse.cc +++ b/frontends/aiger/aigerparse.cc @@ -432,7 +432,7 @@ void AigerReader::parse_xaiger(const dict<int,IdString> &box_lookup)  			else if (c == 'r') {  				uint32_t dataSize YS_ATTRIBUTE(unused) = parse_xaiger_literal(f);  				flopNum = parse_xaiger_literal(f); -				log_debug("flopNum: %u\n", flopNum); +				log_debug("flopNum = %u\n", flopNum);  				log_assert(dataSize == (flopNum+1) * sizeof(uint32_t));  				f.ignore(flopNum * sizeof(uint32_t));  			} @@ -464,9 +464,10 @@ void AigerReader::parse_xaiger(const dict<int,IdString> &box_lookup)  					boxes.emplace_back(cell);  				}  			} -			else if (c == 'a' || c == 'i' || c == 'o') { +			else if (c == 'a' || c == 'i' || c == 'o' || c == 's') {  				uint32_t dataSize = parse_xaiger_literal(f);  				f.ignore(dataSize); +				log_debug("ignoring '%c'\n", c);  			}  			else {  				break; @@ -734,12 +735,19 @@ void AigerReader::parse_aiger_binary()  void AigerReader::post_process()  {  	pool<IdString> seen_boxes; -	unsigned ci_count = 0, co_count = 0; +	pool<IdString> flops; +	unsigned ci_count = 0, co_count = 0, flop_count = 0;  	for (auto cell : boxes) {  		RTLIL::Module* box_module = design->module(cell->type);  		log_assert(box_module); +		bool is_flop = false;  		if (seen_boxes.insert(cell->type).second) { +			if (box_module->attributes.count("\\abc9_flop")) { +				log_assert(flop_count < flopNum); +				flops.insert(cell->type); +				is_flop = true; +			}  			auto it = box_module->attributes.find("\\abc9_carry");  			if (it != box_module->attributes.end()) {  				RTLIL::Wire *carry_in = nullptr, *carry_out = nullptr; @@ -779,6 +787,8 @@ void AigerReader::post_process()  				carry_out->port_id = ports.size();  			}  		} +		else +			is_flop = flops.count(cell->type);  		// NB: Assume box_module->ports are sorted alphabetically  		//     (as RTLIL::Module::fixup_ports() would do) @@ -804,9 +814,32 @@ void AigerReader::post_process()  				}  				rhs.append(wire);  			} -  			cell->setPort(port_name, rhs);  		} + +		if (is_flop) { +			log_assert(co_count < outputs.size()); +			Wire *wire = outputs[co_count++]; +			log_assert(wire); +			log_assert(wire->port_output); +			wire->port_output = false; + +			RTLIL::Wire *d = outputs[outputs.size() - flopNum + flop_count]; +			log_assert(d); +			log_assert(d->port_output); +			d->port_output = false; + +			RTLIL::Wire *q = inputs[piNum - flopNum + flop_count]; +			log_assert(q); +			log_assert(q->port_input); +			q->port_input = false; + +			auto ff = module->addCell(NEW_ID, "$__ABC9_FF_"); +			ff->setPort("\\D", d); +			ff->setPort("\\Q", q); +			flop_count++; +			continue; +		}  	}  	dict<RTLIL::IdString, int> wideports_cache; @@ -909,6 +942,10 @@ void AigerReader::post_process()  					}  				}  				log_debug(" -> %s\n", log_id(wire)); +				int init; +				mf >> init; +				if (init < 2) +					wire->attributes["\\init"] = init;  			}  			else if (type == "box") {  				RTLIL::Cell* cell = module->cell(stringf("$__box%d__", variable)); | 
