@@ -30,15 +30,15 @@ def __init__(self, requests):
30
30
self .want_cmds = Signal ()
31
31
# NB: cas_n/ras_n/we_n are 1 when stb is inactive
32
32
self .cmd = CommandRequestRW (flen (requests [0 ].a ), flen (requests [0 ].ba ))
33
-
33
+
34
34
###
35
35
36
36
rr = RoundRobin (len (requests ), SP_CE )
37
37
self .submodules += rr
38
-
38
+
39
39
self .comb += [rr .request [i ].eq (req .stb & ((req .is_cmd & self .want_cmds ) | ((req .is_read == self .want_reads ) | (req .is_write == self .want_writes ))))
40
40
for i , req in enumerate (requests )]
41
-
41
+
42
42
stb = Signal ()
43
43
self .comb += stb .eq (Array (req .stb for req in requests )[rr .grant ])
44
44
for name in ["a" , "ba" , "is_read" , "is_write" , "is_cmd" ]:
@@ -51,7 +51,7 @@ def __init__(self, requests):
51
51
self .comb += self .cmd .stb .eq (stb \
52
52
& ((self .cmd .is_cmd & self .want_cmds ) | ((self .cmd .is_read == self .want_reads ) \
53
53
& (self .cmd .is_write == self .want_writes ))))
54
-
54
+
55
55
self .comb += [If (self .cmd .stb & self .cmd .ack & (rr .grant == i ), req .ack .eq (1 ))
56
56
for i , req in enumerate (requests )]
57
57
self .comb += rr .ce .eq (self .cmd .ack )
@@ -61,9 +61,9 @@ def __init__(self, commands, dfi):
61
61
ncmd = len (commands )
62
62
nph = len (dfi .phases )
63
63
self .sel = [Signal (max = ncmd ) for i in range (nph )]
64
-
64
+
65
65
###
66
-
66
+
67
67
def stb_and (cmd , attr ):
68
68
if not hasattr (cmd , "stb" ):
69
69
return 0
@@ -91,7 +91,7 @@ def stb_and(cmd, attr):
91
91
class Multiplexer (Module , AutoCSR ):
92
92
def __init__ (self , phy_settings , geom_settings , timing_settings , bank_machines , refresher , dfi , lasmic ):
93
93
assert (phy_settings .nphases == len (dfi .phases ))
94
-
94
+
95
95
# Command choosing
96
96
requests = [bm .cmd for bm in bank_machines ]
97
97
choose_cmd = _CommandChooser (requests )
@@ -104,24 +104,24 @@ def __init__(self, phy_settings, geom_settings, timing_settings, bank_machines,
104
104
self .comb += [
105
105
choose_cmd .want_cmds .eq (1 ),
106
106
choose_req .want_cmds .eq (1 )
107
- ]
107
+ ]
108
108
self .submodules += choose_cmd , choose_req
109
-
109
+
110
110
# Command steering
111
111
nop = CommandRequest (geom_settings .mux_a , geom_settings .bank_a )
112
112
commands = [nop , choose_cmd .cmd , choose_req .cmd , refresher .cmd ] # nop must be 1st
113
113
(STEER_NOP , STEER_CMD , STEER_REQ , STEER_REFRESH ) = range (4 )
114
114
steerer = _Steerer (commands , dfi )
115
115
self .submodules += steerer
116
-
116
+
117
117
# Read/write turnaround
118
118
read_available = Signal ()
119
119
write_available = Signal ()
120
120
self .comb += [
121
121
read_available .eq (optree ("|" , [req .stb & req .is_read for req in requests ])),
122
122
write_available .eq (optree ("|" , [req .stb & req .is_write for req in requests ]))
123
123
]
124
-
124
+
125
125
def anti_starvation (timeout ):
126
126
en = Signal ()
127
127
max_time = Signal ()
@@ -139,12 +139,12 @@ def anti_starvation(timeout):
139
139
return en , max_time
140
140
read_time_en , max_read_time = anti_starvation (timing_settings .read_time )
141
141
write_time_en , max_write_time = anti_starvation (timing_settings .write_time )
142
-
142
+
143
143
# Refresh
144
144
self .comb += [bm .refresh_req .eq (refresher .req ) for bm in bank_machines ]
145
145
go_to_refresh = Signal ()
146
146
self .comb += go_to_refresh .eq (optree ("&" , [bm .refresh_gnt for bm in bank_machines ]))
147
-
147
+
148
148
# Datapath
149
149
all_rddata = [p .rddata for p in dfi .phases ]
150
150
all_wrdata = [p .wrdata for p in dfi .phases ]
@@ -154,11 +154,11 @@ def anti_starvation(timeout):
154
154
Cat (* all_wrdata ).eq (lasmic .dat_w ),
155
155
Cat (* all_wrdata_mask ).eq (~ lasmic .dat_we )
156
156
]
157
-
157
+
158
158
# Control FSM
159
159
fsm = FSM ()
160
160
self .submodules += fsm
161
-
161
+
162
162
def steerer_sel (steerer , phy_settings , r_w_n ):
163
163
r = []
164
164
for i in range (phy_settings .nphases ):
0 commit comments