1. Introduction

TEMU provides support for SpaceWire based devices. It also provides
helpful functions for RMAP commands decoding. The bus model interfaces are
available in: "temu-c/Bus/Spacewire.h". In addition to the interfaces a
simple SpaceWire Router model is provided.

Spacewire is a point to point bus. Two devices can be connected directly
while multiple devices can be connected through a Router.
A SpaceWire Route receives a packet on a port and forward it to another,
where the destination device is connected.

Spacewire uses wormhole routing. The sender device provides the list of
addresses (each address is an 8-bit value) required to reach the
destination. Each node in the middle is supposed to strip the first
address and use it to select the port used to forward the packet.

2. Interfaces

The interesting interfaces are defined in the temu-c/Bus/Spacewire.h
header.

While the SpaceWire protocol is character based, to have better performances
TEMU transfers full messages with a single call on the port interface.
Example of messages are a data packet, an RMAP packet and a time code.
Control characters like FCT (flow control) are abstracted away.

The SpaceWire packet structure is used to pass a packet between nodes.
The MsgType field identifies if the packet is a timecode, a complete data
packet (ending with EOP) or an incomplete data packet (ending with EEP).
The PktData field contains the packet data or the time code value.

A TEMU buffer is used to hold the data. This data structure has been
implemented to handle SpaceWire packets in a performant way.
It allows to acquire a reference to a part of the original data so that
a copy of data is not required for each node due to wormhole routing
stripping. It also free the memory used to store the original message
when no more references are active. This way, destination devices can
maintain the data as long as needed without coping it.

SpaceWire links are full-duplex. The SpaceWire link is modeled by simply
having each device implementing a port interface and holding a
reference to other end port. This allows comunication in both directions
simultaneously.

SpaceWire devices often have several connections port. The SpwPortIface is
meant to be implement for each port a device intends to provide.

temu-c/Bus/Spacewire.h header also define functions to help decode
RMAP packets:

Provided the previous calculated crc and a the current byte returns the next CRC value.

temu_spwRmapCRC

Calculates the CRC over the specified data.

3. Limitations

The following deviations from real hardware are known to exist with
this model:

When two different devices try to access the same device the two
accesses will happend simultaneously. This should not be the case,
the accesses should be sequential (the second device should wait for
the bus to be free).
This issue will be solved in the future when bus-reservation feature
will be implemented.

4. Commands

The following commands are provided:

Name

Description

spw-connect

Connect the two SpaceWire port interfaces provided as parameters

spw-disconnect

Disconnect the two SpaceWire port interfaces provided as parameters

5. Classes

5.1. SpwRouter

The SpwRouter class provides a simple SpaceWire Router that lets
the user configure the mapping between the packet-address and the port
that will be used to forward the packet.
More advanced features like Group Adaptive Routing or Packet Distribution
are not implemented.

6. Attributes

6.1. Properties

Name

Type

Description

internal.linkState

[32 x int32_t]

Holds the link state of the ports

object.timeSource

object

Time source object (a cpu or machine object)

ports

[32 x iref]

Connected SpaceWire devices

routingTable

[256 x uint8_t]

Configure packet-address to forwarding-port mapping

6.2. Interfaces

Name

Type

Description

SpwPortIface

SpwPortIface

Input spacewire ports interfaces

6.3. Ports

Prop

Iface

Description

-

-

-

7. Examples

This example shows how to create a simple SpaceWire Router and a Grspw2 device
and connect them.