2011-12-16 16:25:26 -05:00
|
|
|
from migen.fhdl.structure import *
|
2012-02-13 17:12:57 -05:00
|
|
|
from migen.fhdl import verilog, autofragment
|
|
|
|
from migen.bus import wishbone, asmibus, wishbone2asmi, 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
|
|
|
|
|
2012-02-13 17:12:57 -05:00
|
|
|
MHz = 1000000
|
|
|
|
clk_freq = 80*MHz
|
|
|
|
sram_size = 4096 # in bytes
|
|
|
|
l2_size = 8192 # in bytes
|
|
|
|
|
2011-12-16 10:02:49 -05:00
|
|
|
def get():
|
2012-02-13 17:12:57 -05:00
|
|
|
#
|
|
|
|
# ASMI
|
|
|
|
#
|
|
|
|
asmihub0 = asmibus.Hub(24, 64, 8) # TODO: get hub from memory controller
|
|
|
|
asmiport_wb = asmihub0.get_port()
|
|
|
|
asmihub0.finalize()
|
2011-12-16 16:25:26 -05:00
|
|
|
|
2012-02-13 17:12:57 -05:00
|
|
|
#
|
|
|
|
# WISHBONE
|
|
|
|
#
|
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-02-13 17:12:57 -05:00
|
|
|
wishbone2asmi0 = wishbone2asmi.WB2ASMI(l2_size//4, asmiport_wb)
|
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)
|
2012-02-13 17:12:57 -05:00
|
|
|
# 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),
|
2012-02-13 17:12:57 -05:00
|
|
|
(binc("10"), wishbone2asmi0.wishbone),
|
2012-02-05 13:54:08 -05:00
|
|
|
(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-02-13 17:12:57 -05:00
|
|
|
#
|
|
|
|
# CSR
|
|
|
|
#
|
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
|
|
|
|
2012-02-13 17:12:57 -05:00
|
|
|
#
|
|
|
|
# Interrupts
|
|
|
|
#
|
2012-02-06 11:45:40 -05:00
|
|
|
interrupts = Fragment([
|
|
|
|
cpu0.interrupt[0].eq(uart0.events.irq)
|
|
|
|
])
|
|
|
|
|
2012-02-13 17:12:57 -05:00
|
|
|
#
|
|
|
|
# Housekeeping
|
|
|
|
#
|
|
|
|
clkfx_sys = clkfx.ClkFX(50*MHz, clk_freq)
|
|
|
|
reset0 = m1reset.M1Reset()
|
|
|
|
|
2012-02-06 11:45:40 -05:00
|
|
|
frag = autofragment.from_local() + interrupts
|
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)
|