Exemplo n.º 1
0
def test_loopback():
    circ = aigbv.rebundle_aig(aiger.identity(['x[0]', 'x[1]', 'y[0]', 'y[1]']))
    circ2 = circ.loopback({'input': 'x', 'output': 'y'})
    assert circ2.inputs == {'y'}

    circ = aigbv.rebundle_aig(aiger.identity(['x[0]', 'x[1]', 'y[0]', 'y[1]']))
    circ2 = circ.loopback({'input': 'x', 'output': 'y', 'init': (True, False)})
    assert circ2.latch2init['x'] == (True, False)
Exemplo n.º 2
0
def test_feedback():
    circ = aigbv.rebundle_aig(aiger.identity(['x[0]', 'x[1]', 'y[0]', 'y[1]']))
    circ2 = circ.feedback(inputs=['x'], outputs=['y'])
    assert circ2.inputs == {'y'}

    circ = aigbv.rebundle_aig(aiger.identity(['x[0]', 'x[1]', 'y[0]', 'y[1]']))
    circ2 = circ.feedback(inputs=['x'],
                          outputs=['y'],
                          initials=[(True, False)])
    assert circ2.latch2init['x'] == (True, False)
Exemplo n.º 3
0
def test_unroll():
    circ = aigbv.rebundle_aig(aiger.identity(['x[0]', 'x[1]', 'y[0]', 'y[1]']))
    circ2 = circ.feedback(inputs=['x'], outputs=['y'])

    circ3 = circ2.unroll(3)
    assert circ3.inputs == {'y##time_0', 'y##time_1', 'y##time_2'}
    assert circ3.outputs == {'x##time_1', 'x##time_2', 'x##time_3'}
Exemplo n.º 4
0
def test_cutlatches():
    circ = aigbv.rebundle_aig(aiger.identity(['x[0]', 'x[1]', 'y[0]', 'y[1]']))
    circ2 = circ.feedback(inputs=['x'], outputs=['y'])
    circ3, lmap = circ2.cutlatches(renamer=lambda x: f"{x}##time_0")

    assert circ3.inputs >= circ2.inputs
    assert circ3.outputs >= circ2.outputs
    assert len(lmap) == 1
Exemplo n.º 5
0
def identity_gate(wordlen, input='x', output=None):
    if output is None:
        output = input

    imap, omap = BundleMap({input: wordlen}), BundleMap({output: wordlen})
    return aigbv.AIGBV(
        imap=imap,
        omap=omap,
        aig=aiger.identity(inputs=imap[input], outputs=omap[output]),
    )
Exemplo n.º 6
0
def index_gate(wordlen, idx, input, output=None):
    assert 0 <= idx < wordlen
    if output is None:
        output = input

    imap, omap = BundleMap({input: wordlen}), BundleMap({output: 1})
    inputs, outputs = imap[input], (imap[input][idx], )

    aig = aiger.sink(set(inputs) - set(outputs)) | aiger.identity(outputs)
    relabels = {outputs[0]: omap[output][0]}
    return aigbv.AIGBV(imap=imap, omap=omap, aig=aig['o', relabels])
Exemplo n.º 7
0
def identity_gate(wordlen, input='x', output=None):
    if output is None:
        output = input

    inputs = named_indexes(wordlen, input)
    outputs = named_indexes(wordlen, output)
    return aigbv.AIGBV(
        aig=aiger.identity(inputs=inputs, outputs=outputs),
        input_map=frozenset([(input, inputs)]),
        output_map=frozenset([(output, outputs)]),
    )
Exemplo n.º 8
0
def index_gate(wordlen, idx, input, output=None):
    assert 0 <= idx < wordlen
    if output is None:
        output = input

    inputs = named_indexes(wordlen, input)
    outputs = (inputs[idx], )
    aig = aiger.sink(set(inputs) - set(outputs)) \
        | aiger.identity(outputs)
    return aigbv.AIGBV(
        aig=aig,
        input_map=frozenset([(input, inputs)]),
        output_map=frozenset([(output, outputs)]),
    )