Skip to content

Commit ecfad4d

Browse files
author
Jean-François Nguyen
committed
Clarify documentation for alignment parameters to mention it is log2.
Fixes #6.
1 parent b405880 commit ecfad4d

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

nmigen_soc/csr/bus.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -192,28 +192,29 @@ class Multiplexer(Elaboratable):
192192
are possible for connecting the CSR bus to the CPU:
193193
* The CPU could access the CSR bus directly (with no intervening logic other than simple
194194
translation of control signals). In this case, the register alignment should be set
195-
to 1, and each *w*-bit register would occupy *ceil(w/n)* addresses from the CPU
196-
perspective, requiring the same amount of memory instructions to access.
195+
to 1 (i.e. `alignment` should be set to 0), and each *w*-bit register would occupy
196+
*ceil(w/n)* addresses from the CPU perspective, requiring the same amount of memory
197+
instructions to access.
197198
* The CPU could also access the CSR bus through a width down-converter, which would issue
198199
*k/n* CSR accesses for each CPU access. In this case, the register alignment should be
199200
set to *k/n*, and each *w*-bit register would occupy *ceil(w/k)* addresses from the CPU
200201
perspective, requiring the same amount of memory instructions to access.
201202
202-
If alignment is greater than 1, it affects which CSR bus write is considered a write to
203-
the last register chunk. For example, if a 24-bit register is used with a 8-bit CSR bus and
204-
a CPU with a 32-bit datapath, a write to this register requires 4 CSR bus writes to complete
205-
and the 4th write is the one that actually writes the value to the register. This allows
206-
determining write latency solely from the amount of addresses the register occupies in
207-
the CPU address space, and the width of the CSR bus.
203+
If the register alignment (i.e. `2 ** alignment`) is greater than 1, it affects which CSR bus
204+
write is considered a write to the last register chunk. For example, if a 24-bit register is
205+
used with a 8-bit CSR bus and a CPU with a 32-bit datapath, a write to this register requires
206+
4 CSR bus writes to complete and the 4th write is the one that actually writes the value to
207+
the register. This allows determining write latency solely from the amount of addresses the
208+
register occupies in the CPU address space, and the width of the CSR bus.
208209
209210
Parameters
210211
----------
211212
addr_width : int
212213
Address width. See :class:`Interface`.
213214
data_width : int
214215
Data width. See :class:`Interface`.
215-
alignment : int
216-
Register alignment. See :class:`Interface`.
216+
alignment : log2 of int
217+
Register alignment. See :class:`..memory.MemoryMap`.
217218
218219
Attributes
219220
----------
@@ -327,8 +328,8 @@ class Decoder(Elaboratable):
327328
Address width. See :class:`Interface`.
328329
data_width : int
329330
Data width. See :class:`Interface`.
330-
alignment : int
331-
Window alignment. See :class:`Interface`.
331+
alignment : log2 of int
332+
Window alignment. See :class:`..memory.MemoryMap`.
332333
333334
Attributes
334335
----------

nmigen_soc/memory.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class MemoryMap:
7070
Address width.
7171
data_width : int
7272
Data width.
73-
alignment : int
73+
alignment : log2 of int
7474
Range alignment. Each added resource and window will be placed at an address that is
7575
a multiple of ``2 ** alignment``, and its size will be rounded up to be a multiple of
7676
``2 ** alignment``.
@@ -142,7 +142,7 @@ def align_to(self, alignment):
142142
143143
Arguments
144144
---------
145-
alignment : int
145+
alignment : log2 of int
146146
Address alignment. The start of the implicit next address will be a multiple of
147147
``2 ** max(alignment, self.alignment)``.
148148
@@ -216,7 +216,7 @@ def add_resource(self, resource, *, size, addr=None, alignment=None, extend=Fals
216216
size : int
217217
Size of the resource, in minimal addressable units. Rounded up to a multiple of
218218
``2 ** max(alignment, self.alignment)``.
219-
alignment : int or None
219+
alignment : log2 of int or None
220220
Alignment of the resource. If not specified, the memory map alignment is used.
221221
extend: bool
222222
Allow memory map extension. If ``True``, the upper bound of the address space is

nmigen_soc/wishbone/bus.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ class Decoder(Elaboratable):
184184
Granularity. See :class:`Interface`
185185
features : iter(str)
186186
Optional signal set. See :class:`Interface`.
187-
alignment : int
188-
Window alignment. See :class:`Interface`.
187+
alignment : log2 of int
188+
Window alignment. See :class:`..memory.MemoryMap`
189189
190190
Attributes
191191
----------

0 commit comments

Comments
 (0)