Wishbone bus
Warning
This manual is a work in progress and is seriously incomplete!
The amaranth_soc.wishbone.bus
module provides Wishbone bus primitives.
- class amaranth_soc.wishbone.bus.CycleType
Wishbone Registered Feedback cycle type.
- CLASSIC = 0
- CONST_BURST = 1
- INCR_BURST = 2
- END_OF_BURST = 7
- class amaranth_soc.wishbone.bus.BurstTypeExt
Wishbone Registered Feedback burst type extension.
- LINEAR = 0
- WRAP_4 = 1
- WRAP_8 = 2
- WRAP_16 = 3
- class amaranth_soc.wishbone.bus.Feature
Optional Wishbone interface signals.
- ERR = 'err'
- RTY = 'rty'
- STALL = 'stall'
- LOCK = 'lock'
- CTI = 'cti'
- BTE = 'bte'
- class amaranth_soc.wishbone.bus.Signature
Wishbone interface signature.
See the Wishbone specification for description of the Wishbone signals. The
RST_I
andCLK_I
signals are provided as a part of the clock domain that drives the interface.The correspondence between the Amaranth-SoC signals and the Wishbone signals changes depending on whether the interface acts as an initiator or a target.
- Parameters:
addr_width (
int
) – Width of the address signal.data_width (
int
) – Width of the data signals (“port size” in Wishbone terminology). One of 8, 16, 32, 64.granularity (
int
) – Granularity of select signals (“port granularity” in Wishbone terminology). One of 8, 16, 32, 64. Optional. IfNone
(by default), the granularity is equal todata_width
.features (iterable of
Feature
) – Selects additional signals that will be a part of this interface. Optional.
- Members:
adr (
unsigned(addr_width)
) – Corresponds to Wishbone signalADR_O
(initiator) orADR_I
(target).dat_w (
unsigned(data_width)
) – Corresponds to Wishbone signalDAT_O
(initiator) orDAT_I
(target).dat_r (
unsigned(data_width)
) – Corresponds to Wishbone signalDAT_I
(initiator) orDAT_O
(target).sel (
unsigned(data_width // granularity)
) – Corresponds to Wishbone signalSEL_O
(initiator) orSEL_I
(target).cyc (
unsigned(1)
) – Corresponds to Wishbone signalCYC_O
(initiator) orCYC_I
(target).stb (
unsigned(1)
) – Corresponds to Wishbone signalSTB_O
(initiator) orSTB_I
(target).we (
unsigned(1)
) – Corresponds to Wishbone signalWE_O
(initiator) orWE_I
(target).ack (
unsigned(1)
) – Corresponds to Wishbone signalACK_I
(initiator) orACK_O
(target).err (
unsigned(1)
) – Optional. Corresponds to Wishbone signalERR_I
(initiator) orERR_O
(target).rty (
unsigned(1)
) – Optional. Corresponds to Wishbone signalRTY_I
(initiator) orRTY_O
(target).stall (
unsigned(1)
) – Optional. Corresponds to Wishbone signalSTALL_I
(initiator) orSTALL_O
(target).lock (
unsigned(1)
) – Optional. Corresponds to Wishbone signalLOCK_O
(initiator) orLOCK_I
(target). Amaranth-SoC Wishbone support assumes that initiators that don’t want bus arbitration to happen in between two transactions need to uselock
feature to guarantee this. An initiator without thelock
feature may be arbitrated in between two transactions even ifcyc
is kept high.cti (
unsigned(1)
) – Optional. Corresponds to Wishbone signalCTI_O
(initiator) orCTI_I
(target).bte (
unsigned(1)
) – Optional. Corresponds to Wishbone signalBTE_O
(initiator) orBTE_I
(target).
- data_width
Width of the data signals (“port size” in Wishbone terminology).
- Return type:
One of 8, 16, 32, 64.
- granularity
Granularity of select signals (“port granularity” in Wishbone terminology).
- Return type:
One of 8, 16, 32, 64.
- features
Additional signals that will be a part of this interface.
- create(*, path=None, src_loc_at=0)
Create a compatible interface.
See
amaranth.lib.wiring.Signature.create()
for details.- Return type:
- __eq__(other)
Compare signatures.
Two signatures are equal if they have the same address width, data width, granularity and features.
- class amaranth_soc.wishbone.bus.Interface
Wishbone bus interface.
Note
The data width of the underlying
MemoryMap
of the interface is equal to port granularity, not port size. If port granularity is less than port size, then the address width of the underlying memory map is extended to reflect that.- Parameters:
addr_width (
int
) – Width of the address signal. SeeSignature
.data_width (
int
) – Width of the data signals. SeeSignature
.granularity (
int
) – Granularity of select signals. Optional. SeeSignature
.features (iterable of
Feature
) – Describes additional signals of this interface. Optional. SeeSignature
.path (iter(
str
)) – Path to this Wishbone interface. Optional. Seeamaranth.lib.wiring.PureInterface
.
- data_width
Width of the data signals (“port size” in Wishbone terminology).
- Return type:
One of 8, 16, 32, 64.
- granularity
Granularity of select signals (“port granularity” in Wishbone terminology).
- Return type:
One of 8, 16, 32, 64.
- class amaranth_soc.wishbone.bus.Decoder
Wishbone bus decoder.
An address decoder for subordinate Wishbone buses.
- Parameters:
- Members:
bus (
In(wishbone.Signature(addr_width, data_width, granularity, features))
) – Wishbone bus providing access to subordinate buses.
- align_to(alignment)
Align the implicit address of the next window.
See
align_to()
for details.- Returns:
Implicit next address.
- Return type:
- add(sub_bus, *, name=None, addr=None, sparse=False)
Add a window to a subordinate bus.
See
add_window()
for details.Note
The
Decoder
can perform either sparse or dense address translation:If dense address translation is used (the default), the subordinate bus must have the same data width as the
Decoder
; the window will be contiguous.If sparse address translation is used, the subordinate bus may have data width less than the data width of the
Decoder
; the window may be discontiguous.
In either case, the granularity of the subordinate bus must be equal to or less than the granularity of the
Decoder
.- Returns:
A tuple
(start, end, ratio)
describing the address range assigned to the window. When bridging buses of unequal data width,ratio
is the amount of contiguous addresses on the narrower bus that are accessed for each transaction on the wider bus. Otherwise, it is always 1.- Return type:
- Raises:
ValueError – If the subordinate bus granularity is greater than the
Decoder
granularity.ValueError – If dense address translation is used and the subordinate bus data width is not equal to the
Decoder
data width.ValueError – If sparse address translation is used and the subordinate bus data width is not the equal to the subordinate bus granularity.
ValueError – If the subordinate bus as an optional output signal that is not present in the
Decoder
interface.
- class amaranth_soc.wishbone.bus.Arbiter
Wishbone bus arbiter.
A round-robin arbiter for initiators accessing a shared Wishbone bus.
- Parameters:
- Members:
bus (
Out(wishbone.Signature(addr_width, data_width, granularity, features))
) – Shared Wishbone bus.
- add(intr_bus)
Add an initiator bus to the arbiter.
- Raises:
ValueError – If the initiator bus address width is not equal to the
Arbiter
address width.ValueError – If the initiator bus granularity is lesser than the
Arbiter
granularity.ValueError – If the initiator bus data width is not equal to the
Arbiter
data width.ValueError – If the
Arbiter
has an optional output signal that is not present in the initiator bus.