diff options
author | Clifford Wolf <clifford@clifford.at> | 2019-05-22 12:01:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-22 12:01:19 +0200 |
commit | 84d91420e4a6b09a70e9588f918aec9e684b3c63 (patch) | |
tree | d5ae33a579360c8cafb45003880fa14846391711 | |
parent | cb24d23b6d450edb3349c9788c06a0a1ee9f0ade (diff) | |
parent | a5131e28966757c3c8b79bee838005c0246f6331 (diff) | |
download | yosys-84d91420e4a6b09a70e9588f918aec9e684b3c63.tar.gz yosys-84d91420e4a6b09a70e9588f918aec9e684b3c63.tar.bz2 yosys-84d91420e4a6b09a70e9588f918aec9e684b3c63.zip |
Merge pull request #1021 from ucb-bar/fixfirrtl_shr,neg
Fix static shift operands, neg result type, minor formatting
-rw-r--r-- | backends/firrtl/firrtl.cc | 10 |
1 files changed, 7 insertions, 3 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"; } |