Beispiel #1
0
def test_through_hier_cosim_in_channel():
    reg['gear/infer_signal_names'] = True

    @gear
    def hier(din, *, channeled):
        din | leaf_sink(name='si1')
        channeled | leaf_sink(name='si2')

    s = leaf_src(t=Unit)
    s | hier(sim_cls=CosimBase, channeled=s)

    intf = get_source_producer(s)
    assert is_source_producer(intf)
    assert intf.consumers[0].name == '/leaf_src.dout'

    consumers = get_consumer_tree(intf)

    # Leaf consumers are hidden behind "hier" module with "sim_cls"
    assert len(consumers) == 1
    assert consumers[0].name == '/hier.din'
    assert is_end_consumer(consumers[0].consumer, sim=True)

    cons_intf = consumers[0].consumer
    assert len(cons_intf.consumers) == 2
    assert cons_intf.consumers[0].name == '/hier/si1.din'
    assert cons_intf.consumers[1].name == '/hier/si2.din'
Beispiel #2
0
    def extend_intfs(self):
        for p, v in self.vcd_vars.items():
            v['srcs'] = [self.end_consumers[pp.consumer] for pp in get_consumer_tree(p.consumer)]
            v['srcs_active'] = [False] * len(v['srcs'])
            v['p'] = p
            for vs in v['srcs']:
                vs['prods'].append(v)

        reg['graph/consumer_tree'] = {}
        reg['graph/end_producer'] = {}
Beispiel #3
0
def test_plain():
    reg['gear/infer_signal_names'] = True

    s = leaf_src(t=Unit)
    s | leaf_sink(name='si1')
    s | leaf_sink(name='si2')

    intf = get_source_producer(s)
    assert is_source_producer(intf)
    assert intf.consumers[0].name == '/leaf_src.dout'

    consumers = get_consumer_tree(intf)
    assert len(consumers) == 2

    assert consumers[0].name == '/si1.din'
    assert consumers[1].name == '/si2.din'

    assert is_end_consumer(consumers[0])
    assert is_end_consumer(consumers[1])
Beispiel #4
0
def test_through_hier_cosim():
    reg['gear/infer_signal_names'] = True

    @gear
    def hier(din):
        din | leaf_sink(name='si1')
        din | leaf_sink(name='si2')

    s = leaf_src(t=Unit)
    s | hier(sim_cls=CosimBase)

    intf = get_source_producer(s)
    assert is_source_producer(intf)
    assert intf.consumers[0].name == '/leaf_src.dout'

    consumers = get_consumer_tree(intf)
    assert len(consumers) == 1

    assert consumers[0].name == '/hier.din'

    assert is_end_consumer(consumers[0], sim=True)
Beispiel #5
0
def test_through_hier_simple():
    reg['gear/infer_signal_names'] = True

    @gear
    def hier(din):
        din | leaf_sink(name='si1')
        din | leaf_sink(name='si2')

    s = leaf_src(t=Unit)
    s | hier

    intf = get_source_producer(s)
    assert is_source_producer(intf)
    assert intf.consumers[0].name == '/leaf_src.dout'

    consumers = get_consumer_tree(intf)
    assert len(consumers) == 2

    assert consumers[0].name == '/hier/si1.din'
    assert consumers[1].name == '/hier/si2.din'

    assert is_end_consumer(consumers[0])
    assert is_end_consumer(consumers[1])
Beispiel #6
0
def test_through_hier_cosim_out_channel():
    reg['gear/infer_signal_names'] = True

    @gear
    def hier(din, *, channeled):
        din | leaf_sink(name='si1')
        channeled |= leaf_src(name='sr2', t=Unit)

    sout = Intf(Unit)
    sout | leaf_sink(name='si0')
    sin = leaf_src(t=Unit)
    sin | hier(sim_cls=CosimBase, channeled=sout)

    intf = get_source_producer(sout, sim=True)
    assert is_source_producer(intf, sim=True)
    assert intf.consumers[0].name == '/hier.channeled'

    consumers = get_consumer_tree(intf)

    # Leaf consumers are hidden behind "hier" module with "sim_cls"
    assert len(consumers) == 1
    assert consumers[0].name == '/si0.din'
    assert is_end_consumer(consumers[0].consumer)