1
1
from fractions import Fraction
2
+ from math import ceil
2
3
3
4
from migen .fhdl .structure import *
4
5
from migen .fhdl import verilog , autofragment
5
- from migen .bus import wishbone , asmibus , wishbone2asmi , csr , wishbone2csr , dfi
6
+ from migen .bus import wishbone , wishbone2asmi , csr , wishbone2csr , dfi
6
7
7
- from milkymist import m1crg , lm32 , norflash , uart , sram , s6ddrphy , dfii
8
+ from milkymist import m1crg , lm32 , norflash , uart , sram , s6ddrphy , dfii , asmicon
8
9
import constraints
9
10
10
11
MHz = 1000000
11
12
clk_freq = (83 + Fraction (1 , 3 ))* MHz
12
13
sram_size = 4096 # in bytes
13
14
l2_size = 8192 # in bytes
14
15
15
- dfi_a = 13
16
- dfi_ba = 2
17
- dfi_d = 64
16
+ clk_period_ns = 1000000000 / clk_freq
17
+ def ns (t , margin = False ):
18
+ if margin :
19
+ t += clk_period_ns / 2
20
+ return ceil (t / clk_period_ns )
21
+
22
+ sdram_phy = asmicon .PhySettings (
23
+ dfi_a = 13 ,
24
+ dfi_ba = 2 ,
25
+ dfi_d = 64 ,
26
+ nphases = 2 ,
27
+ rdphase = 0 ,
28
+ wrphase = 1
29
+ )
30
+ sdram_geom = asmicon .GeomSettings (
31
+ row_a = 13 ,
32
+ col_a = 10
33
+ )
34
+ sdram_timing = asmicon .TimingSettings (
35
+ tREFI = ns (7800 ),
36
+ tRFC = ns (70 )
37
+ )
18
38
19
39
def ddrphy_clocking (crg , phy ):
20
40
names = [
@@ -31,16 +51,17 @@ def get():
31
51
#
32
52
# ASMI
33
53
#
34
- asmihub0 = asmibus . Hub ( 23 , 128 , 12 ) # TODO: get hub from memory controller
35
- asmiport_wb = asmihub0 .get_port ()
36
- asmihub0 .finalize ()
54
+ asmicon0 = asmicon . ASMIcon ( sdram_phy , sdram_geom , sdram_timing , 8 )
55
+ asmiport_wb = asmicon0 . hub .get_port ()
56
+ asmicon0 .finalize ()
37
57
38
58
#
39
59
# DFI
40
60
#
41
- ddrphy0 = s6ddrphy .S6DDRPHY (dfi_a , dfi_ba , dfi_d )
42
- dfii0 = dfii .DFIInjector (1 , dfi_a , dfi_ba , dfi_d , 2 )
61
+ ddrphy0 = s6ddrphy .S6DDRPHY (sdram_phy . dfi_a , sdram_phy . dfi_ba , sdram_phy . dfi_d )
62
+ dfii0 = dfii .DFIInjector (1 , sdram_phy . dfi_a , sdram_phy . dfi_ba , sdram_phy . dfi_d , sdram_phy . nphases )
43
63
dficon0 = dfi .Interconnect (dfii0 .master , ddrphy0 .dfi )
64
+ dficon1 = dfi .Interconnect (asmicon0 .dfi , dfii0 .slave )
44
65
45
66
#
46
67
# WISHBONE
0 commit comments