forked from opendacs/PyHCL
test_firrtl_ir: add serialize (#26)
This commit is contained in:
parent
bcfae9b41a
commit
664322cc11
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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)')
|
||||
|
|
|
@ -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)')
|
||||
|
|
|
@ -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)')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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)')
|
||||
|
|
|
@ -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)')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
|
@ -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"))')
|
||||
|
|
Loading…
Reference in New Issue