Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: amaranth-lang/amaranth-soc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4a6a948fd9e1
Choose a base ref
...
head repository: amaranth-lang/amaranth-soc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 13a23705110a
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Jun 24, 2020

  1. memory: fix address range overlap with zero-sized resources.

    Jean-François Nguyen committed Jun 24, 2020
    Copy the full SHA
    13a2370 View commit details
Showing with 6 additions and 1 deletion.
  1. +1 −1 nmigen_soc/memory.py
  2. +5 −0 nmigen_soc/test/test_memory.py
2 changes: 1 addition & 1 deletion nmigen_soc/memory.py
Original file line number Diff line number Diff line change
@@ -171,7 +171,7 @@ def _compute_addr_range(self, addr, size, step=1, *, alignment, extend):
if not isinstance(size, int) or size < 0:
raise ValueError("Size must be a non-negative integer, not {!r}"
.format(size))
size = self._align_up(size, alignment)
size = self._align_up(max(size, 1), alignment)

if addr > (1 << self.addr_width) or addr + size > (1 << self.addr_width):
if extend:
5 changes: 5 additions & 0 deletions nmigen_soc/test/test_memory.py
Original file line number Diff line number Diff line change
@@ -104,6 +104,11 @@ def test_add_resource_extend(self):
(0x10000, 0x10001))
self.assertEqual(memory_map.addr_width, 17)

def test_add_resource_size_zero(self):
memory_map = MemoryMap(addr_width=1, data_width=8)
self.assertEqual(memory_map.add_resource("a", size=0), (0, 1))
self.assertEqual(memory_map.add_resource("b", size=0), (1, 2))

def test_add_resource_wrong_address(self):
memory_map = MemoryMap(addr_width=16, data_width=8)
with self.assertRaisesRegex(ValueError,