跳转至

I3C FIFO 目标

PxI3CFifoTarget 模拟具有主机可访问 RX 与 TX FIFO 的 I3C 目标器件。控制器在总线上写入的数据进入 RX FIFO(以事件交给 Python);Python 将数据入队到 TX FIFO,供控制器在总线上读取。

此目标也支持标准 I3C CCC 处理、Dynamic Address Assignment、IBI 与 Hot-Join。

TX FIFO 深度固定为 2 KB(扣除 8 字节簿记开销后为 2040 字节),无法从 Python 配置。单次 enqueue 最多可传送当前可用的 TX FIFO 容量。当总线读取抽空 TX FIFO 时,sent 事件会回报从 TX FIFO 抽走的字节数。

收到的数据以 receive 事件交给 Python,每个 receive 事件最多交付 1 KB。若传输大于 1 KB,会拆成多个事件。

功能

  • 2 KB TX FIFO,支持主机端入队与分组总线事件。
  • CCC 处理,包含地址分配、MRL/MWL、GETCAPS、GETSTATUS、GETMXDS 与组地址。
  • 通过 CCC 启用时支持 IBI 与 Hot-Join

数据流

Controller WRITE  →  RX FIFO  →  fifo_target_recv events  →  Python
Python enqueue    →  TX FIFO  →  Controller READ
Controller READ   →  (drains TX FIFO)  →  fifo_target_sent events  →  Python

PxI3CFifoTarget

PxI3CFifoTarget(
    exerciser: AqProtocolExerciser,
    *args,
    pid: int | None = None,
    bcr: int = 0,
    dcr: int = 0,
    config: I3CFifoTargetConfig | None = None,
    static_addr: int = 0,
    minimum_mrl: int | None = None,
    minimum_mwl: int | None = None,
    getcaps_std_value: bytes | None = None,
    getcaps_usr_value: list[tuple[int, bytes]] | None = None,
    getstatus_std_value: bytes | None = None,
    getstatus_usr_value: list[tuple[int, bytes]] | None = None,
    getmxds_std_value: bytes | None = None,
    getmxds_usr_value: list[tuple[int, bytes]] | None = None,
    supported_group_address_count: int = 3,
    **kwargs
)

Bases: PxAbstractTarget

I3C FIFO target.

Emulates an I3C target with host-accessible RX and TX FIFOs. Bytes written by a controller on the bus are delivered to Python as packeted fifo_target_recv events. Bytes enqueued from Python are presented on subsequent bus reads; completed bus reads are reported as fifo_target_sent events with the byte count drained in each transaction.

The target also supports standard I3C CCC handling, IBI, and Hot-Join like other I3C targets.

CLASS DESCRIPTION
IbiType

IBI type enumeration.

HotJoinType

Hot-Join type enumeration.

METHOD DESCRIPTION
add_event_handler

Add an event handler to the current device instance.

remove_event_handler

Remove an event handler.

get_event_handlers

Retreive handlers registerd on this device.

on_event

Add an event handler to the instance by decorator.

set_config

Set the config of the target.

detach_from_bus

Detach the device from the bus.

perform_operation

Send an operation.

attach_to_bus

Attach the target to a bus.

enqueue

Enqueue bytes into the host-side TX FIFO.

ibi_request

Initiate an IBI request from the current target.

send_hotjoin

Initiate a Hot-Join request from the current target.

ATTRIBUTE DESCRIPTION
available_events_map

A reverse mapping of field_name_by_number, which uses field name as key.

TYPE: dict[str, str]

is_attached

Check if the device is attached to a bus.

TYPE: bool

state

Get the state of the device.

TYPE: Message | None

name

Get the name of the device.

TYPE: str

additional_data

Get the opaque additional data blob associated with this device.

TYPE: bytes

config

Get the config of the device.

TYPE: Message | None

cts_op_name

Get the name of CTS operation. Currently not available now.

TYPE: str | None

static_address

Static address of the I3C FIFO target.

TYPE: int

assigned_address

Get the assigned address of the target.

TYPE: int

event_state

Get the event state of the target.

TYPE: int

group_addresses

Get the group addresses assigned to the target.

TYPE: list[int]

mrl

Get the maximum read length of the target.

TYPE: int

mwl

Get the maximum write length of the target.

TYPE: int

tx_capacity

Get the capacity of the FIFO.

TYPE: int

tx_fill

Number of bytes currently in the TX FIFO.

TYPE: int

total_read

Total bytes read by the controller from the target since configuration.

TYPE: int

total_written

Total bytes written by the controller to the target since configuration.

TYPE: int

available_events_map

available_events_map: dict[str, str]

A reverse mapping of field_name_by_number, which uses field name as key.

is_attached

is_attached: bool

Check if the device is attached to a bus.

state

state: Message | None

Get the state of the device.

name

name: str

Get the name of the device.

additional_data

additional_data: bytes

Get the opaque additional data blob associated with this device.

config

config: Message | None

Get the config of the device.

cts_op_name

cts_op_name: str | None

Get the name of CTS operation. Currently not available now.

static_address

static_address: int

Static address of the I3C FIFO target.

assigned_address

assigned_address: int

Get the assigned address of the target.

event_state

event_state: int

Get the event state of the target.

group_addresses

group_addresses: list[int]

Get the group addresses assigned to the target.

mrl

mrl: int

Get the maximum read length of the target.

mwl

mwl: int

Get the maximum write length of the target.

tx_capacity

tx_capacity: int

Get the capacity of the FIFO.

tx_fill

tx_fill: int

Number of bytes currently in the TX FIFO.

total_read

total_read: int

Total bytes read by the controller from the target since configuration.

total_written

total_written: int

Total bytes written by the controller to the target since configuration.

IbiType

Bases: IntEnum

IBI type enumeration.

HotJoinType

Bases: IntEnum

Hot-Join type enumeration.

add_event_handler

add_event_handler(event: str, handler: Callable[[Any], Any]) -> None

Add an event handler to the current device instance.

remove_event_handler

remove_event_handler(event: str) -> None

Remove an event handler.

get_event_handlers

get_event_handlers() -> dict[str, Callable]

Retreive handlers registerd on this device.

on_event

on_event(event_type: str) -> Callable[[Callable[..., Any]], Callable[..., Any]]

Add an event handler to the instance by decorator.

set_config

set_config(config: Message) -> None

Set the config of the target.

detach_from_bus

detach_from_bus() -> None

Detach the device from the bus.

The opposite of the attach_to_bus method.

perform_operation

perform_operation(operation: PxDeviceOperation) -> PxDeviceOperation

Send an operation.

attach_to_bus

attach_to_bus(bus: PxAbstractBus) -> None

Attach the target to a bus.

This method is used to make the device aware of the bus it is connected to. It is used to set the bus attribute of the device.

Note

This method will not automatically create an actual instance on the Protocol Exerciser until user call the attach_to_bus method.

PARAMETER DESCRIPTION

bus

The bus to attach the device to

TYPE: PxAbstractBus

RAISES DESCRIPTION
ValueError

If the device is already attached to a bus

enqueue

enqueue(data: list[int] | bytes) -> None

Enqueue bytes into the host-side TX FIFO.

ibi_request

ibi_request(
    ibi_type: IbiType = IMMEDIATE,
    mdb_value: bytes = b"",
    additional_data: bytes = b"",
    skip_bcr_check: bool = False,
) -> None

Initiate an IBI request from the current target.

send_hotjoin

send_hotjoin(hotjoin_type: HotJoinType = IMMEDIATE) -> None

Initiate a Hot-Join request from the current target.