Exemplo n.º 1
0
def min_parallel(v, length):
    srcs = [v.prev(i) for i in range(length)]

    while len(srcs) > 1:
        next_srcs = []
        while srcs:
            a = srcs.pop(0)
            b = srcs.pop(0) if srcs else None
            if b is None:
                next_srcs.append(a)
            else:
                next_srcs.append(dataflow.Mux(a < b, a, b))
        srcs = next_srcs

    return srcs[0]
Exemplo n.º 2
0
def mkMain():
    # input variiable
    x = dataflow.Variable('xdata', valid='xvalid', ready='xready')
    y = dataflow.Variable('ydata', valid='yvalid', ready='yready')

    # dataflow definition
    z = dataflow.Mux(x < y, x, y)

    # set output attribute
    z.output('zdata', valid='zvalid', ready='zready')

    df = dataflow.Dataflow(z)
    m = df.to_module('main')

    return m
Exemplo n.º 3
0
def mkMain():
    # input variiable
    x = dataflow.Variable('xdata', valid='xvalid', ready='xready')
    y = dataflow.Variable('ydata', valid='yvalid', ready='yready')

    # Mux with constant condition: only true_value is selected
    z = dataflow.Mux(1, x + y, x - y)

    # set output attribute
    z.output('zdata', valid='zvalid', ready='zready')

    df = dataflow.Dataflow(z)
    m = df.to_module('main')

    return m
Exemplo n.º 4
0
def min_serial(v, length):
    ret = v
    for i in range(1, length):
        prev = v.prev(i)
        ret = dataflow.Mux(ret < prev, ret, prev)
    return ret
Exemplo n.º 5
0
def mux(cond, x, y):
    if dataflow.is_dataflow_object(cond, x, y):
        return dataflow.Mux(cond, x, y)
    return x if cond else y