2011-12-16 16:25:26 -05:00
|
|
|
from migen.fhdl.structure import *
|
2012-01-13 11:07:46 -05:00
|
|
|
from migen.fhdl import tools, verilog, autofragment
|
2011-12-13 11:33:12 -05:00
|
|
|
from migen.bus import wishbone, csr, wishbone2csr
|
2011-12-16 10:02:49 -05:00
|
|
|
|
2012-01-27 16:09:03 -05:00
|
|
|
from milkymist import m1reset, clkfx, lm32, norflash, uart, sram
|
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
|
2012-01-27 16:09:03 -05:00
|
|
|
sram_size = 4096 # in kilobytes
|
2011-12-17 09:00:18 -05:00
|
|
|
|
2012-01-21 06:25:22 -05:00
|
|
|
clkfx_sys = clkfx.ClkFX(50*MHz, clk_freq)
|
|
|
|
reset0 = m1reset.M1Reset()
|
2011-12-16 16:25:26 -05:00
|
|
|
|
2012-01-21 06:25:22 -05:00
|
|
|
cpu0 = lm32.LM32()
|
|
|
|
norflash0 = norflash.NorFlash(25, 12)
|
2012-01-27 16:09:03 -05:00
|
|
|
sram0 = sram.SRAM(sram_size//4)
|
2012-01-21 06:25:22 -05:00
|
|
|
wishbone2csr0 = wishbone2csr.WB2CSR()
|
2012-02-05 13:54:08 -05:00
|
|
|
|
|
|
|
# norflash 0x00000000 (shadow @0x80000000)
|
|
|
|
# SRAM/debug 0x10000000 (shadow @0x90000000)
|
|
|
|
# USB 0x20000000 (shadow @0xa0000000)
|
|
|
|
# Ethernet 0x30000000 (shadow @0xb0000000)
|
|
|
|
# SDRAM 0x40000000 (shadow @0xc0000000)
|
|
|
|
# CSR bridge 0x60000000 (shadow @0xe0000000)
|
2011-12-13 11:33:12 -05:00
|
|
|
wishbonecon0 = wishbone.InterconnectShared(
|
2012-02-05 13:54:08 -05:00
|
|
|
[
|
|
|
|
cpu0.ibus,
|
|
|
|
cpu0.dbus
|
|
|
|
], [
|
|
|
|
(binc("000"), norflash0.bus),
|
|
|
|
(binc("001"), sram0.bus),
|
|
|
|
(binc("11"), wishbone2csr0.wishbone)
|
|
|
|
],
|
2011-12-13 11:33:12 -05:00
|
|
|
register=True,
|
|
|
|
offset=1)
|
2012-02-05 13:54:08 -05:00
|
|
|
|
2012-01-21 06:25:22 -05:00
|
|
|
uart0 = uart.UART(0, clk_freq, baud=115200)
|
2011-12-17 18:29:37 -05:00
|
|
|
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()
|
2012-01-20 17:00:11 -05:00
|
|
|
src_verilog, vns = verilog.convert(frag,
|
2011-12-17 09:00:18 -05:00
|
|
|
{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,
|
2012-01-20 17:00:11 -05:00
|
|
|
return_ns=True)
|
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)
|