Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

asmicon: remove uses of multimux

  • Loading branch information...
commit 809cd99205d2c4769ad945bdb1f25007244dab1f 1 parent 99b889a
Sébastien Bourdeauducq authored
9  milkymist/asmicon/bankmachine.py
@@ -2,7 +2,7 @@
2 2
 from migen.bus.asmibus import *
3 3
 from migen.corelogic.roundrobin import *
4 4
 from migen.corelogic.fsm import FSM
5  
-from migen.corelogic.misc import multimux, optree
  5
+from migen.corelogic.misc import optree
6 6
 
7 7
 from milkymist.asmicon.multiplexer import *
8 8
 
@@ -114,11 +114,10 @@ def get_fragment(self):
114 114
 		
115 115
 		# Multiplex
116 116
 		state = Signal(BV(2))
117  
-		mux_outputs = [state, self.adr, self.we]
118  
-		mux_inputs = [[slot.state, slot.adr, slot.we]
119  
-			for slot in self.slots]
120  
-		comb += multimux(rr.grant, mux_inputs, mux_outputs)
121 117
 		comb += [
  118
+			state.eq(Array(slot.state for slot in self.slots)[rr.grant]),
  119
+			self.adr.eq(Array(slot.adr for slot in self.slots)[rr.grant]),
  120
+			self.we.eq(Array(slot.we for slot in self.slots)[rr.grant]),
122 121
 			self.stb.eq(
123 122
 				(self.slicer.bank(self.adr) == self.bankn) \
124 123
 				& (state == SLOT_PENDING)),
45  milkymist/asmicon/multiplexer.py
@@ -2,7 +2,7 @@
2 2
 
3 3
 from migen.fhdl.structure import *
4 4
 from migen.corelogic.roundrobin import *
5  
-from migen.corelogic.misc import multimux, optree
  5
+from migen.corelogic.misc import optree
6 6
 from migen.corelogic.fsm import FSM
7 7
 
8 8
 class CommandRequest:
@@ -41,21 +41,17 @@ def get_fragment(self):
41 41
 			for i, req in enumerate(self.requests)]
42 42
 		
43 43
 		stb = Signal()
44  
-		inputs_perm = [[req.stb,
45  
-			req.a, req.ba,
46  
-			req.is_read, req.is_write, req.tag] for req in self.requests]
47  
-		outputs_perm = [stb,
48  
-			self.cmd.a, self.cmd.ba,
49  
-			self.cmd.is_read, self.cmd.is_write, self.cmd.tag]
50  
-		comb += multimux(rr.grant, inputs_perm, outputs_perm)
51  
-		
52  
-		inputs_filtered = [[req.cas_n, req.ras_n, req.we_n] for req in self.requests]
53  
-		outputs_filtered = [self.cmd.cas_n, self.cmd.ras_n, self.cmd.we_n]
54  
-		ms = multimux(rr.grant, inputs_filtered, outputs_filtered)
55  
-		comb += [
56  
-			self.cmd.stb.eq(stb & (self.cmd.is_read == self.want_reads) & (self.cmd.is_write == self.want_writes)),
57  
-			If(self.cmd.stb, *ms)
58  
-		]
  44
+		comb.append(stb.eq(Array(req.stb for req in self.requests)[rr.grant]))
  45
+		for name in ["a", "ba", "is_read", "is_write", "tag"]:
  46
+			choices = Array(getattr(req, name) for req in self.requests)
  47
+			comb.append(getattr(self.cmd, name).eq(choices[rr.grant]))
  48
+		for name in ["cas_n", "ras_n", "we_n"]:
  49
+			# we should only assert those signals when stb is 1
  50
+			choices = Array(getattr(req, name) for req in self.requests)
  51
+			comb.append(If(self.cmd.stb, getattr(self.cmd, name).eq(choices[rr.grant])))
  52
+		comb.append(self.cmd.stb.eq(stb \
  53
+			& (self.cmd.is_read == self.want_reads) \
  54
+			& (self.cmd.is_write == self.want_writes)))
59 55
 		
60 56
 		comb += [If(self.cmd.stb & self.cmd.ack & (rr.grant == i), req.ack.eq(1))
61 57
 			for i, req in enumerate(self.requests)]
@@ -80,19 +76,20 @@ def stb_and(cmd, attr):
80 76
 				return Constant(0)
81 77
 			else:
82 78
 				return cmd.stb & getattr(cmd, attr)
83  
-		inputs = [[cmd.a, cmd.ba,
84  
-			cmd.cas_n, cmd.ras_n,
85  
-			cmd.we_n, stb_and(cmd, "is_read"), stb_and(cmd, "is_write")]
86  
-			for cmd in self.commands]
87 79
 		for phase, sel in zip(self.dfi.phases, self.sel):
88 80
 			comb += [
89 81
 				phase.cke.eq(1),
90 82
 				phase.cs_n.eq(0)
91 83
 			]
92  
-			outputs = [phase.address, phase.bank,
93  
-				phase.cas_n, phase.ras_n, phase.we_n,
94  
-				phase.rddata_en, phase.wrdata_en]
95  
-			sync += multimux(sel, inputs, outputs)
  84
+			sync += [
  85
+				phase.address.eq(Array(cmd.a for cmd in self.commands)[sel]),
  86
+				phase.bank.eq(Array(cmd.ba for cmd in self.commands)[sel]),
  87
+				phase.cas_n.eq(Array(cmd.cas_n for cmd in self.commands)[sel]),
  88
+				phase.ras_n.eq(Array(cmd.ras_n for cmd in self.commands)[sel]),
  89
+				phase.we_n.eq(Array(cmd.we_n for cmd in self.commands)[sel]),
  90
+				phase.rddata_en.eq(Array(stb_and(cmd, "is_read") for cmd in self.commands)[sel]),
  91
+				phase.wrdata_en.eq(Array(stb_and(cmd, "is_write") for cmd in self.commands)[sel])
  92
+			]
96 93
 		return Fragment(comb, sync)
97 94
 
98 95
 class _Datapath:

0 notes on commit 809cd99

Please sign in to comment.
Something went wrong with that request. Please try again.