diff --git a/tests/test_firrtl_ir/test_prim_ops/test_add.py b/tests/test_firrtl_ir/test_prim_ops/test_add.py index c9b088d..8263e31 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_add.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_add.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Add -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -40,3 +40,5 @@ def test_add(): encounter_error_tester(add_width_wrong_cases) serialize_equal(Add([u(20, w(5)), u(15, w(4))], uw(6)), 'add(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Add([s(-20, w(6)), s(-15, w(5))], sw(6)), + 'add(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_and.py b/tests/test_firrtl_ir/test_prim_ops/test_and.py index 1eb0bfe..e38fd7c 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_and.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_and.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import And -from py_hcl.firrtl_ir.shortcuts import uw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -36,3 +36,5 @@ def test_and(): encounter_error_tester(and_width_wrong_cases) serialize_equal(And([u(20, w(5)), u(15, w(4))], uw(5)), 'and(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(And([s(-20, w(6)), s(-15, w(5))], uw(6)), + 'and(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_assint.py b/tests/test_firrtl_ir/test_prim_ops/test_assint.py index b080aa5..195f27c 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_assint.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_assint.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import AsSInt -from py_hcl.firrtl_ir.shortcuts import sw, uw, u, w +from py_hcl.firrtl_ir.shortcuts import sw, uw, u, w, s, n from py_hcl.firrtl_ir.type import UIntType, SIntType, ClockType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -42,3 +42,7 @@ def test_assint(): encounter_error_tester(assint_width_wrong_cases) serialize_equal(AsSInt(u(20, w(5)), sw(5)), 'asSInt(UInt<5>("14"))') + serialize_equal(AsSInt(s(-20, w(6)), sw(5)), + 'asSInt(SInt<6>("-14"))') + serialize_equal(AsSInt(n("clock", ClockType()), sw(1)), + 'asSInt(clock)') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_asuint.py b/tests/test_firrtl_ir/test_prim_ops/test_asuint.py index 0e7ba92..4119bae 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_asuint.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_asuint.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import AsUInt -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s, n from py_hcl.firrtl_ir.type import UIntType, SIntType, ClockType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -42,3 +42,7 @@ def test_asuint(): encounter_error_tester(asuint_width_wrong_cases) serialize_equal(AsUInt(u(20, w(5)), uw(5)), 'asUInt(UInt<5>("14"))') + serialize_equal(AsUInt(s(-20, w(6)), uw(5)), + 'asUInt(SInt<6>("-14"))') + serialize_equal(AsUInt(n("clock", ClockType()), uw(1)), + 'asUInt(clock)') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_bits.py b/tests/test_firrtl_ir/test_prim_ops/test_bits.py index 30026f7..027d7c5 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_bits.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_bits.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Bits -from py_hcl.firrtl_ir.shortcuts import uw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType, \ UnknownType, VectorType, BundleType from tests.test_firrtl_ir.utils import serialize_equal @@ -89,3 +89,5 @@ def test_bits(): encounter_error_tester(bits_invalid_cases) serialize_equal(Bits(u(20, w(5)), [4, 4], uw(1)), 'bits(UInt<5>("14"), 4, 4)') + serialize_equal(Bits(s(-20, w(6)), [4, 3], uw(2)), + 'bits(SInt<6>("-14"), 4, 3)') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_cat.py b/tests/test_firrtl_ir/test_prim_ops/test_cat.py index 89e9031..4e90264 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_cat.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_cat.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Cat -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -39,3 +39,5 @@ def test_cat(): encounter_error_tester(cat_width_wrong_cases) serialize_equal(Cat([u(20, w(5)), u(15, w(4))], uw(9)), 'cat(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Cat([s(-20, w(6)), s(-15, w(5))], uw(11)), + 'cat(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_div.py b/tests/test_firrtl_ir/test_prim_ops/test_div.py index c6ff3f2..6fc5964 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_div.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_div.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Div -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -37,3 +37,5 @@ def test_div(): encounter_error_tester(div_width_wrong_cases) serialize_equal(Div([u(20, w(5)), u(15, w(4))], uw(5)), 'div(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Div([s(-20, w(6)), s(-15, w(5))], uw(7)), + 'div(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_dshl.py b/tests/test_firrtl_ir/test_prim_ops/test_dshl.py index de345e2..7bde227 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_dshl.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_dshl.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Dshl -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -42,3 +42,5 @@ def test_dshl(): encounter_error_tester(dshl_width_wrong_cases) serialize_equal(Dshl([u(20, w(5)), u(15, w(4))], uw(20)), 'dshl(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Dshl([s(-20, w(6)), u(15, w(4))], uw(21)), + 'dshl(SInt<6>("-14"), UInt<4>("f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_dshr.py b/tests/test_firrtl_ir/test_prim_ops/test_dshr.py index 5d314a3..e232088 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_dshr.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_dshr.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Dshr -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -42,3 +42,5 @@ def test_dshr(): encounter_error_tester(dshr_width_wrong_cases) serialize_equal(Dshr([u(20, w(5)), u(15, w(4))], uw(5)), 'dshr(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Dshr([s(-20, w(6)), u(15, w(4))], uw(6)), + 'dshr(SInt<6>("-14"), UInt<4>("f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_eq.py b/tests/test_firrtl_ir/test_prim_ops/test_eq.py index ab077a8..abe8dfe 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_eq.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_eq.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Eq -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -39,3 +39,5 @@ def test_eq(): encounter_error_tester(eq_width_wrong_cases) serialize_equal(Eq([u(20, w(5)), u(15, w(4))], uw(1)), 'eq(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Eq([s(-20, w(6)), s(-15, w(5))], uw(1)), + 'eq(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_geq.py b/tests/test_firrtl_ir/test_prim_ops/test_geq.py index 99e021f..9f16009 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_geq.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_geq.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Geq -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -39,3 +39,5 @@ def test_geq(): encounter_error_tester(geq_width_wrong_cases) serialize_equal(Geq([u(20, w(5)), u(15, w(4))], uw(1)), 'geq(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Geq([s(-20, w(6)), s(-15, w(5))], uw(1)), + 'geq(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_gt.py b/tests/test_firrtl_ir/test_prim_ops/test_gt.py index 2ea1e34..2a11303 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_gt.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_gt.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Gt -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -39,3 +39,5 @@ def test_gt(): encounter_error_tester(gt_width_wrong_cases) serialize_equal(Gt([u(20, w(5)), u(15, w(4))], uw(1)), 'gt(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Gt([s(-20, w(6)), s(-15, w(5))], uw(1)), + 'gt(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_leq.py b/tests/test_firrtl_ir/test_prim_ops/test_leq.py index 781d9c5..1404f62 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_leq.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_leq.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Leq -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -39,3 +39,5 @@ def test_leq(): encounter_error_tester(leq_width_wrong_cases) serialize_equal(Leq([u(20, w(5)), u(15, w(4))], uw(1)), 'leq(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Leq([s(-20, w(6)), s(-15, w(5))], uw(1)), + 'leq(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_lt.py b/tests/test_firrtl_ir/test_prim_ops/test_lt.py index c770ad3..0c24ac0 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_lt.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_lt.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Lt -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -39,3 +39,5 @@ def test_lt(): encounter_error_tester(lt_width_wrong_cases) serialize_equal(Lt([u(20, w(5)), u(15, w(4))], uw(1)), 'lt(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Lt([s(-20, w(6)), s(-15, w(5))], uw(1)), + 'lt(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_mul.py b/tests/test_firrtl_ir/test_prim_ops/test_mul.py index 055464c..12a82bc 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_mul.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_mul.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Mul -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -38,3 +38,5 @@ def test_mul(): encounter_error_tester(mul_width_wrong_cases) serialize_equal(Mul([u(20, w(5)), u(15, w(4))], uw(9)), 'mul(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Mul([s(-20, w(6)), s(-15, w(5))], sw(11)), + 'mul(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_neg.py b/tests/test_firrtl_ir/test_prim_ops/test_neg.py index 24f8509..2487adb 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_neg.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_neg.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Neg -from py_hcl.firrtl_ir.shortcuts import sw, uw, u, w +from py_hcl.firrtl_ir.shortcuts import sw, uw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -39,5 +39,7 @@ def test_neg(): basis_tester(neg_basis_cases) encounter_error_tester(neg_type_wrong_cases) encounter_error_tester(neg_width_wrong_cases) - serialize_equal(Neg(u(20, w(5)), uw(6)), + serialize_equal(Neg(u(20, w(5)), sw(6)), 'neg(UInt<5>("14"))') + serialize_equal(Neg(s(-20, w(6)), sw(7)), + 'neg(SInt<6>("-14"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_neq.py b/tests/test_firrtl_ir/test_prim_ops/test_neq.py index 31262b1..4fda006 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_neq.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_neq.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Neq -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -39,3 +39,5 @@ def test_neq(): encounter_error_tester(neq_width_wrong_cases) serialize_equal(Neq([u(20, w(5)), u(15, w(4))], uw(1)), 'neq(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Neq([s(-20, w(6)), s(-15, w(5))], uw(1)), + 'neq(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_not.py b/tests/test_firrtl_ir/test_prim_ops/test_not.py index bd6b22f..b424213 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_not.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_not.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Not -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -39,3 +39,5 @@ def test_not(): encounter_error_tester(not_width_wrong_cases) serialize_equal(Not(u(20, w(5)), uw(5)), 'not(UInt<5>("14"))') + serialize_equal(Not(s(-20, w(6)), uw(6)), + 'not(SInt<6>("-14"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_or.py b/tests/test_firrtl_ir/test_prim_ops/test_or.py index 9fe7294..0b70000 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_or.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_or.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Or -from py_hcl.firrtl_ir.shortcuts import uw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -36,3 +36,5 @@ def test_or(): encounter_error_tester(or_width_wrong_cases) serialize_equal(Or([u(20, w(5)), u(15, w(4))], uw(5)), 'or(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Or([s(-20, w(6)), s(-15, w(5))], uw(6)), + 'or(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_rem.py b/tests/test_firrtl_ir/test_prim_ops/test_rem.py index 534b47b..7cdca2b 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_rem.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_rem.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Rem -from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, sw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -36,3 +36,5 @@ def test_rem(): encounter_error_tester(rem_width_wrong_cases) serialize_equal(Rem([u(20, w(5)), u(15, w(4))], uw(4)), 'rem(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Rem([s(-20, w(6)), s(-15, w(5))], sw(5)), + 'rem(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_shl.py b/tests/test_firrtl_ir/test_prim_ops/test_shl.py index d3186ca..d4cb1df 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_shl.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_shl.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Shl -from py_hcl.firrtl_ir.shortcuts import sw, uw, u, w +from py_hcl.firrtl_ir.shortcuts import sw, uw, u, w, s from py_hcl.firrtl_ir.type import BundleType, SIntType, \ UIntType, UnknownType, VectorType from tests.test_firrtl_ir.utils import serialize_equal @@ -48,3 +48,5 @@ def test_shl(): encounter_error_tester(shl_width_wrong_cases) serialize_equal(Shl(u(20, w(5)), 6, uw(11)), 'shl(UInt<5>("14"), 6)') + serialize_equal(Shl(s(-20, w(6)), 6, sw(12)), + 'shl(SInt<6>("-14"), 6)') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_shr.py b/tests/test_firrtl_ir/test_prim_ops/test_shr.py index 3c867f7..5837178 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_shr.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_shr.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Shr -from py_hcl.firrtl_ir.shortcuts import sw, uw, u, w +from py_hcl.firrtl_ir.shortcuts import sw, uw, u, w, s from py_hcl.firrtl_ir.type import BundleType, SIntType, \ UIntType, UnknownType, VectorType from tests.test_firrtl_ir.utils import serialize_equal @@ -48,3 +48,5 @@ def test_shr(): encounter_error_tester(shr_width_wrong_cases) serialize_equal(Shr(u(20, w(5)), 3, uw(2)), 'shr(UInt<5>("14"), 3)') + serialize_equal(Shr(s(-20, w(6)), 3, uw(3)), + 'shr(SInt<6>("-14"), 3)') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_sub.py b/tests/test_firrtl_ir/test_prim_ops/test_sub.py index 06e860e..8bea9b6 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_sub.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_sub.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Sub -from py_hcl.firrtl_ir.shortcuts import sw, u, w +from py_hcl.firrtl_ir.shortcuts import sw, u, w, s from py_hcl.firrtl_ir.type import SIntType, UIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import basis_tester, encounter_error_tester, OpCase, \ @@ -44,3 +44,5 @@ def test_sub(): encounter_error_tester(sub_width_wrong_cases) serialize_equal(Sub([u(20, w(5)), u(15, w(4))], sw(6)), 'sub(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Sub([s(-20, w(6)), s(-15, w(5))], sw(7)), + 'sub(SInt<6>("-14"), SInt<5>("-f"))') diff --git a/tests/test_firrtl_ir/test_prim_ops/test_xor.py b/tests/test_firrtl_ir/test_prim_ops/test_xor.py index f4a4a3b..08a26e0 100644 --- a/tests/test_firrtl_ir/test_prim_ops/test_xor.py +++ b/tests/test_firrtl_ir/test_prim_ops/test_xor.py @@ -1,5 +1,5 @@ from py_hcl.firrtl_ir.expr.prim_ops import Xor -from py_hcl.firrtl_ir.shortcuts import uw, u, w +from py_hcl.firrtl_ir.shortcuts import uw, u, w, s from py_hcl.firrtl_ir.type import UIntType, SIntType from tests.test_firrtl_ir.utils import serialize_equal from .helper import OpCase, basis_tester, \ @@ -36,3 +36,5 @@ def test_xor(): encounter_error_tester(xor_width_wrong_cases) serialize_equal(Xor([u(20, w(5)), u(15, w(4))], uw(5)), 'xor(UInt<5>("14"), UInt<4>("f"))') + serialize_equal(Xor([s(-20, w(6)), s(-15, w(5))], uw(6)), + 'xor(SInt<6>("-14"), SInt<5>("-f"))')