inteconnect/ahb: Add specific case for 32-bit data width, fix CSR accesses with gowin_ae350.

This commit is contained in:
Florent Kermarrec 2024-01-15 11:40:25 +01:00
parent 6b79644108
commit b19d992f23
1 changed files with 52 additions and 29 deletions

View File

@ -61,10 +61,12 @@ class AHB2Wishbone(LiteXModule):
"word" : log2_int(ahb.data_width//8),
"byte" : 0
}[wishbone.addressing]
assert ahb.data_width in [32, 64]
assert ahb.data_width == wishbone.data_width
assert ahb.address_width == wishbone.adr_width + wishbone_adr_shift
def wishbone_sel_decoder(ahb_size, ahb_addr):
if ahb.data_width == 64:
wishbone_sel = Signal(8)
self.comb += Case(ahb_size, {
# 8-bit access.
@ -94,6 +96,27 @@ class AHB2Wishbone(LiteXModule):
0b11 : wishbone_sel.eq(0b1111_1111),
})
return wishbone_sel
if ahb.data_width == 32:
wishbone_sel = Signal(4)
self.comb += Case(ahb_size, {
# 8-bit access.
0b00 : Case(ahb_addr[0:2], {
0b00 : wishbone_sel.eq(0b0001),
0b01 : wishbone_sel.eq(0b0010),
0b10 : wishbone_sel.eq(0b0100),
0b11 : wishbone_sel.eq(0b1000),
}),
# 16-bit access.
0b01 : Case(ahb_addr[1:2], {
0b0 : wishbone_sel.eq(0b0011),
0b1 : wishbone_sel.eq(0b1100),
}),
# 32-bit access.
0b10 : wishbone_sel.eq(0b1111),
# 64-bit access (Should not happen but do a full 32-bit access).
0b11 : wishbone_sel.eq(0b1111),
})
return wishbone_sel
# FSM.
self.fsm = fsm = FSM()