1 from migen
.fhdl
.structure
import *
2 from migen
.fhdl
import tools
, verilog
, autofragment
3 from migen
.bus
import wishbone
, csr
, wishbone2csr
5 from milkymist
import m1reset
, clkfx
, lm32
, norflash
, uart
, sram
11 sram_size
= 4096 # in bytes
13 clkfx_sys
= clkfx
.ClkFX(50*MHz
, clk_freq
)
14 reset0
= m1reset
.M1Reset()
17 norflash0
= norflash
.NorFlash(25, 12)
18 sram0
= sram
.SRAM(sram_size
//4)
19 wishbone2csr0
= wishbone2csr
.WB2CSR()
21 # norflash 0x00000000 (shadow @0x80000000)
22 # SRAM/debug 0x10000000 (shadow @0x90000000)
23 # USB 0x20000000 (shadow @0xa0000000)
24 # Ethernet 0x30000000 (shadow @0xb0000000)
25 # SDRAM 0x40000000 (shadow @0xc0000000)
26 # CSR bridge 0x60000000 (shadow @0xe0000000)
27 wishbonecon0
= wishbone
.InterconnectShared(
32 (binc("000"), norflash0
.bus
),
33 (binc("001"), sram0
.bus
),
34 (binc("11"), wishbone2csr0
.wishbone
)
39 uart0
= uart
.UART(0, clk_freq
, baud
=115200)
40 csrcon0
= csr
.Interconnect(wishbone2csr0
.csr
, [uart0
.bank
.interface
])
42 interrupts
= Fragment([
43 cpu0
.interrupt
[0].eq(uart0
.events
.irq
)
46 frag
= autofragment
.from_local() + interrupts
47 src_verilog
, vns
= verilog
.convert(frag
,
48 {clkfx_sys
.clkin
, reset0
.trigger_reset
},
50 clk_signal
=clkfx_sys
.clkout
,
51 rst_signal
=reset0
.sys_rst
,
53 src_ucf
= constraints
.get(vns
, clkfx_sys
, reset0
, norflash0
, uart0
)
54 return (src_verilog
, src_ucf
)