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

Python myhdl.toVerilog函数代码示例

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

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



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

示例1: main

def main():
    #sim = Simulation(testBench())
    #sim.run()
    pc_adder_in, data1_in, data2_in, address32_in, jumpaddr_in = [Signal(intbv(random.randint(-255, 255), min=-(2 ** 31), max=2 ** 31 - 1)) for i in range(5)]
    pc_adder_out, data1_out, data2_out, address32_out, branch_addr32_out, jumpaddr_out = [Signal(intbv(0, min=-(2 ** 31), max=2 ** 31 - 1)) for i in range(6)]

    rs_in, rd_in, rt_in, rd_out, rt_out, rs_out, shamt_in, shamt_out = [Signal(intbv(0)[5:]) for i in range(8)]
    func_in, func_out = [Signal(intbv(0)[6:]) for i in range(2)]

    RegDst_in, ALUop_in, ALUSrc_in = [Signal(intbv(0)[1:]) for i in range(3)]
    Branch_in, Jump_in, MemRead_in, MemWrite_in = [Signal(intbv(0)[1:]) for i in range(4)]
    RegWrite_in, MemtoReg_in = [Signal(intbv(0)[1:]) for i in range(2)]

    RegDst_out, ALUop_out, ALUSrc_out = [Signal(intbv(0)[1:]) for i in range(3)]
    Branch_out, Jump_out, MemRead_out, MemWrite_out = [Signal(intbv(0)[1:]) for i in range(4)]
    RegWrite_out, MemtoReg_out = [Signal(intbv(0)[1:]) for i in range(2)]

    clk = Signal(intbv(0)[1:])
    rst = Signal(intbv(0)[1:])

    toVerilog(latch_id_ex, clk, rst,
            pc_adder_in,
            data1_in, data2_in, address32_in, jumpaddr_in,
            rs_in, rt_in, rd_in, shamt_in, func_in,
            RegDst_in, ALUop_in, ALUSrc_in,  # signals to EX pipeline stage
            Branch_in, Jump_in, MemRead_in, MemWrite_in,  # signals to MEM pipeline stage
            RegWrite_in, MemtoReg_in,  # signals to WB pipeline stage
            pc_adder_out,
            data1_out, data2_out, address32_out, branch_addr32_out, jumpaddr_out,
            rs_out, rt_out, rd_out, shamt_out, func_out,
            RegDst_out, ALUop_out, ALUSrc_out,
            Branch_out, Jump_out, MemRead_out, MemWrite_out,
            RegWrite_out, MemtoReg_out)
开发者ID:bigeagle,项目名称:pymips,代码行数:33,代码来源:latch_id_ex.py


示例2: convert_to_verilog

def convert_to_verilog(args):
    clk          = Signal(False)
    rst          = Signal(False)
    imem_addr_o  = Signal(modbv(0)[32:])
    imem_dat_o   = Signal(modbv(0)[32:])
    imem_sel_o   = Signal(modbv(0)[4:])
    imem_cyc_o   = Signal(False)
    imem_we_o    = Signal(False)
    imem_stb_o   = Signal(False)
    imem_dat_i   = Signal(modbv(0)[32:])
    imem_ack_i   = Signal(False)
    imem_err_i   = Signal(False)
    dmem_addr_o  = Signal(modbv(0)[32:])
    dmem_dat_o   = Signal(modbv(0)[32:])
    dmem_sel_o   = Signal(modbv(0)[4:])
    dmem_cyc_o   = Signal(False)
    dmem_we_o    = Signal(False)
    dmem_stb_o   = Signal(False)
    dmem_dat_i   = Signal(modbv(0)[32:])
    dmem_ack_i   = Signal(False)
    dmem_err_i   = Signal(False)
    toHost       = Signal(modbv(0)[32:])

    toVerilog(CoreHDL, clk, rst, toHost, imem_addr_o, imem_dat_o, imem_sel_o, imem_cyc_o, imem_we_o,
              imem_stb_o, imem_dat_i, imem_ack_i, imem_err_i, dmem_addr_o, dmem_dat_o, dmem_sel_o,
              dmem_cyc_o, dmem_we_o, dmem_stb_o, dmem_dat_i, dmem_ack_i, dmem_err_i)
开发者ID:AngelTerrones,项目名称:Algol,代码行数:26,代码来源:run.py


示例3: 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


示例4: _getCosimulation

    def _getCosimulation(self, func, **kwargs):
        ''' Returns a co-simulation instance of func. 
            Uses the _simulator specified by self._simulator. 
            Enables traces if self._trace is True
                func - MyHDL function to be simulated
                kwargs - dict of func interface assignments: for signals and parameters
        '''
        vals = {}
        vals['topname'] = func.func_name
        vals['unitname'] = func.func_name.lower()
        hdlsim = self._simulator
        if not hdlsim:
            raise ValueError("No _simulator specified")
        if not self.sim_reg.has_key(hdlsim):
            raise ValueError("Simulator {} is not registered".format(hdlsim))

        hdl, analyze_cmd, elaborate_cmd, simulate_cmd = self.sim_reg[hdlsim]

        # Convert to HDL
        if hdl == "verilog":
            toVerilog(func, **kwargs)
            if self._trace:
                self._enableTracesVerilog("./tb_{topname}.v".format(**vals))
        elif hdl == "vhdl":
            toVHDL(func, **kwargs)

        # Analyze HDL
        os.system(analyze_cmd.format(**vals))
        # Elaborate
        if elaborate_cmd:
            os.system(elaborate_cmd.format(**vals))
        # Simulate
        return Cosimulation(simulate_cmd.format(**vals), **kwargs)
开发者ID:nkavaldj,项目名称:myhdl_lib,代码行数:33,代码来源:_DUTer.py


示例5: main

def main():
    #sim = Simulation(testBench())
    #sim.run()
    branch_adder_in, alu_result_in, data2_in, wr_reg_in = [Signal(intbv(random.randint(-255, 255), min=-(2 ** 31), max=2 ** 31 - 1)) for i in range(4)]
    branch_adder_out, alu_result_out, data2_out, wr_reg_out = [Signal(intbv(0, min=-(2 ** 31), max=2 ** 31 - 1)) for i in range(4)]

    zero_in, zero_out = [Signal(intbv(0)[1:]) for i in range(2)]

    Branch_in, MemRead_in, MemWrite_in = [Signal(intbv(0)[1:]) for i in range(3)]
    RegWrite_in, MemtoReg_in = [Signal(intbv(0)[1:]) for i in range(2)]

    Branch_out, MemRead_out, MemWrite_out = [Signal(intbv(0)[1:]) for i in range(3)]
    RegWrite_out, MemtoReg_out = [Signal(intbv(0)[1:]) for i in range(2)]

    clk = Signal(intbv(0)[1:])
    rst = Signal(intbv(0)[1:])


    toVerilog(latch_ex_mem, clk, rst,
                        branch_adder_in,
                        alu_result_in,
                        data2_in, wr_reg_in,
                        MemRead_in, MemWrite_in,  # signals to MEM pipeline stage
                        RegWrite_in, MemtoReg_in,  # signals to WB pipeline stage
                        branch_adder_out,
                        alu_result_out,
                        data2_out, wr_reg_out,
                        MemRead_out, MemWrite_out,
                        RegWrite_out, MemtoReg_out,
                        )
开发者ID:bigeagle,项目名称:pymips,代码行数:30,代码来源:latch_ex_mem.py


示例6: 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


示例7: testbench_streamer

def testbench_streamer(args=None):

    args = tb_default_args(args)
    if not hasattr(args, 'keep'):
        args.keep = False
    if not hasattr(args, 'bustype'):
        args.bustype = 'barebone'

    clock = Clock(0, frequency=100e6)
    reset = Reset(0, active=1, async=False)
    glbl = Global(clock, reset)

    # @todo: support all stream types ...
    upstream = AXI4StreamLitePort(data_width=32)
    downstream = AXI4StreamLitePort(data_width=32)

    def _bench_streamer():
        tbdut = streamer_top(clock, reset, upstream, downstream, keep=args.keep)
        tbclk = clock.gen()

        dataout = []

        @instance
        def tbstim():
            yield reset.pulse(42)
            downstream.awaccept.next = True
            downstream.waccept.next = True
            data = [randint(0, (2**32)-1) for _ in range(10)]
            for dd in data:
                upstream.awvalid.next = True
                upstream.awdata.next = 0xA
                upstream.wvalid.next = True
                upstream.wdata.next = dd
                yield clock.posedge
            upstream.awvalid.next = False
            upstream.wvalid.next = False

            # @todo: wait the appropriate delay given the number of
            # @todo: streaming registers
            yield delay(100)
            print(data)
            print(dataout)
            assert False not in [di == do for di, do in zip(data, dataout)]
            raise StopSimulation

        @always(clock.posedge)
        def tbcap():
            if downstream.wvalid:
                dataout.append(int(downstream.wdata))

        return tbdut, tbclk, tbstim, tbcap

    run_testbench(_bench_streamer, args=args)

    myhdl.toVerilog.name = "{}".format(streamer_top.__name__)
    if args.keep:
        myhdl.toVerilog.name += '_keep'
    myhdl.toVerilog.directory = 'output'
    myhdl.toVerilog(streamer_top, clock, reset, upstream, downstream)
开发者ID:Godtec,项目名称:rhea,代码行数:59,代码来源:test_streamers.py


示例8: main

def main():
    control = Signal(alu_code.MAND)
    op1 = Signal(intbv(0, min=-(2 ** 31), max=2 ** 31 - 1))
    op2 = Signal(intbv(0, min=-(2 ** 31), max=2 ** 31 - 1))
    out = Signal(intbv(0, min=-(2 ** 31), max=2 ** 31 - 1))
    zero = Signal(bool(False))
    positive = Signal(bool(False))
    toVerilog(ALU, control, op1, op2, out, zero, positive)
开发者ID:bigeagle,项目名称:pymips,代码行数:8,代码来源:alu.py


示例9: main

def main():
    #unittest.main()

    Rt_ex, Rs_id, Rt_id = [Signal(intbv(0)[5:]) for i in range(3)]

    MemRead_ex, Stall = [Signal(intbv(0)[1:]) for i in range(2)]

    toVerilog(hazard_detector, MemRead_ex, Rt_ex, Rs_id, Rt_id, Stall)
开发者ID:bigeagle,项目名称:pymips,代码行数:8,代码来源:hazard_detector.py


示例10: main

def main():
    #sim = Simulation(testBench())
    #sim.run()
    i_in, pc_in, i_out, pc_out = [Signal(intbv(0)[32:]) for i in range(4)]

    clk, rst, stall = [Signal(intbv(0)[1:]) for i in range(3)]

    toVerilog(latch_if_id, clk, rst, i_in, pc_in, i_out, pc_out, stall)
开发者ID:bigeagle,项目名称:pymips,代码行数:8,代码来源:latch_if_id.py


示例11: convert

def convert():

    pins = 10
    t = TristateSignal(intbv(1)[pins:])
    dir = Signal(bool(0))
    wr, rst = [Signal(bool(0)) for i in range(2)]

    toVerilog(ReadWriteFlipFlop, t, dir, wr, rst)
    toVHDL(ReadWriteFlipFlop, t, dir, wr, rst)
开发者ID:mpflaga,项目名称:ReadWriteFlipFlop.myhdl,代码行数:9,代码来源:ReadWriteFlipFlop.py


示例12: convert

def convert():
    Clk = myhdl.Signal(bool(0))
#     Reset = myhdl.ResetSignal(0, active=1, async=True)
    Reset = None
    D = myhdl.Signal(myhdl.intbv(0)[WIDTH_D:])
    Q = myhdl.Signal(myhdl.intbv(0)[WIDTH_Q:])

    myhdl.toVHDL(sumbits, Clk, Reset, D, Q)
    myhdl.toVerilog(sumbits, Clk, Reset, D, Q)
开发者ID:josyb,项目名称:recurse,代码行数:9,代码来源:sumbits.py


示例13: main

def main():
    #sim = Simulation(testBench_alu_control())
    #sim = Simulation(testBench())
    #sim.run()
    data_in = Signal(intbv(0, min=-(2 ** 15), max=2 ** 15 - 1))

    data_out = Signal(intbv(0, min=-(2 ** 31), max=2 ** 31 - 1))

    toVerilog(sign_extend, data_in, data_out)
开发者ID:bigeagle,项目名称:pymips,代码行数:9,代码来源:sign_extender.py


示例14: emit

def emit():
    from myhdl import toVerilog

    clk = Clk(50E6)

    toVerilog(test, clk)

    print
    print open('test.v', 'r').read()
开发者ID:wingel,项目名称:sds7102,代码行数:9,代码来源:test_util.py


示例15: emit

def emit():
    from myhdl import toVerilog

    insts, gen, args = setup()

    toVerilog(gen, *args)

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


示例16: main

def main():
    #sim = Simulation(testBench())
    #sim.run(100)
    I0, I1, I2, I3 = [Signal(intbv(random.randint(0, 255))[32:]) for i in range(4)]
    O = Signal(intbv(0)[32:])
    S = Signal(intbv(0, min=0, max=4))

    toVerilog(mux2, S, O, I2, I3)
    toVerilog(mux4, S, O, I0, I1, I2, I3)
开发者ID:bigeagle,项目名称:pymips,代码行数:9,代码来源:mux.py


示例17: convert

def convert(brd, top=None, name=None, use='verilog', path='.'):
    """ Wrapper around the myhdl conversion functions
    This function will use the _fpga objects get_portmap function
    to map the board definition to the 

    Arguments
      top  : top-level myhld module
      brd  : FPGA board definition (_fpga object)
      name : name to use for the generated (converted) file
      use  : User 'verilog' or 'vhdl' for conversion
      path : path of the output files
    """
    assert isinstance(brd, _fpga)

    name = brd.top_name if name is None else name
    pp = brd.get_portmap(top=top)

    # convert with the ports and parameters        
    if use.lower() == 'verilog':
        if name is not None:
            myhdl.toVerilog.name = name
        myhdl.toVerilog(brd.top, **pp)
        brd.name = name
        brd.vfn = "%s.v"%(name)
    elif use.lower() == 'vhdl':
        if name is not None:
            myhdl.toVHDL.name = name
        myhdl.toVHDL(brd.top, **pp)
        brd.name = name
        brd.vfn = "%s.vhd"%(name)
    else:
        raise ValueError("Incorrect conversion target %s"%(use))

    # make sure the working directory exists
    #assert brd.pathexist(brd.path)
    time.sleep(2)

    # copy files etc to the working directory
    tbfn = 'tb_' + brd.vfn
    ver = myhdl.__version__
    # remove special characters from the version
    for sp in ('.', '-', 'dev'):
        ver = ver.replace(sp,'')
    pckfn = 'pck_myhdl_%s.vhd'%(ver)
    for src in (brd.vfn,tbfn,pckfn):
        dst = os.path.join(path, src)
        print('   checking %s'%(dst))
        if os.path.isfile(dst):
            print('   removing %s'%(dst))
            os.remove(dst)
        if os.path.isfile(src):
            print('   moving %s --> %s'%(src, path))
            try:
                shutil.move(src, path)
            except Exception,err:
                print("skipping %s because %s" % (src, err,))
开发者ID:benallard,项目名称:gizflo,代码行数:56,代码来源:_convert.py


示例18: main

def main():
    #sim = Simulation(testBench_alu_control())
    #sim = Simulation(testBench_alu_control())
    #sim.run()
    aluop = Signal(alu_op_code.MNOP)
    control_out = Signal(alu_code.MADD)
    funct_field = Signal(intbv(0)[6:])
    front_sel = Signal(intbv(0)[1:])
    branch = Signal(intbv(0)[1:])
    toVerilog(alu_control, aluop, branch, funct_field, front_sel, control_out)
开发者ID:bigeagle,项目名称:pymips,代码行数:10,代码来源:alu_control.py


示例19: tb_convert

def tb_convert(toplevel, *ports, **params):
    if not os.path.isdir('output/ver/'):
        os.makedirs('output/ver/')
    myhdl.toVerilog.directory = 'output/ver/'
    myhdl.toVerilog(toplevel, *ports, **params)

    if not os.path.isdir('output/vhd/'):
        os.makedirs('output/vhd/')
    myhdl.toVHDL.directory = 'output/vhd/'
    myhdl.toVHDL(toplevel, *ports, **params)
开发者ID:gbin,项目名称:rhea,代码行数:10,代码来源:test_utils.py


示例20: test_ibh

def test_ibh(args=None):
    args = tb_default_args(args)
    numbytes = 13

    clock = Clock(0, frequency=50e6)
    glbl = Global(clock, None)
    led = Signal(intbv(0)[8:])
    pmod = Signal(intbv(0)[8:])
    uart_tx = Signal(bool(0))
    uart_rx = Signal(bool(0))
    uart_dtr = Signal(bool(0))
    uart_rts = Signal(bool(0))
    uartmdl = UARTModel()

    def _bench_ibh():
        tbclk = clock.gen()
        tbmdl = uartmdl.process(glbl, uart_tx, uart_rx)
        tbdut = icestick_blinky_host(clock, led, pmod, 
                                     uart_tx, uart_rx,
                                     uart_dtr, uart_rts)

        @instance
        def tbstim():
            yield delay(1000)
            
            # send a write that should enable all five LEDs
            pkt = CommandPacket(False, address=0x20, vals=[0xFF])
            for bb in pkt.rawbytes:
                uartmdl.write(bb)
            waitticks = int((1/115200.) / 1e-9) * 10 * 28
            yield delay(waitticks) 
            timeout = 100
            yield delay(waitticks) 
            # get the response packet
            for ii in range(PACKET_LENGTH):
                rb = uartmdl.read()
                while rb is None and timeout > 0:
                    yield clock.posedge
                    rb = uartmdl.read()
                    timeout -= 1
                if rb is None:
                    raise TimeoutError

            # the last byte should be the byte written
            assert rb == 0xFF

            yield delay(1000)
            raise StopSimulation

        return tbclk, tbmdl, tbdut, tbstim

    run_testbench(_bench_ibh, args=args)
    myhdl.toVerilog.directory = 'output'
    myhdl.toVerilog(icestick_blinky_host, clock, led, pmod,
                    uart_tx, uart_rx, uart_dtr, uart_rts)
开发者ID:Godtec,项目名称:rhea,代码行数:55,代码来源:test_blinky_host_icestick.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python myhdl.traceSignals函数代码示例发布时间:2022-05-27
下一篇:
Python myhdl.toVHDL函数代码示例发布时间: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