Esempio n. 1
0
def add_truth(inputs):
    '''
    Split inputs into two and return sum that is half length.
    First is carry.
    For the output, last bit is carry
    '''
    length = len(inputs)
    c = inputs[0]
    half = (length-1)/2
    inputa = inputs[0:half]
    inputb = inputs[half:length]
    a = get_uint(inputa)
    b = get_uint(inputb)
    result = a+b
    return get_bools(result, half+1)
Esempio n. 2
0
def decoder_truth(inputs):
    '''
    convert inputs to a number.
    '''
    number = get_uint(inputs)
    outputs = [False]*int(math.pow(2, len(inputs)))
    outputs[number] = True
    return outputs
Esempio n. 3
0
def mux_truth(inputs):
    '''
    inputs, then selects
    '''
    number_selects = get_selects(len(inputs))
    number_ins = len(inputs) - number_selects
    #print "num selects: {0}, inputs: {1}".format(number_selects,inputs)
    ins = inputs[0:number_ins]
    selects = inputs[number_ins:]
    select_index = get_uint(selects)
    #print "select: ", select_index
    return [ins[select_index]]