• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python myhdl.intbv函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: gen_internal

    def gen_internal(self):
        self.cur_count = Signal(intbv(0, 0, self.count + 1))
        self.cur_skip = Signal(intbv(0, 0, self.skip + 1))

        self.new_count = Signal(intbv(0, 0, self.count + 1))
        self.new_skip = Signal(intbv(0, 0, self.skip + 1))

        @always_comb
        def comb():
            self.new_count.next = self.cur_count
            self.new_skip.next = self.cur_skip

            if self.cur_skip != 0:
                self.new_skip.next = self.cur_skip - 1

            elif self.cur_count != self.count:
                if self.strobe:
                    self.new_count.next = self.cur_count + 1
                    self.new_skip.next = self.skip

        @always_seq(self.clk.posedge, self.rst)
        def seq():
            self.cur_count.next = self.new_count
            self.cur_skip.next = self.new_skip

        @always_comb
        def busy_comb():
            self.busy.next = 1
            if self.new_count != self.count and self.new_skip == 0:
                self.busy.next = 0

        return instances()
开发者ID:wingel,项目名称:sds7102,代码行数:32,代码来源:dummy.py


示例2: __init__

    def __init__(self, size=16, width=8):
        """
        """
        self.name = "fifobus{0}".format(_fb_num)

        # @todo: add write clock and read clock to the interface!
        # @todo: use longer names read, read_valid, read_data,
        # @todo: write, write_data, etc.!

        # all the data signals are from the perspective
        # of the FIFO being interfaced to.        
        self.clear = Signal(bool(0))           # fifo clear
        #self.wclk = None                      # write side clock
        self.wr = Signal(bool(0))              # write strobe to fifo
        self.wdata = Signal(intbv(0)[width:])  # fifo data in

        #self.rclk = None                      # read side clock
        self.rd = Signal(bool(0))              # fifo read strobe
        self.rdata = Signal(intbv(0)[width:])  # fifo data out
        self.rvld = Signal(bool(0))
        self.empty = Signal(bool(1))           # fifo empty
        self.full = Signal(bool(0))            # fifo full
        self.count = Signal(intbv(0, min=0, max=size+1))

        self.width = width
        self.size = size

        _add_bus(self, self.name)
开发者ID:asterbini,项目名称:rhea,代码行数:28,代码来源:fifobus.py


示例3: led_peripheral

def led_peripheral(glbl, regbus, leds, base_address=0x8240):
    """ LED memory-map peripheral
    This (rather silly) core will select different LED
    displays based on the memory-mapped select register.
    """

    ndrv = 3  # the number of different drivers
    regfile.base_address = base_address 
    
    clock, reset = glbl.clock, glbl.reset
    rleds = Signal(intbv(0)[len(leds):])

    # assign the LED port to the local register
    assign(leds, rleds)

    # memory-mapped registers
    greg = regbus.add(regfile, 'led')

    # led bus from each driver
    dled = Signals(intbv(0)[len(leds):0], ndrv)

    # instantiate different LED drivers
    led_insts = [None for _ in range(ndrv)]
    led_insts[0] = led_stroby(clock, reset, dled[0])
    led_insts[1] = led_count(clock, reset, dled[1])
    led_insts[2] = led_dance(clock, reset, dled[2])

    @always_seq(clock.posedge, reset=reset)
    def beh():
        for ii in range(ndrv):
            idx = regfile.select
            rleds.next = dled[idx-1]

    return myhdl.instances()
开发者ID:FelixVi,项目名称:rhea,代码行数:34,代码来源:led_mm_per.py


示例4: __init__

 def __init__(self, nbits=8):
     """member variables initialize"""
     self.nbits = nbits
     self.red = Signal(intbv(0)[nbits:])
     self.green = Signal(intbv(0)[nbits:])
     self.blue = Signal(intbv(0)[nbits:])
     self.data_valid = Signal(bool(0))
开发者ID:Vikram9866,项目名称:test_jpeg,代码行数:7,代码来源:interfaces.py


示例5: uartRx

def uartRx(CLK, RST_X, RXD, DOUT, EN):

    # reg
    stage = myhdl.Signal(myhdl.intbv(0)[4:])
    cnt = myhdl.Signal(myhdl.intbv(0)[21:])                  # counter to latch D0, D1, ..., D7
    cnt_detect_startbit = myhdl.Signal(myhdl.intbv(0)[20:])  # counter to detect the Start Bit

    @myhdl.always_comb
    def assign():
        EN.next = (stage == SS_SER_DONE)

    @myhdl.always(CLK.posedge)
    def detect_startbit():
        if not RST_X:
            cnt_detect_startbit.next = 0
        else:
            cnt_detect_startbit.next = 0 if (RXD) else cnt_detect_startbit + 1

    @myhdl.always(CLK.posedge)
    def main_proc():
        if not RST_X:
            stage.next = SS_SER_WAIT
            cnt.next = 1
            DOUT.next = 0
        elif (stage == SS_SER_WAIT):
            stage.next = SS_SER_RCV0 if (cnt_detect_startbit == (SERIAL_WCNT >> 1)) else stage
        else:
            if (cnt != SERIAL_WCNT):
                cnt.next = cnt + 1
            else:
                stage.next = SS_SER_WAIT if (stage == SS_SER_DONE) else stage + 1
                DOUT.next = myhdl.ConcatSignal(RXD, DOUT[8:1])
                cnt.next = 1

    return assign, detect_startbit, main_proc
开发者ID:monotone-RK,项目名称:MyHDL-samples,代码行数:35,代码来源:uart.py


示例6: __init__

    def __init__(self, data_width=32,  address_width=4, response_width=2):
        self.data_width = data_width
        self.address_width = address_width
        self.response_width = response_width
        # currently top-level port interfaces can't contain multiple
        # levels (nested).  This will be enhanced in the future.

        self.awvalid = Signal(bool(0))
        self.awdata = Signal(intbv(15)[address_width:])
        self.awaccept = Signal(bool(1))

        self.wvalid = Signal(bool(0))
        self.wdata = Signal(intbv(0xE6)[data_width:])
        self.waccept = Signal(bool(1))

        self.arvalid = Signal(bool(0))
        self.ardata = Signal(intbv(15)[address_width:])
        self.araccept = Signal(bool(1))

        self.rvalid = Signal(bool(0))
        self.rdata = Signal(intbv(0xE8)[data_width:])
        self.raccept = Signal(bool(1))

        self.bvalid = Signal(bool(0))
        self.bdata = Signal(intbv(3)[response_width:])
        self.baccept = Signal(bool(1))
开发者ID:gbin,项目名称:rhea,代码行数:26,代码来源:axi4st.py


示例7: op_add_sub

    def op_add_sub():

        if __debug__:
            if debug:
                print("inside alu", acc, opd)
        if dec.add_sub == 0:
            res_arith.next = intbv(acc + opd)[16:]
            if __debug__:
                if debug:
                    print(res_arith.next, acc + opd, acc, opd)
        else:
            res_arith.next = intbv(acc - opd)[16:]

    # for the logical operations
    # @always_comb
    # def op_logical():

        if alu_op == alu_op_type.LD:
            # LOAD
            res_log.next = opd

        elif alu_op == alu_op_type.AND:
            # AND
            res_log.next = acc & opd

        elif alu_op == alu_op_type.OR:
            # OR
            res_log.next = acc | opd

        elif alu_op == alu_op_type.XOR:
            # XOR
            res_log.next = acc ^ opd
开发者ID:forumulator,项目名称:pyLeros,代码行数:32,代码来源:alu.py


示例8: gen

    def gen(self):
        idx = Signal(intbv(0, 0, self.parts))

        insts = []

        rd_parts = []
        for i in range(self.parts):
            s = Signal(intbv(0)[self.data_width:])
            insts.append(self.extract(s, i))
            rd_parts.append(s)

        @always_comb
        def comb():
            self.parent.RD.next = 0
            self.RD_DATA.next = rd_parts[idx]
            self.RD_EMPTY.next = self.parent.RD_EMPTY

            if self.RD and idx == self.parts - 1:
                self.parent.RD.next = 1

        @always_seq(self.RD_CLK.posedge, self.RD_RST)
        def seq():
            if self.RD:
                idx.next = 0
                if idx != self.parts - 1:
                    idx.next = idx + 1

        return instances()
开发者ID:wingel,项目名称:sds7102,代码行数:28,代码来源:interleaver.py


示例9: convert

def convert():
    clock = Signal(bool(0))
    addr = Signal(intbv(0)[8:])
    datao = Signal(intbv(0)[16:])
    inst = romr(addr, clock, datao)
    inst.convert(hdl='Verilog', name='ROMR',
                 directory='output_files', testbench=False)
开发者ID:ravijain056,项目名称:test_jpeg,代码行数:7,代码来源:romr.py


示例10: serial_adder

def serial_adder(R, load_en, clk, add_carry):
    '''
    adds the two numbers given in R and stores the sum in
    the lower significant half of R
    :param R: Two numbers of equal bit vector length
    :param load_en: when equal to 1 it parallel loads the value in R to the two internal shift registers
    :param clk:
    :param add_carry: will contain the final carry bit after adding the msbs
    '''
    out1 = Signal(intbv(0)[len(R)/2:])
    parallelin1 = R[len(R):len(R)/2]
    out2 = Signal(intbv(0)[len(R)/2:])
    parallelin2 = R[len(R)/2:]
    sum, cin, cout, inp1, inp2, a, b = [Signal(intbv(0)) for i in range(7)]
    shift1 = shift_reg(inp1, out1, clk, parallelin1, load_en)    #contains first number
    shift2 = shift_reg(inp2,out2,clk,parallelin2, load_en)       #contains second number initially and final result at the end of simulation
    adder = full_adder(a, b, cin, sum, cout, clk)
    @always_comb
    def connect():
        inp1.next = intbv(out1[0])[1:]
        inp2.next = sum
        a.next = intbv(out1[0])[1:]
        b.next = intbv(out2[0])[1:]
        add_carry.next = cout
    return connect, shift1, shift2, adder
开发者ID:srivatsan-ramesh,项目名称:MyHDL-Example,代码行数:25,代码来源:serial_adder.py


示例11: mux_test

    def mux_test():

        sel    = Signal(bool(0))
        q      = Signal(intbv(0))
        a      = Signal(intbv(0))
        b      = Signal(intbv(0))

        mux = mux2(q, a, b, sel)

        DELAY = delay(PERIOD // 2)

        @instance
        def stimulus():
            for step in range(STEPS):
                print "STEP %02d:" % step,

                a.next = step
                b.next = step << 8

                if step % 2 == 0:
                    sel.next = not sel

                yield DELAY
                print "%d q %s a %s b %s" % (sel, bin(q, 16), bin(a, 16), bin(b, 16))
                if sel % 2 == 0:
                    assert q == a
                else:
                    assert q == b

            raise StopSimulation

        return mux, stimulus
开发者ID:seletz,项目名称:myhdl-test,代码行数:32,代码来源:test_mux2.py


示例12: convert

def convert():
    q = Signal(intbv(0)[1:0])
    d = Signal(intbv(0)[1:0])
    wr, rst = [Signal(bool(0)) for i in range(2)]

    toVerilog(dff, q, d, wr, rst)
    toVHDL(dff, q, d, wr, rst)
开发者ID:mpflaga,项目名称:ReadWriteFlipFlop.myhdl,代码行数:7,代码来源:dff.py


示例13: __init__

 def __init__(self, color_space=(8, 8, 8)):
     """An red-green-blue interface """
     assert len(color_space) == 3
     rbits, gbits, bbits = color_space
     self.red = Signal(intbv(0)[rbits:0])
     self.green = Signal(intbv(0)[gbits:0])
     self.blue = Signal(intbv(0)[rbits:0])
开发者ID:Vikram9866,项目名称:test_jpeg,代码行数:7,代码来源:interfaces.py


示例14: icestick_blinky_host

def icestick_blinky_host(clock, led, pmod, uart_tx, uart_rx, uart_dtr, uart_rts):
    """
    This example is similar to the other examples in this directory but
    the LEDs are controlled externally via command packets sent from a
    host via the UART on the icestick.

    Ports:
      clock:
      led:
      pmod:
      uart_tx:
      uart_rx:
    """

    glbl = Global(clock, None)
    ledreg = Signal(intbv(0)[8:])

    # create the timer tick instance
    tick_inst = glbl_timer_ticks(glbl, include_seconds=True)

    # create the interfaces to the UART
    fbustx = FIFOBus(width=8, size=4)
    fbusrx = FIFOBus(width=8, size=4)

    # create the memmap (CSR) interface
    memmap = Barebone(glbl, data_width=32, address_width=32)

    # create the UART instance.
    uart_inst = uartlite(glbl, fbustx, fbusrx, uart_rx, uart_tx)

    # create the packet command instance
    cmd_inst = memmap_command_bridge(glbl, fbusrx, fbustx, memmap)

    @always_seq(clock.posedge, reset=None)
    def beh_led_control():
        memmap.done.next = not (memmap.write or memmap.read)
        if memmap.write and memmap.mem_addr == 0x20:
            ledreg.next = memmap.write_data

    @always_comb
    def beh_led_read():
        if memmap.read and memmap.mem_addr == 0x20:
            memmap.read_data.next = ledreg
        else:
            memmap.read_data.next = 0

    # blink one of the LEDs
    tone = Signal(intbv(0)[8:])

    @always_seq(clock.posedge, reset=None)
    def beh_assign():
        if glbl.tick_sec:
            tone.next = (~tone) & 0x1
        led.next = ledreg | tone[5:]

        pmod.next = 0

    # @todo: PMOD OLED memmap control

    return (tick_inst, uart_inst, cmd_inst, beh_led_control, beh_led_read, beh_assign)
开发者ID:asterbini,项目名称:rhea,代码行数:60,代码来源:icestick_blinky_host.py


示例15: emit_connect

def emit_connect():
    from myhdl import toVerilog

    bus = DdrBus(2, 12, 2)
    rename_interface(bus, 'bus')

    soc_clk = Signal(False)
    soc_clk_b = Signal(False)

    soc_cs = Signal(False)
    soc_ras = Signal(False)
    soc_cas = Signal(False)
    soc_we = Signal(False)
    soc_ba = Signal(False)
    soc_a = Signal(False)

    soc_dqs = Signal(intbv(0)[bus.d_width:])
    soc_dm = Signal(intbv(0)[bus.d_width:])
    soc_dq = Signal(intbv(0)[bus.d_width * 8:])

    toVerilog(ddr_connect, bus, soc_clk, soc_clk_b, None,
              soc_cs, soc_ras, soc_cas, soc_we, soc_ba, soc_a,
              soc_dqs, soc_dm, soc_dq)

    print
    print open('ddr_connect.v', 'r').read()
开发者ID:trigrass2,项目名称:sds7102,代码行数:26,代码来源:test_ddr.py


示例16: __init__

    def __init__(self, name, signed, **kwargs):
        self.name = name
        self.signed = signed

        if 'bits' in kwargs:
            bits = self.bits = kwargs['bits']
            if signed:
                Q = 2**(bits-1)
                self.min = -Q
                self.max = Q
            else:
                Q = 2**bits
                self.min = 0
                self.max = Q

        elif 'min' in kwargs and 'max' in kwargs:
            self.min = kwargs['min']
            self.max = kwargs['max']
            self.bits = len(self.myhdl(0))

        else:
            raise AttributeError, "Must give bits or min & max"

        self.valid = kwargs.get('valid', Signal(bool(0)))
        self.last = kwargs.get('last', Signal(bool(0)))
        self.i = kwargs.get('i', Signal(intbv(0, min=self.min, max=self.max)))
        self.q = kwargs.get('q', Signal(intbv(0, min=self.min, max=self.max)))
开发者ID:n8ohu,项目名称:whitebox,代码行数:27,代码来源:dsp.py


示例17: SquareGenerator

def SquareGenerator(freq, duty, dout, clk, reset):

    # freq.max = FS / 2
    # freq.min = 0Hz

    M = len(freq)       # Bits
    CLK_MULT = FS_MODE * CLK_FREQ
    HALF_HZ_CYCLES = CLK_MULT * FS
    extra_bits = log(CLK_MULT, 2)

    assert M > extra_bits

    count = Signal(intbv(0, _nrbits=M + extra_bits))
    count_max = Signal(intbv(0, _nrbits=M + extra_bits))

    @always(clk.posedge)
    def set_freq():
        count_max.next = ((freq << (extra_bits - M)) + CLK_MULT) << (freq // M)

    @always(clk.posedge)
    def counting():
        if count < count_max - 1:
            count.next += 1
        else:
            count.next = 0
            dout.next = not dout

    return set_freq, counting
开发者ID:scryver,项目名称:fpga,代码行数:28,代码来源:square.py


示例18: testSliceAssign

 def testSliceAssign(self):
     s = Signal(intbv(min=-24, max=34))
     for i in (-24, -2, 13, 33):
         for k in (6, 9, 10):
             s.next[:] = 0
             s.next[k:] = i
             self.assertEqual(s.next, i)
     for i in (-25, -128, 34, 35, 229):
         for k in (0, 9, 10):
             try:
                 s.next[k:] = i
                 # s._update()
             except ValueError:
                 pass
             else:
                 self.fail()
     s = Signal(intbv(5)[8:])
     for v in (0, 2**8-1, 100):
         s.next[:] = v
     for v in (-1, 2**8, -10, 1000):
         try:
             s.next[:] = v
             # s._update()
         except ValueError:
             pass
         else:
             self.fail()
开发者ID:Cadavis8,项目名称:myhdl,代码行数:27,代码来源:test_Signal.py


示例19: c_testbench_three

def c_testbench_three():
    """
    this will test the use of constants in an inteface
    as well as top-level interface conversion.
    """
    clock = Signal(bool(0))
    reset = ResetSignal(0, active=0, isasync=True)
    x = Signal(intbv(3, min=-5000, max=5000))
    y = Signal(intbv(4, min=-200, max=200))
    intf = IntfWithConstant2()

    tbdut = top_const(clock, reset, x, y, intf)
    
    @instance
    def tbclk():
        clock.next = False
        while True:
            yield delay(3)
            clock.next = not clock
        
    @instance
    def tbstim():
        reset.next = reset.active
        yield delay(33)
        reset.next = not reset.active
        yield clock.posedge
        yield clock.posedge
        print("x: %d" % (x,))
        print("y: %d" % (y,))
        assert x == 0
        assert y == 0
        raise StopSimulation

    return tbdut, tbclk, tbstim
开发者ID:cpeppenster,项目名称:myhdl,代码行数:34,代码来源:test_interfaces3.py


示例20: __init__

    def __init__(self, clock, aux_depth=(4, 4, 4)):

        """

         This interface is the internal interface modeled after
         the xapp495 internal audio interface

         Args:
             clock: pixel clock.
             aux_depth (optional): The bus width of the aux interface
                                          Default value: (4, 4, 4)

        Usage:
            aux_interface = AuxInterface()

        """

        self.clock = clock
        self.aux_depth = aux_depth

        # AUX data from audio source
        self.aux0 = Signal(intbv(0)[aux_depth[0]:])
        self.aux1 = Signal(intbv(0)[aux_depth[1]:])
        self.aux2 = Signal(intbv(0)[aux_depth[2]:])

        # Audio data enable
        self.ade = Signal(bool(0))
开发者ID:forumulator,项目名称:HDMI-Source-Sink-Modules,代码行数:27,代码来源:aux_interface.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python myhdl.join函数代码示例发布时间:2022-05-27
下一篇:
Python myhdl.instances函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap