@@ -112,8 +112,8 @@ class ChannelMMIO(esi.ServiceImplementation):
112112 - 0x12: ESI version number (0)
113113 - 0x18: Location of the manifest ROM (absolute address)
114114
115- - 0x10000 : Start of MMIO space for requests. Mapping is contained in the
116- manifest so can be dynamically queried.
115+ - 0x400 : Start of MMIO space for requests. Mapping is contained in the
116+ manifest so can be dynamically queried.
117117
118118 - addr(Manifest ROM) + 0: Size of compressed manifest
119119 - addr(Manifest ROM) + 8: Start of compressed manifest
@@ -133,16 +133,12 @@ class ChannelMMIO(esi.ServiceImplementation):
133133 # TODO: make the amount of register space each client gets a parameter.
134134 # Supporting this will require more address decode logic.
135135 #
136- # TODO: if the compressed manifest is larger than 'RegisterSpace', we won't be
137- # allocating enough address space. This should be fixed with the more complex
138- # address decode logic mentioned above.
139- #
140136 # TODO: only supports one outstanding transaction at a time. This is NOT
141137 # enforced or checked! Enforce this.
142138
143- RegisterSpace = 0x100000
139+ RegisterSpace = 0x400
144140 RegisterSpaceBits = RegisterSpace .bit_length () - 1
145- AddressMask = 0xFFFFF
141+ AddressMask = 0x3FF
146142
147143 # Start at this address for assigning MMIO addresses to service requests.
148144 initial_offset : int = RegisterSpace
@@ -204,7 +200,8 @@ def build_read(ports, manifest_loc: int, table: Dict[int, AssignableSignal]):
204200 counted_output .assign (data_resp_channel )
205201
206202 # Get the selection index and the address to hand off to the clients.
207- sel_bits , client_cmd_chan = ChannelMMIO .build_addr_read (cmd_channel )
203+ sel_bits , client_cmd_chan = ChannelMMIO .build_addr_read (
204+ cmd_channel , len (table ), manifest_loc )
208205
209206 # Build the demux/mux and assign the results of each appropriately.
210207 read_clients_clog2 = clog2 (len (table ))
@@ -231,8 +228,8 @@ def build_read(ports, manifest_loc: int, table: Dict[int, AssignableSignal]):
231228 data_resp_channel .assign (resp_channel )
232229
233230 @staticmethod
234- def build_addr_read (
235- read_addr_chan : ChannelSignal ) -> Tuple [BitsSignal , ChannelSignal ]:
231+ def build_addr_read (read_addr_chan : ChannelSignal , num_clients : int ,
232+ manifest_loc : int ) -> Tuple [BitsSignal , ChannelSignal ]:
236233 """Build a channel for the address read request. Returns the index to select
237234 the client and a channel for the masked address to be passed to the
238235 clients."""
@@ -241,19 +238,27 @@ def build_addr_read(
241238 # change to support more flexibility in addressing. Not clear if what we're
242239 # doing now it sufficient or not.
243240
241+ manifest_loc_const = UInt (32 )(manifest_loc )
242+
244243 cmd_ready_wire = Wire (Bits (1 ))
245244 cmd , cmd_valid = read_addr_chan .unwrap (cmd_ready_wire )
245+ is_manifest_read = cmd .offset > manifest_loc_const
246246 sel_bits = NamedWire (Bits (32 - ChannelMMIO .RegisterSpaceBits ), "sel_bits" )
247- sel_bits .assign (cmd .offset .as_bits ()[ChannelMMIO .RegisterSpaceBits :])
247+ # If reading the manifest, override the selection to select the manifest instead.
248+ sel_bits .assign (
249+ Mux (is_manifest_read ,
250+ cmd .offset .as_bits ()[ChannelMMIO .RegisterSpaceBits :],
251+ Bits (32 - ChannelMMIO .RegisterSpaceBits )(num_clients - 1 )))
252+ regular_client_offset = (cmd .offset .as_bits () &
253+ Bits (32 )(ChannelMMIO .AddressMask )).as_uint ()
254+ offset = Mux (is_manifest_read , regular_client_offset ,
255+ (cmd .offset - manifest_loc_const ).as_uint (32 ))
248256 client_cmd = NamedWire (esi .MMIOReadWriteCmdType , "client_cmd" )
249257 client_cmd .assign (
250258 esi .MMIOReadWriteCmdType ({
251- "write" :
252- cmd .write ,
253- "offset" : (cmd .offset .as_bits () &
254- Bits (32 )(ChannelMMIO .AddressMask )).as_uint (),
255- "data" :
256- cmd .data
259+ "write" : cmd .write ,
260+ "offset" : offset ,
261+ "data" : cmd .data
257262 }))
258263 client_addr_chan , client_addr_ready = Channel (
259264 esi .MMIOReadWriteCmdType ).wrap (client_cmd , cmd_valid )
0 commit comments