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: m-labs/migen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 27accd72b550
Choose a base ref
...
head repository: m-labs/migen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5208baada8ef
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on May 19, 2013

  1. bus/csr/SRAM: support init

    Sebastien Bourdeauducq committed May 19, 2013
    Copy the full SHA
    7ada015 View commit details
  2. bus/wishbone/SRAM: support init and read_only

    Sebastien Bourdeauducq committed May 19, 2013
    Copy the full SHA
    5208baa View commit details
Showing with 15 additions and 8 deletions.
  1. +2 −2 migen/bus/csr.py
  2. +13 −6 migen/bus/wishbone.py
4 changes: 2 additions & 2 deletions migen/bus/csr.py
Original file line number Diff line number Diff line change
@@ -55,11 +55,11 @@ def _compute_page_bits(nwords):
return 0

class SRAM(Module):
def __init__(self, mem_or_size, address, read_only=None, bus=None):
def __init__(self, mem_or_size, address, read_only=None, init=None, bus=None):
if isinstance(mem_or_size, Memory):
mem = mem_or_size
else:
mem = Memory(data_width, mem_or_size//(data_width//8))
mem = Memory(data_width, mem_or_size//(data_width//8), init=init)
if mem.width > data_width:
csrw_per_memw = (mem.width + data_width - 1)//data_width
word_bits = bits_for(csrw_per_memw-1)
19 changes: 13 additions & 6 deletions migen/bus/wishbone.py
Original file line number Diff line number Diff line change
@@ -184,12 +184,17 @@ def do_simulation(self, s):
bus.ack = 0

class SRAM(Module):
def __init__(self, mem_or_size, bus=None):
def __init__(self, mem_or_size, read_only=None, init=None, bus=None):
if isinstance(mem_or_size, Memory):
assert(mem_or_size.width <= 32)
mem = mem_or_size
else:
mem = Memory(32, mem_or_size//4)
mem = Memory(32, mem_or_size//4, init=init)
if read_only is None:
if hasattr(mem, "bus_read_only"):
read_only = mem.bus_read_only
else:
read_only = False
if bus is None:
bus = Interface()
self.bus = bus
@@ -198,16 +203,18 @@ def __init__(self, mem_or_size, bus=None):

# memory
self.specials += mem
port = mem.get_port(write_capable=True, we_granularity=8)
port = mem.get_port(write_capable=not read_only, we_granularity=8)
# generate write enable signal
self.comb += [port.we[i].eq(self.bus.cyc & self.bus.stb & self.bus.we & self.bus.sel[i])
for i in range(4)]
if not read_only:
self.comb += [port.we[i].eq(self.bus.cyc & self.bus.stb & self.bus.we & self.bus.sel[i])
for i in range(4)]
# address and data
self.comb += [
port.adr.eq(self.bus.adr[:len(port.adr)]),
port.dat_w.eq(self.bus.dat_w),
self.bus.dat_r.eq(port.dat_r)
]
if not read_only:
self.comb += port.dat_w.eq(self.bus.dat_w),
# generate ack
self.sync += [
self.bus.ack.eq(0),