litex/top.py

36 lines
1.0 KiB
Python
Raw Normal View History

2011-12-16 16:25:26 -05:00
from migen.fhdl.structure import *
2011-12-13 11:33:12 -05:00
from migen.fhdl import convtools, verilog, autofragment
from migen.bus import wishbone, csr, wishbone2csr
2011-12-16 10:02:49 -05:00
2011-12-17 09:00:18 -05:00
from milkymist import m1reset, clkfx, lm32, norflash, uart
2011-12-13 11:33:12 -05:00
import constraints
2011-12-16 10:02:49 -05:00
def get():
2011-12-17 09:00:18 -05:00
MHz = 1000000
clk_freq = 80*MHz
clkfx_sys = clkfx.Inst(50*MHz, clk_freq)
2011-12-16 16:25:26 -05:00
reset0 = m1reset.Inst()
2011-12-13 11:33:12 -05:00
cpu0 = lm32.Inst()
norflash0 = norflash.Inst(25, 12)
wishbone2csr0 = wishbone2csr.Inst()
wishbonecon0 = wishbone.InterconnectShared(
[cpu0.ibus, cpu0.dbus],
[(0, norflash0.bus), (3, wishbone2csr0.wishbone)],
register=True,
offset=1)
2011-12-17 09:00:18 -05:00
uart0 = uart.Inst(0, clk_freq, baud=115200)
csrcon0 = csr.Interconnect(wishbone2csr0.csr, [uart0.bank.interface])
2011-12-13 11:33:12 -05:00
2011-12-17 09:00:18 -05:00
frag = autofragment.from_local()
2011-12-13 11:33:12 -05:00
vns = convtools.Namespace()
2011-12-17 09:00:18 -05:00
src_verilog = verilog.Convert(frag,
{clkfx_sys.clkin, reset0.trigger_reset},
name="soc",
clk_signal=clkfx_sys.clkout,
2011-12-16 16:25:26 -05:00
rst_signal=reset0.sys_rst,
ns=vns)
2011-12-17 09:00:18 -05:00
src_ucf = constraints.get(vns, clkfx_sys, reset0, norflash0, uart0)
2011-12-13 11:33:12 -05:00
return (src_verilog, src_ucf)