diff options
| -rw-r--r-- | backends/firrtl/firrtl.cc | 10 | ||||
| -rw-r--r-- | frontends/aiger/aigerparse.cc | 14 | 
2 files changed, 16 insertions, 8 deletions
diff --git a/backends/firrtl/firrtl.cc b/backends/firrtl/firrtl.cc index fe6bdb8f6..1c7a7351f 100644 --- a/backends/firrtl/firrtl.cc +++ b/backends/firrtl/firrtl.cc @@ -146,7 +146,7 @@ struct FirrtlWorker  			if (!mask.is_fully_def())  				this->ena = SigSpec(RTLIL::Const(1));  		} -	  string gen_read(const char * /* indent */) { +		string gen_read(const char * /* indent */) {  			log_error("gen_read called on write_port: %s\n", name.c_str());  			return stringf("gen_read called on write_port: %s\n", name.c_str());  		} @@ -449,8 +449,10 @@ struct FirrtlWorker  				string primop;  				bool always_uint = false;  				if (cell->type == "$not") primop = "not"; -				else if (cell->type == "$neg") primop = "neg"; -				else if (cell->type == "$logic_not") { +				else if (cell->type == "$neg") { +					primop = "neg"; +					is_signed = true;	// Result of "neg" is signed (an SInt). +				} else if (cell->type == "$logic_not") {                                          primop = "eq";                                          a_expr = stringf("%s, UInt(0)", a_expr.c_str());                                  } @@ -562,6 +564,7 @@ struct FirrtlWorker  					auto b_sig = cell->getPort("\\B");  					if (b_sig.is_fully_const()) {  						primop = "shl"; +						b_expr = std::to_string(b_sig.as_int());  					} else {  						primop = "dshl";  						// Convert from FIRRTL left shift semantics. @@ -575,6 +578,7 @@ struct FirrtlWorker  					auto b_sig = cell->getPort("\\B");  					if (b_sig.is_fully_const()) {  						primop = "shr"; +						b_expr = std::to_string(b_sig.as_int());  					} else {  						primop = "dshr";  					} diff --git a/frontends/aiger/aigerparse.cc b/frontends/aiger/aigerparse.cc index 2e4774dfd..38348cd65 100644 --- a/frontends/aiger/aigerparse.cc +++ b/frontends/aiger/aigerparse.cc @@ -55,11 +55,15 @@ void AigerReader::parse_aiger()      // Optional values      B = C = J = F = 0; -    for (auto &i : std::array<std::reference_wrapper<unsigned>,4>{B, C, J, F}) { -        if (f.peek() != ' ') break; -        if (!(f >> i)) -            log_error("Invalid AIGER header\n"); -    } +    if (f.peek() != ' ') goto end_of_header; +    if (!(f >> B)) log_error("Invalid AIGER header\n"); +    if (f.peek() != ' ') goto end_of_header; +    if (!(f >> C)) log_error("Invalid AIGER header\n"); +    if (f.peek() != ' ') goto end_of_header; +    if (!(f >> J)) log_error("Invalid AIGER header\n"); +    if (f.peek() != ' ') goto end_of_header; +    if (!(f >> F)) log_error("Invalid AIGER header\n"); +end_of_header:      std::string line;      std::getline(f, line); // Ignore up to start of next line, as standard  | 
