当前位置: 首页>>代码示例>>Python>>正文


Python myhdl.Signal类代码示例

本文整理汇总了Python中myhdl.Signal的典型用法代码示例。如果您正苦于以下问题:Python Signal类的具体用法?Python Signal怎么用?Python Signal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Signal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: bench

    def bench(self):
        clk = Signal(0)
        sig1 = Signal(0)
        sig2 = Signal(0)
        td = 10

        def gen(s, n):
            for i in range(n-1):
                yield delay(td)
            s.next = 1
            yield delay(td)

        for i in range(10):
            offset = now()
            n0 = randrange(1, 50)
            n1 = randrange(1, 50)
            n2 = randrange(1, 50)
            sig1.next = 0
            sig2.next = 0
            yield join(delay(n0*td), gen(sig1, n1), gen(sig2, n2))
            assert sig1.val == 1
            assert sig2.val == 1
            assert now() == offset + td * max(n0, n1, n2)

        raise StopSimulation("Joined concurrent generator yield")
开发者ID:Aravind-Suresh,项目名称:myhdl,代码行数:25,代码来源:test_Simulation.py

示例2: assign_config

def assign_config(sig, val):
    keep = Signal(bool(0))
    keep.driven = 'wire'

    @always_comb
    def beh_assign():
        sig.next = val if keep else val
    return beh_assign
开发者ID:zignig,项目名称:rhea,代码行数:8,代码来源:cso.py

示例3: testValAttrReadOnly

 def testValAttrReadOnly(self):
     """ val attribute should not be writable"""
     s1 = Signal(1)
     try:
         s1.val = 1
     except AttributeError:
         pass
     else:
         self.fail()
开发者ID:Cadavis8,项目名称:myhdl,代码行数:9,代码来源:test_Signal.py

示例4: testDrivenAttrValue

 def testDrivenAttrValue(self):
     """ driven attribute only accepts value 'reg' or 'wire' """
     s1 = Signal(1)
     try:
         s1.driven = "signal"
     except ValueError:
         pass
     else:
         self.fail()
开发者ID:Cadavis8,项目名称:myhdl,代码行数:9,代码来源:test_Signal.py

示例5: get_unsigned_intbv_rand_signal

def get_unsigned_intbv_rand_signal(width, init_value=0):
    '''Create an unsigned intbv random signal.
    '''
    min_val = 0
    max_val = 2**(width)
    signal = Signal(intbv(val=init_value, min=min_val, max=max_val))
    signal.val[:] = randrange(min_val, max_val)

    return signal, min_val, max_val
开发者ID:hgomersall,项目名称:Ovenbird,代码行数:9,代码来源:base_hdl_test.py

示例6: testNegedgeAttrReadOnly

 def testNegedgeAttrReadOnly(self):
     """ negedge attribute should not be writable"""
     s1 = Signal(1)
     try:
         s1.negedge = 1
     except AttributeError:
         pass
     else:
         self.fail()
开发者ID:Cadavis8,项目名称:myhdl,代码行数:9,代码来源:test_Signal.py

示例7: testSignalBoolBounds

 def testSignalBoolBounds(self):
     if type(bool) is not type:  # bool not a type in 2.2
         return
     s = Signal(bool())
     s.next = 1
     s.next = 0
     for v in (-1, -8, 2, 5):
         with pytest.raises(ValueError):
             s.next = v
开发者ID:Aravind-Suresh,项目名称:myhdl,代码行数:9,代码来源:test_Signal.py

示例8: stimulus

 def stimulus():
     a = Signal(0)
     yield delay(10)
     a.next = 1
     yield None, delay(10)
     self.assertEqual(a.val, 0)
     self.assertEqual(now(), 10)
     yield delay(0)
     self.assertEqual(a.val, 1)
     self.assertEqual(now(), 10)
开发者ID:Alisa-lisa,项目名称:uni-stuff,代码行数:10,代码来源:test_Simulation.py

示例9: stimulus

 def stimulus():
     a = Signal(0)
     yield delay(10)
     a.next = 1
     yield None, delay(10)
     assert a.val == 0
     assert now() == 10
     yield delay(0)
     assert a.val == 1
     assert now() == 10
开发者ID:Aravind-Suresh,项目名称:myhdl,代码行数:10,代码来源:test_Simulation.py

示例10: inst

    def inst():
        yield delay(200 * nsec)

        addr = Signal(intbv(0x10)[len(bus.A):])

        while 1:
            yield system.CLK.posedge

            bus.CS_B.next = 0
            bus.RAS_B.next = 0
            bus.A.next = 0x4
            bus.BA.next = 0x2

            yield system.CLK.posedge

            bus.CS_B.next = 1
            bus.RAS_B.next = 1
            bus.A.next = ~0 & mask(bus.A)
            bus.BA.next = ~0 & mask(bus.BA)

            yield system.CLK.posedge

            bus.CS_B.next = 0
            bus.CAS_B.next = 0
            bus.A.next = addr
            bus.BA.next = 0

            yield system.CLK.posedge

            bus.CS_B.next = 1
            bus.CAS_B.next = 1
            bus.A.next = ~0 & mask(bus.A)
            bus.BA.next = ~0 & mask(bus.BA)

            addr.next = 0
            if addr != n - 1:
                addr.next = addr + 4

            yield system.CLK.posedge

            bus.CS_B.next = 0
            bus.CAS_B.next = 0
            bus.A.next = addr

            yield system.CLK.posedge

            bus.CS_B.next = 1
            bus.CAS_B.next = 1
            bus.A.next = ~0 & mask(bus.A)

            addr.next = 0
            if addr != n - 1:
                addr.next = addr + 4

            yield delay(interval - 1)
开发者ID:trigrass2,项目名称:sds7102,代码行数:55,代码来源:test_ddr.py

示例11: test

 def test(B, G):
     w = len(B)
     G_Z = Signal(intbv(0)[w:])
     B.next = intbv(0)
     yield delay(10)
     for i in range(1, 2**w):
         G_Z.next = G
         B.next = intbv(i)
         yield delay(10)
         diffcode = bin(G ^ G_Z)
         self.assertEqual(diffcode.count('1'), 1)
开发者ID:StudentESE,项目名称:myhdl,代码行数:11,代码来源:test_gray_properties.py

示例12: stimulus

        def stimulus():
            N = Signal(intbv(0)[32:])

            yield bus.reset()
            # Send a clear
            yield whitebox_clear(bus)

            # Check the fifo flags
            yield bus.receive(WE_STATUS_ADDR)
            assert bus.rdata & WES_SPACE
            assert not (bus.rdata & WES_DATA)

            yield bus.transmit(WE_THRESHOLD_ADDR,
                concat(intbv(1)[16:], intbv(3)[16:]))
            yield bus.receive(WE_THRESHOLD_ADDR)
            assert bus.rdata == concat(intbv(1)[16:], intbv(3)[16:])

            yield bus.transmit(WE_INTERP_ADDR, INTERP)
            yield bus.receive(WE_INTERP_ADDR)
            assert bus.rdata == INTERP

            ## Insert samples until overrun
            yield bus.receive(WE_RUNS_ADDR)
            while not (bus.rdata & 0x0000ffff):
                x = intbv(int(sin(1000 * (2 * pi) * N / 50000) * 2**15), min=-2**15, max=2**15)[16:]
                yield bus.transmit(WE_SAMPLE_ADDR, concat(x, x))
                N.next = N + 1
                yield bus.receive(WE_RUNS_ADDR)

            # Check that we're full
            yield bus.receive(WE_STATUS_ADDR)
            assert not (bus.rdata & WES_SPACE)
            assert bus.rdata & WES_DATA

            ## Now start transmitting
            yield bus.transmit(WE_STATUS_ADDR, WES_TXEN)
            yield bus.receive(WE_STATUS_ADDR)
            assert bus.rdata & WES_TXEN

            ## Wait until underrun
            yield bus.receive(WE_RUNS_ADDR)
            while not (bus.rdata & 0xffff0000):
                yield bus.delay(1000)
                yield bus.receive(WE_RUNS_ADDR)

            ## Make sure we're both over and underrun
            assert bus.rdata & 0xffff0000 and bus.rdata & 0x0000ffff

            # Check the fifo flags
            yield bus.receive(WE_STATUS_ADDR)
            assert bus.rdata & WES_SPACE
            assert not (bus.rdata & WES_DATA)

            raise StopSimulation
开发者ID:n8ohu,项目名称:whitebox,代码行数:54,代码来源:test_whitebox.py

示例13: assign_config

def assign_config(sig, val):
    """
    Arguments:
        sig (Signal): The signals to be assigned to a constant value
        val (int): The constant value
    """
    keep = Signal(bool(0))
    keep.driven = 'wire'

    @always_comb
    def beh_assign():
        sig.next = val if keep else val
    return beh_assign
开发者ID:Godtec,项目名称:rhea,代码行数:13,代码来源:cso.py

示例14: get_signed_intbv_rand_signal

def get_signed_intbv_rand_signal(width, val_range=None, init_value=0):
    '''Create a signed intbv random signal.
    '''
    if val_range is not None:
        min_val = val_range[0]
        max_val = val_range[1]
    else:
        min_val = -(2**(width - 1) - 1)
        max_val = 2**(width - 1)

    signal = Signal(intbv(init_value, min=min_val, max=max_val))
    signal.val[:] = randrange(min_val, max_val)

    return signal, min_val, max_val
开发者ID:hgomersall,项目名称:Ovenbird,代码行数:14,代码来源:base_hdl_test.py

示例15: testSignalBoolBounds

 def testSignalBoolBounds(self):
     if type(bool) is not type: # bool not a type in 2.2
         return
     s = Signal(bool())
     s.next = 1
     s.next = 0
     for v in (-1, -8, 2, 5):
         try:
             s.next = v
             #s._update()
             #s.val
         except ValueError:
             pass
         else:
             self.fail()
开发者ID:Cadavis8,项目名称:myhdl,代码行数:15,代码来源:test_Signal.py


注:本文中的myhdl.Signal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。