def test_sext(do_test):
    class A(Component):
        def construct(s):
            s.in_ = InPort(Bits32)
            s.out = OutPort(Bits64)

            @s.update
            def upblk():
                s.out = sext(s.in_, 64)

    a = A()
    a._ref_upblk_srcs = { 'upblk' : \
  """\
always_comb begin : upblk
  out = { { 32 { in_[31] } }, in_ };
end\
""" }

    # TestVectorSimulator properties
    def tv_in(m, tv):
        m.in_ = Bits32(tv[0])

    def tv_out(m, tv):
        assert m.out == Bits64(tv[0])

    a._test_vectors = [
        [42, sext(Bits32(42), 64)],
        [-2, sext(Bits32(-2), 64)],
        [-1, sext(Bits32(-1), 64)],
        [2, sext(Bits32(2), 64)],
    ]
    a._tv_in, a._tv_out = tv_in, tv_out
    a._ref_upblk_srcs_yosys = a._ref_upblk_srcs
    do_test(a)
Exemple #2
0
 def upblk():
     x = sext(s)
Exemple #3
0
 def upblk():
     s.out = sext(s, 1)
Exemple #4
0
 def upblk():
     s.out = sext(s.in_, 4)