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: 7e20320b9d61
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: 6ba0d4bd0d8a
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jul 27, 2013

  1. genlib/record: support abstract signal width

    Sebastien Bourdeauducq committed Jul 27, 2013
    Copy the full SHA
    14ed5c1 View commit details
  2. bus/wishbone: configurable data width

    Sebastien Bourdeauducq committed Jul 27, 2013
    Copy the full SHA
    6ba0d4b View commit details
Showing with 25 additions and 19 deletions.
  1. +14 −13 migen/bus/wishbone.py
  2. +11 −6 migen/genlib/record.py
27 changes: 14 additions & 13 deletions migen/bus/wishbone.py
Original file line number Diff line number Diff line change
@@ -6,22 +6,23 @@
from migen.sim.generic import Proxy

_layout = [
("adr", 30, DIR_M_TO_S),
("dat_w", 32, DIR_M_TO_S),
("dat_r", 32, DIR_S_TO_M),
("sel", 4, DIR_M_TO_S),
("cyc", 1, DIR_M_TO_S),
("stb", 1, DIR_M_TO_S),
("ack", 1, DIR_S_TO_M),
("we", 1, DIR_M_TO_S),
("cti", 3, DIR_M_TO_S),
("bte", 2, DIR_M_TO_S),
("err", 1, DIR_S_TO_M)
("adr", 30, DIR_M_TO_S),
("dat_w", "data_width", DIR_M_TO_S),
("dat_r", "data_width", DIR_S_TO_M),
("sel", "sel_width", DIR_M_TO_S),
("cyc", 1, DIR_M_TO_S),
("stb", 1, DIR_M_TO_S),
("ack", 1, DIR_S_TO_M),
("we", 1, DIR_M_TO_S),
("cti", 3, DIR_M_TO_S),
("bte", 2, DIR_M_TO_S),
("err", 1, DIR_S_TO_M)
]

class Interface(Record):
def __init__(self):
Record.__init__(self, _layout)
def __init__(self, data_width=32):
Record.__init__(self, _layout, data_width=data_width,
sel_width=data_width//8)

class InterconnectPointToPoint(Module):
def __init__(self, master, slave):
17 changes: 11 additions & 6 deletions migen/genlib/record.py
Original file line number Diff line number Diff line change
@@ -11,19 +11,21 @@
# size can be an int, or a (int, bool) tuple for signed numbers
# sublayout must be a list

def layout_len(layout):
def layout_len(layout, **layout_dict):
r = 0
for f in layout:
if isinstance(f[1], (int, tuple)): # cases 1/2
if isinstance(f[1], (int, tuple, str)): # cases 1/2
if(len(f) == 3):
fname, fsize, fdirection = f
else:
fname, fsize = f
elif isinstance(f[1], list): # case 3
fname, fsublayout = f
fsize = layout_len(fsublayout)
fsize = layout_len(fsublayout, **layout_dict)
else:
raise TypeError
if isinstance(fsize, str):
fsize = layout_dict[fsize]
if isinstance(fsize, tuple):
r += fsize[0]
else:
@@ -55,20 +57,23 @@ def layout_partial(layout, *elements):
return r

class Record:
def __init__(self, layout, name=None):
def __init__(self, layout, name=None, **layout_dict):
self.name = get_obj_var_name(name, "")
self.layout = layout
self.layout_dict = layout_dict

if self.name:
prefix = self.name + "_"
else:
prefix = ""
for f in self.layout:
if isinstance(f[1], (int, tuple)): # cases 1/2
if isinstance(f[1], (int, tuple, str)): # cases 1/2
if(len(f) == 3):
fname, fsize, fdirection = f
else:
fname, fsize = f
if isinstance(fsize, str):
fsize = layout_dict[fsize]
finst = Signal(fsize, name=prefix + fname)
elif isinstance(f[1], list): # case 3
fname, fsublayout = f
@@ -139,7 +144,7 @@ def connect_flat(self, *slaves):
return r

def __len__(self):
return layout_len(self.layout)
return layout_len(self.layout, **self.layout_dict)

def __repr__(self):
return "<Record " + ":".join(f[0] for f in self.layout) + " at " + hex(id(self)) + ">"