interconnect/ahb: Simplify AHBInterface and add data_width/address_width parameters.

This commit is contained in:
Florent Kermarrec 2024-01-04 15:30:26 +01:00
parent 02f0a96c84
commit 7009299132
1 changed files with 24 additions and 25 deletions

View File

@ -22,31 +22,30 @@ class AHBTransferType(IntEnum):
NONSEQUENTIAL = 2 NONSEQUENTIAL = 2
SEQUENTIAL = 3 SEQUENTIAL = 3
# AHB Interface ------------------------------------------------------------------------------------ # AHB Definition -----------------------------------------------------------------------------------
def ahb_description(data_width, address_width):
return [
("addr", address_width, DIR_M_TO_S),
("burst", 3, DIR_M_TO_S),
("mastlock", 1, DIR_M_TO_S),
("prot", 4, DIR_M_TO_S),
("size", 3, DIR_M_TO_S),
("trans", 2, DIR_M_TO_S),
("wdata", data_width, DIR_M_TO_S),
("write", 1, DIR_M_TO_S),
("sel", 1, DIR_M_TO_S),
("rdata", data_width, DIR_S_TO_M),
("readyout", 1, DIR_S_TO_M),
("resp", 1, DIR_S_TO_M),
]
class AHBInterface(Record): class AHBInterface(Record):
"""Sets up the AHB interface signals for master and slave.""" def __init__(self, data_width=32, address_width=32):
adr_width = 32 Record.__init__(self, ahb_description(data_width, address_width))
data_width = 32 self.data_width = data_width
addressing = "byte" self.address_width = address_width
master_signals = [ self.addressing = "byte"
("addr", adr_width),
("burst", 3),
("mastlock", 1),
("prot", 4),
("size", 3),
("trans", 2),
("wdata", data_width),
("write", 1),
("sel", 1),
]
slave_signals = [
("rdata", data_width),
("readyout", 1),
("resp", 1),
]
def __init__(self):
Record.__init__(self, set_layout_parameters(self.master_signals + self.slave_signals))
# AHB to Wishbone --------------------------------------------------------------------------------- # AHB to Wishbone ---------------------------------------------------------------------------------
@ -62,8 +61,8 @@ class AHB2Wishbone(LiteXModule):
"word" : log2_int(ahb.data_width//8), "word" : log2_int(ahb.data_width//8),
"byte" : 0 "byte" : 0
}[wishbone.addressing] }[wishbone.addressing]
assert ahb.data_width == wishbone.data_width assert ahb.data_width == wishbone.data_width
assert ahb.adr_width == wishbone.adr_width + wishbone_adr_shift assert ahb.address_width == wishbone.adr_width + wishbone_adr_shift
# FSM. # FSM.
self.fsm = fsm = FSM() self.fsm = fsm = FSM()