Skip to content

Commit

Permalink
soc_core: csr_alignment assertions
Browse files Browse the repository at this point in the history
Enforce the condition that csr_alignment be either 32 or 64 when
requested explicitly when initializing SoCCore().

Additionally, if a CPU is specified, enforce that csr_alignment be
equal to the native CPU word size (currently either 32 or 64), and
warn the caller if an alignment value *higher* than the CPU native
word size was explicitly requested.

In conclusion, if a CPU is specified, then csr_alignment should be
assumed to equal 8*sizeof(unsigned long).

Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
  • Loading branch information
gsomlo committed Dec 21, 2019
1 parent b6818c2 commit 585b50b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion litex/soc/integration/soc_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ def __init__(self, platform, clk_freq,
self.csr_data_width = csr_data_width
self.csr_address_width = csr_address_width

assert csr_alignment in [32, 64]

self.with_ctrl = with_ctrl

self.with_uart = with_uart
Expand Down Expand Up @@ -200,6 +202,9 @@ def __init__(self, platform, clk_freq,
# Allow SoCController to reset the CPU
if with_ctrl:
self.comb += self.cpu.reset.eq(self.ctrl.reset)

assert csr_alignment <= self.cpu.data_width
csr_alignment = self.cpu.data_width
else:
self.submodules.cpu = cpu.CPUNone()
self.soc_io_regions.update(self.cpu.io_regions)
Expand Down Expand Up @@ -256,7 +261,6 @@ def __init__(self, platform, clk_freq,
self.add_interrupt("timer0", allow_user_defined=True)

# Add Wishbone to CSR bridge
csr_alignment = max(csr_alignment, self.cpu.data_width)
self.config["CSR_DATA_WIDTH"] = csr_data_width
self.config["CSR_ALIGNMENT"] = csr_alignment
assert csr_data_width <= csr_alignment
Expand Down

0 comments on commit 585b50b

Please sign in to comment.