Пример #1
0
def dot(din: Queue[Tuple[Uint[8], Fixp]]):
    coef_t = din.dtype.data[1]
    accum_t = Fixp[coef_t.integer + 2, coef_t.width + 2]

    return din \
        | queuemap(f=mul) \
        | accum(init=accum_t(0.0), cast=saturate) \
        | qround \
        | saturate(t=Uint[8])
Пример #2
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])
Пример #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])