示例#1
0
def filter(din: Queue[Uint[8]], *, coeffs, precision=32):
    accum_t = Ufixp[10, 10 + precision]

    coeff = qrange(3*3) \
        | flatten \
        | rom(data=coeffs, dtype=Ufixp[0, precision])

    return czip(din, coeff) \
        | queuemap(f=mul) \
        | accum(init=accum_t(0.0), cast=saturate) \
        | qround \
        | saturate(t=Uint[8])
示例#2
0
def filter(pixels: Queue[Array[Uint[8], 3]], coef: Queue[Array[Fixp, 3]], *,
           window_num):

    window_cnt = replicate(when(coef['eot'], window_num), 3 * 3)

    mem_wr_data = czip(qcnt(coef, running=True, w_out=4, init=0),
                       coef) | flatten

    coef_rd = qrange(window_cnt['data']) \
        | flatten \
        | sdp(wr_addr_data=mem_wr_data, depth=16)

    pix_coef = czip(pixels, coef_rd) | reorder

    res = [dot(p) for p in pix_coef]

    return ccat(*res)
示例#3
0
def filter(pixels: Queue[Uint[8]], coef: Queue[Fixp], *, window_num):
    coef_t = coef.dtype.data
    accum_t = Fixp[coef_t.integer + 2, coef_t.width + 2]

    window_cnt = replicate(window_num, 3 * 3)

    mem_wr_data = czip(qcnt(coef, running=True, w_out=4, init=0),
                       coef) | flatten

    coef_rd = qrange(window_cnt['data']) \
        | flatten \
        | sdp(wr_addr_data=mem_wr_data, depth=16)

    return czip(pixels, coef_rd) \
        | queuemap(f=mul) \
        | accum(init=accum_t(0.0), cast=saturate) \
        | qround \
        | saturate(t=Uint[8])
示例#4
0
def test_basic(tmpdir):
    qrange(Intf(Uint[8]))
示例#5
0
 def qrange_wrp(din):
     return qrange(din)
示例#6
0
def test_stop_unsigned(sim_cls):
    directed(drv(t=Uint[4], seq=[4]),
             f=qrange(sim_cls=sim_cls),
             ref=[list(range(4))])
    sim()
示例#7
0
def test_start_stop_step_combined(sim_cls):
    res = []
    qrange((0, 8, 1), sim_cls=sim_cls) | collect(result=res)
    sim(timeout=16)

    assert res == [(i, i == 7) for i in range(8)] * 2
示例#8
0
def test_start_stop_combined(sim_cls):
    directed(drv(t=Tuple[Int[2], Uint[4]], seq=[(-2, 7)]),
             f=qrange(sim_cls=sim_cls),
             ref=[list(range(-2, 7))])
    sim()
示例#9
0
def test_start_stop_inclusive(sim_cls):
    directed(drv(t=Tuple[Uint[2], Uint[4]], seq=[(2, 10)]),
             f=qrange(inclusive=True, sim_cls=sim_cls),
             ref=[list(range(2, 11))])
    sim()
示例#10
0
def test_start_stop(sim_cls):
    directed(drv(t=Tuple[Uint[2], Uint[4]], seq=[(2, 10)]),
             f=qrange(sim_cls=sim_cls),
             ref=[list(range(2, 10))])
    sim()
示例#11
0
def test_stop_inclusive(sim_cls):
    directed(drv(t=Uint[4], seq=[4]),
             f=qrange(inclusive=True, sim_cls=sim_cls),
             ref=[list(range(5))])
    sim()
示例#12
0
def test_stop_signed(sim_cls):
    directed(drv(t=Int[4], seq=[7]),
             f=qrange(sim_cls=sim_cls),
             ref=[list(range(7))])
    sim()
示例#13
0
 async def test() -> Uint[3]:
     async for i, _ in qrange(4):
         yield i
示例#14
0
 async def test() -> Tuple[Uint[4], Uint[4]]:
     async for (i, i_eot) in qrange(2):
         async for (j, j_eot) in qrange(2):
             yield i, j