diff options
author | Jannis Harder <me@jix.one> | 2022-08-02 21:12:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-02 21:12:32 +0200 |
commit | b8316b2f13aa8005d33d666f3cb905ee237924d4 (patch) | |
tree | 33bd8bcce096e0d21d93673af74fd6b6536d3b1c | |
parent | 7d4f87d69f06d2cf6259fb445275a5f479bf74ee (diff) | |
parent | 6af5e74f95abdead1c4c900e0c1951b71dcf80c8 (diff) | |
download | yosys-b8316b2f13aa8005d33d666f3cb905ee237924d4.tar.gz yosys-b8316b2f13aa8005d33d666f3cb905ee237924d4.tar.bz2 yosys-b8316b2f13aa8005d33d666f3cb905ee237924d4.zip |
Merge pull request #3433 from jix/fix_smt_shift
smt2: Fix $shift/$shiftx with negative shift ammounts
-rw-r--r-- | backends/smt2/smt2.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/backends/smt2/smt2.cc b/backends/smt2/smt2.cc index 7481e0510..f6c3560c1 100644 --- a/backends/smt2/smt2.cc +++ b/backends/smt2/smt2.cc @@ -449,7 +449,7 @@ struct Smt2Worker bool is_signed = cell->getParam(ID::A_SIGNED).as_bool(); int width = GetSize(sig_y); - if (type == 's' || type == 'd' || type == 'b') { + if (type == 's' || type == 'S' || type == 'd' || type == 'b') { width = max(width, GetSize(cell->getPort(ID::A))); if (cell->hasPort(ID::B)) width = max(width, GetSize(cell->getPort(ID::B))); @@ -462,7 +462,7 @@ struct Smt2Worker if (cell->hasPort(ID::B)) { sig_b = cell->getPort(ID::B); - sig_b.extend_u0(width, is_signed && !(type == 's')); + sig_b.extend_u0(width, (type == 'S') || (is_signed && !(type == 's'))); } std::string processed_expr; @@ -619,8 +619,8 @@ struct Smt2Worker if (cell->type.in(ID($shift), ID($shiftx))) { if (cell->getParam(ID::B_SIGNED).as_bool()) { return export_bvop(cell, stringf("(ite (bvsge P #b%0*d) " - "(bvlshr A B) (bvlshr A (bvneg B)))", - GetSize(cell->getPort(ID::B)), 0), 's'); + "(bvlshr A B) (bvshl A (bvneg B)))", + GetSize(cell->getPort(ID::B)), 0), 'S'); // type 'S' sign extends B } else { return export_bvop(cell, "(bvlshr A B)", 's'); } |