Skip to content

OpenSPP User Guide

This guide describes how to integrate the OpenSPP core spp_core into an FPGA design: sources, generics, clock and reset, interfaces, the programming sequence, the protection scope, the performance, the integration constraints and the conformance statement for CCSDS 133.0-B-2 (Annex A, PICS proforma) and ECSS-E-ST-50-53C. The architecture is described in architecture.md, the registers in the generated register map.

1. Sources

Library Sources Order
olo Open Logic, fork open-space-hdl/open-logic-ft, tag 4.8.0-ft.2 (1f4a6c3), based on Open Logic 4.8.0 (submodule open-logic/): the areas base, axi and ft open-logic/compile_order.txt
openspp hdl/<module>/src/*.vhd of every module of component_list.txt compile_order.txt: the modules in the order of component_list.txt, within a module packages first

All sources are VHDL-2008 and contain no vendor primitive. spp_nchar is needed only to connect a SpaceWire port with an N-Char stream, such as the OpenWire core; spp_packetizer only to send data units larger than a packet, for example compressed images, as segmented Space Packets (section 4.7).

2. Generics

Generic Default Description
DataWidth_g 32 Width of all streams in bits: 8 to 128, a multiple of 8
NumTx_g, NumRx_g 1 Send and receive ports (1 to 16)
TxOctetString_g, RxOctetString_g all '1' Service of each port, bit p for port p: '1' Octet String Service, '0' Packet Service
TxBufferBytes_g 4096 Buffer of each send port in bytes: B times a power of two beats, at least max(2, nextpow2(ceil(7 / B))) and at most nextpow2(TxMaxPackets_g x ceil(65542 / B)) beats (more are never written). An SDU longer than the buffer is rejected
TxMaxPackets_g 8 SDUs a send buffer holds: 2 to max(2, TxBufferBytes_g / B)
RxBufferBytes_g 4096 Receive buffer in bytes, shared by all receive ports: B times a power of two beats, at least max(2, nextpow2(ceil(7 / B))) and at most nextpow2(RxMaxPackets_g x ceil(65542 / B)) beats. A packet longer than the buffer is discarded
RxMaxPackets_g 8 Packets the receive buffer holds: 2 to max(2, floor(RxBufferBytes_g / B / ceil(7 / B)))
Encapsulation_g true CPTP layer of ECSS-E-ST-50-53C; false removes it (section 4.3)
NumDest_g 1 Destinations of the CPTP layer (1 to 16)
SpwAddrBytes_g 4 Maximum Target SpaceWire Address of a destination in bytes (0 to 16)
MaxLength_g 65542 Reset value of the Maximum Packet Length in bytes (7 to 65542)
RoundRobin_g '0' Reset value of the Packet Multiplexing Scheme: '0' fixed priority (port 0 first), '1' round robin
Tla_g 0xFE Reset value of the own Target Logical Address of the receive filter
TxPathDefault_g, RxPathDefault_g true Initial entries of the APID tables: true enables the managed data path of every APID to destination 0 and to receive port 0, false disables all paths
ClkFreqHz_g 100.0e6 Frequency of Clk; it has no effect, because the scrubbers of the APID tables run free (Open Logic ScrubPeriod_g = 0.0)

B is DataWidth_g / 8, the bytes of a beat. A value outside the bounds of the buffer generics stops the elaboration with a message that names the bound. Every value of DataWidth_g, NumTx_g, NumRx_g, NumDest_g, SpwAddrBytes_g and of the boolean generics is verified in simulation, and the buffer generics at their bounds. Not verified: buffers deeper than 2^29 beats are excluded by an assertion (the depth limit of the Open Logic packet FIFO), which is not elaborated, because such a buffer exceeds the memory of a simulation host.

With the defaults every APID has an enabled path after the reset, so a node sends and receives without software. A flight configuration sets TxPathDefault_g and RxPathDefault_g to false and enables the managed data paths of the mission by software.

3. Clock and reset

All of the core runs in Clk; there is no clock domain crossing. The core has two reset inputs, both synchronous and high-active (Open Logic convention); synchronise their release to Clk, for example with olo_base_reset_gen and SyncTmr_g = true.

Input Resets Use
Rst The whole core Power-up and system reset. A packet that is being sent on M_Link is cut without its end
DpRst Every function except the link output stage; default '0' Restart of the data path while the link stays in operation, for example by a reset command of the system. A packet that is being sent on M_Link ends with an EEP

Both take effect when applied for one clock cycle, and a longer reset has the same effect. After the release the core initialises both APID tables (2048 clock cycles, TABLE_STATUS.TX_BUSY and RX_BUSY). The send ports accept SDUs meanwhile; packets are sent and delivered once the tables are ready. After DpRst the core is in the same state as after Rst: all buffers are empty, every entry of the APID tables is the initial entry of TxPathDefault_g and RxPathDefault_g (Packet Sequence Counts 0), and every register has its reset value, including the counters, EVENTS, IRQ_EN and the destinations (section 5).

Every path takes one beat per clock cycle while its output is ready; section 7 gives the clock cycles per packet. At 100 MHz and 32 bits the link ports carry up to 3.2 Gbit/s in each direction.

The reset edge is the rising edge of Clk at which a reset input is first sampled '1', the release edge the first edge after it at which neither input is sampled '1'. A packet is open on M_Link from the cycle in which its first beat is presented until its last beat is transferred.

  • DpRst: a beat that M_Link presents at the reset edge stays presented unchanged until it is transferred (AXI4-Stream). When a packet is open and that beat is not its last, the link output stage then ends the packet with one EEP beat: the byte 0x00 in byte lane 0, TLast, M_Link_User(0) '1' and the destination index of the packet in M_Link_User(4:1). The EEP beat comes in the cycle after the reset edge, or in the cycle after the transfer of the pending beat, also while DpRst is still applied. A SpaceWire or SpaceFibre port sends the valid byte of that beat before the EEP (an OpenFibre virtual channel requires at least one valid byte in a last beat), so the far end receives the bytes transferred before the reset, one fill byte 0x00 and the EEP, and discards the packet. No byte of the interrupted packet follows the EEP, and no SDU that was in a send buffer at the reset edge is sent. Between packets, or when the last beat of the packet is pending, DpRst sends nothing on M_Link.
  • Rst: M_Link_Valid is '0' from the cycle after the reset edge. A packet that is being sent is cut without its last beat and without an EEP, also when DpRst is applied at the same time. A subnetwork may join the cut packet to the next one; the far end usually discards the joined packet, and the first packet after the reset is lost with it. Use DpRst to reset the core while the link is in operation.
Order of the inputs M_Link The core leaves the reset
DpRst alone EEP beat for an open packet At the release of DpRst
Rst alone, or both applied at the same edge Cut, no EEP beat At the later release
Rst applied while DpRst is applied Cut from the reset edge of Rst on; an EEP beat that is not yet transferred is withdrawn At the later release
DpRst applied while Rst is applied No beat: no packet is open At the later release
Both applied, Rst released first, DpRst one or more cycles later No beat At the release of DpRst
Both applied, DpRst released first No beat At the release of Rst

Reset domains of the interfaces, for the reset groups of a system:

Interface Reset by
M_Link_* Rst only
S_Link_*, S_Tx_*, M_Rx_*, S_AxiLite_*, Irq, Err_* Rst and DpRst

The N-Char adapter spp_nchar belongs to the link: reset it with Rst only. It sends the EEP beat as the data character 0x00 followed by an EEP marker.

3.2 The other ports during a reset

From the cycle after the reset edge as long as a reset input is '1':

Port During the reset After the release
S_Tx_Ready of every send port '0': the source waits The next beat taken is the first beat of an SDU
S_Link_Ready with the CPTP layer '1': every beat is discarded and not counted The next beat is the first beat of a packet
S_Link_Ready without the CPTP layer '0': the link waits The next beat is the first beat of a packet
M_Rx_Valid of every receive port '0': an SDU in delivery ends without its last beat SDUs of the packets received after the release
S_AxiLite_* Ready and response outputs '0': an access accepted before the reset edge gets no response The registers have their reset values
Irq, Err_Valid '0' Events of the traffic after the release
  • A source that keeps sending an SDU through a reset continues it after the release as a new SDU: an Octet String port sends the rest as an Octet String of its own; at a Packet Service port the rest is checked as a Space Packet and rejected unless it happens to form one. Reset the sources of the send ports with the core (section 8).
  • The rest of a packet that was arriving on S_Link when the reset came is checked after the release as a packet of its own. It is discarded and counted once with the reason of the first failed check (architecture, decision D8): with the CPTP layer its first bytes are taken as the CPTP header (typically 0x11, 0x12 or 0x13), without it as the Packet Primary Header (typically 0x15 or 0x16). A rest whose bytes happen to form a valid packet for an enabled path is delivered; keep the far end from sending to the core while it is in reset (section 8).
  • Beats and packets discarded during the reset are not counted, and the first packet of every APID after the reset sets no loss indicator.

4. Interfaces

All data interfaces are AXI4-Stream ports with TKeep. A packet of the stream is one SDU or one packet: TLast marks its last beat, all bytes of a beat are valid except in the last beat, whose valid bytes are contiguous from byte lane 0. Byte lane 0 (TData(7:0)) holds the first byte of the beat, and the first byte of a packet is the first byte transmitted on the network. At the inputs (send ports, S_Link) a last beat without valid bytes (AXI4-Stream null bytes) is accepted: it ends the SDU or packet, which consists of the bytes of the earlier beats. The outputs never carry a beat without valid bytes. An SDU without any byte is rejected (0x02, SPP 3.2.3.1 and 4.1.4.1.2). Port p of a vector port uses the bits p of Valid, Ready and Last and the slice p of Data, Keep and User.

4.1 Send ports (S_Tx_*)

A send port of the Octet String Service takes OCTET_STRING.request: the Octet String (1 to 65536 bytes, including a Packet Secondary Header that the user places at its start) and the parameters in TUser, held constant during the SDU:

Bits Field Clause
10:0 APID SPP 3.4.2.2
11 Secondary Header Indicator SPP 3.4.2.3
12 Packet Type: '0' telemetry, '1' telecommand SPP 3.4.3.2.2, 4.1.3.3.2
13 Packet Name valid: bits 27:14 are used instead of the Packet Sequence Count (telecommand only) SPP 4.1.3.4.3.2
27:14 Packet Name SPP 4.1.3.4.3

The core builds the Packet Primary Header with version '000', the Sequence Flags '11', the Packet Sequence Count of the APID from the send APID table (or the Packet Name) and the Packet Data Length.

A send port of the Packet Service takes PACKET.request: a complete Space Packet that the user has formatted (7 to 65542 bytes). It is sent intact; TUser is not used, the APID is the one in the packet header.

Every SDU is checked while it arrives and buffered completely before it is sent. A rejected SDU is dropped from the buffer, counted and reported (section 4.5); it never reaches the link.

4.2 Receive ports (M_Rx_*)

A receive port of the Packet Service delivers PACKET.indication: the intact Space Packet. A receive port of the Octet String Service delivers OCTET_STRING.indication: the Packet Data Field without the Packet Primary Header. TUser, constant during the SDU:

Bits Field Clause
10:0 APID SPP 3.3.2.2, 3.4.2.2
11 Secondary Header Indicator (Octet String Service) SPP 3.4.2.3
12 Packet Loss Indicator (Packet Service) or Data Loss Indicator (Octet String Service) SPP 3.3.2.3, 3.4.2.4
13 Error: double bit error in the receive buffer during this SDU; valid with TLast none
21:14 User Application value of the CPTP packet (0 without the CPTP layer) CPTP 5.2.3

The loss indicator is set when the continuity check of the APID is enabled (RX_TABLE_ENTRY.CHECK) and the Packet Sequence Count is not the last count plus one (modulo 16384). The first packet after the reset or after the check is enabled sets no indicator. Disable the check for paths of telecommand packets that carry a Packet Name.

The link ports carry one packet of the network per stream packet, at the width DataWidth_g. TUser bit 0 is the error end of packet flag, valid with TLast ('0' EOP, '1' EEP). With Encapsulation_g true the packets are CPTP packets: Target SpaceWire Address (0 to SpwAddrBytes_g bytes), Target Logical Address, Protocol Identifier 0x02, Reserved 0x00, User Application value, Space Packet. M_Link_User(4:1) carries the destination index of the packet in both configurations, so a subnetwork other than SpaceWire can route by it when the CPTP layer is removed.

A packet that DpRst interrupts on M_Link ends with an EEP beat of one byte (section 3.1).

Connect the link ports to the packet ports of a SpaceFibre port, or through spp_nchar to a SpaceWire port with an N-Char stream (section 4.6). A received packet may start with path address bytes that the network has not removed; CONFIG.RX_STRIP removes up to 15 leading bytes in front of the CPTP header.

4.4 Register file and interrupt

S_AxiLite_* is an AXI4-Lite slave with an 11-bit byte address and 32-bit registers; Irq is the OR of the enabled event flags. The register map is in register_map.md, the C header in sw/spp_regs.h. A read of TX_TABLE_ENTRY or RX_TABLE_ENTRY waits until a pending table access is complete.

4.5 Error event output

Err_Valid is a one-cycle event for every rejected SDU and every discarded packet, with the reason in Err_Code, the send or receive port in Err_Port (0 when unknown) and the APID in Err_Apid (0 when unknown). Each reason has a counter in the register file (ERR_TX1 to ERR_RX6); LAST_ERROR holds the last event.

Code Reason Code Reason
0x01 SDU longer than the maximum packet length or the buffer 0x10 Packet ended with an EEP (CPTP status 0x01)
0x02 Space Packet shorter than 7 bytes, or Octet String without any byte 0x11 Protocol Identifier other than 2
0x03 Packet Version Number not '000' 0x12 Reserved field not zero (CPTP status 0x02)
0x04 Length not the Packet Data Length plus 7 0x13 Target Logical Address not accepted
0x05 Idle Packet with SHF or SHI set 0x14 Shorter than the CPTP header or than 7 bytes
0x06 Packet Name for a telemetry packet 0x15 Packet Version Number not '000'
0x07 APID without enabled managed data path 0x16 Length not the Packet Data Length plus 7
0x08 Double error in the descriptor or the table entry 0x17 Longer than the maximum packet length or the buffer
0x18 Idle Packet
0x19 APID without enabled managed data path or with an invalid port
0x1A Sequence Flags other than '11' for an Octet String port
0x1B Double error in the descriptor or the table entry

The receiving end checks in a fixed order (architecture, decision D8): the CPTP header (0x14, 0x11, 0x12, 0x13), then the Space Packet (0x14 to 0x18), then the APID table (0x1B, 0x19, 0x1A). The first failed check decides; an EEP takes precedence over every other reason.

4.6 N-Char adapter (spp_nchar)

spp_nchar converts the link stream to the N-Char stream of the OpenWire core and back: one data character per beat, the end of packet marker as a separate beat with TLast = '1' (TData(0) = '0' EOP, '1' EEP). It has the generic DataWidth_g of the core. A received marker without data characters is discarded. A link packet that ends with a beat without valid bytes gets its marker after the bytes of the earlier beats; a link packet without any byte sends nothing.

4.7 Packetizer (spp_packetizer)

spp_packetizer is a user of the Packet Service in front of a send port of the core (specification, architecture). It cuts every data unit of its input into segments of ChunkBytes_g bytes and sends every segment as one complete Space Packet; the core transfers these packets unchanged. A receiver finds the boundaries of the data units from the Sequence Flags alone, without decoding the data.

Generic Default Range Description
DataWidth_g 32 8 to 128, multiple of 8 Width of the streams, the DataWidth_g of the core
ChunkBytes_g 4096 multiple of DataWidth_g/8, at most 65536 less SecHdrBytes_g and less 2 with Crc_g Bytes of a segment; the last segment of a data unit holds the rest
BufferBytes_g 8192 DataWidth_g/8 times a power of two, at least ChunkBytes_g Segment buffer. At twice ChunkBytes_g the next segment enters while a packet leaves; at ChunkBytes_g the input waits while every packet leaves
MaxChunks_g 8 2 to 64 Segments the buffer holds at most (short data units)
SecHdrBytes_g 0 0 to 64 Bytes of the Packet Secondary Header from SecHdr_Data; 0 for none
Crc_g false boolean CRC of two bytes at the end of every User Data Field
Port Description
S_* Data units: Valid, Ready, Data, Keep, Last as at a send port; S_Error with the last beat marks an aborted data unit. A last beat without byte enables ends the data unit; a data unit without any byte sends nothing
M_* Space Packets, to a send port of the core with TxOctetString_g bit = '0' (TUser of that port is not used)
Cfg_Apid, Cfg_Type APID and Packet Type of the packets
SecHdr_Data Packet Secondary Header, bits 7:0 its first byte: a time code sent as the bytes T0 T1 T2 T3 is applied as SecHdr_Data = T3 & T2 & T1 & T0
Hdr_Sample '1' for one clock cycle per packet: Cfg_Apid, Cfg_Type and SecHdr_Data are sampled at the rising edge of Clk that ends this cycle; the first beat of the packet follows at least two cycles later. A time code on SecHdr_Data gives the time of that edge
Aborted '1' for one clock cycle per accepted last beat with S_Error
Ecc_Sec, Ecc_Ded One cycle per corrected or detected error, bit 0 segment buffer, bit 1 descriptors
ErrInj_Data, ErrInj_Desc, ErrInj_Double Test injection of one or two data-bit errors into the next word written into the buffer or the descriptors

Every packet carries the Packet Version Number '000', Cfg_Type, the Secondary Header Flag '1' when SecHdrBytes_g is greater than 0, Cfg_Apid, the Sequence Flags of its segment ('11' for a data unit of one segment, '01' first, '00' continuation, '10' last), the Packet Sequence Count of the instance (0 after the reset, then incremented modulo 16384) and the Packet Data Length of SecHdrBytes_g + segment + 2 with Crc_g, minus one. An aborted data unit is sent like any other and closed with '10' or '11'; the user counts Aborted to report it.

With Crc_g the last two bytes of every User Data Field are a CRC over the bytes of the segment: generator x^16 + x^12 + x^5 + 1, initial value all ones, no final inversion, the most significant byte first (the parameters of the packet error control of ECSS-E-ST-70-41C, Annex B.1). It is computed before the segment is stored, so a receiver detects a segment that was corrupted in the buffer. It covers neither header.

The packets are Space Packets of CCSDS 133.0-B-2, not PUS packets: ECSS-E-ST-70-41C uses only the Sequence Flags '11' and transfers large data with its service type 13.

A receiver of the packets (a receive port of the Packet Service, or the ground):

  1. takes the Sequence Flags: '01' or '11' starts a data unit, '10' or '11' ends it;
  2. checks the Packet Sequence Count of the APID: a gap means a lost segment, and the data unit is incomplete;
  3. with the CRC, checks every segment and discards or marks the data unit of a segment whose CRC does not match.

5. Programming sequence

  1. After a reset (Rst or DpRst) wait until TABLE_STATUS.TX_BUSY and RX_BUSY are '0'. Both resets return every register and every table entry to its reset value, so the following steps follow every reset.
  2. Read ID (0x53505001), GENERICS, SERVICES, TX_BUFFER and RX_BUFFER to identify the core and its configuration.
  3. Write MAX_LENGTH and CONFIG (multiplexing scheme, Idle Packet delivery, Target Logical Address filter, RX_STRIP).
  4. CPTP layer: write each destination n (DEST_CTRL with Target Logical Address, User Application value and address length, DEST_ADDR0 to DEST_ADDR3).
  5. Managed data paths, for every APID of the sending end: write the APID to TX_TABLE_APID, read TX_TABLE_ENTRY, write TX_TABLE_ENTRY (ENABLE, DEST, COUNT), read TX_TABLE_ENTRY again. The same sequence with RX_TABLE_APID and RX_TABLE_ENTRY (ENABLE, PORT, CHECK) configures the receiving end. Each read waits for the preceding access, so no write is lost; TABLE_STATUS.TX_OVERRUN and RX_OVERRUN flag a write that arrived while an access was pending.
  6. Write IRQ_EN for the events of interest and clear EVENTS by writing ones.
  7. In operation read the counters (cleared by a write), LAST_ERROR, ECC_STATUS and ECC_COUNT (channel selected by ECC_SELECT). SCRUB.ENABLE controls the scrubbers of the APID tables.

A write of TX_TABLE_ENTRY replaces the whole entry including the Packet Sequence Count. Change the entry of an APID while its source sends nothing, or the count of a packet sent between the read and the write is used again.

6. Protection scope

The core is designed for radiation environments together with the triple modular redundancy (TMR) of the synthesis tool, like the Open Logic ft entities it is built on. It protects the parts in the first rows itself and relies on TMR for all other logic:

Part Protection Indication and test
Data and descriptor buffers of every send port and of the receiving end (olo_ft_fifo_packet, olo_ft_fifo_sync); send and receive APID tables (olo_ft_ram_sdp_scrub, scrubbed in idle cycles) SECDED ECC of the Open Logic ft entities: a single error is corrected, a double error is detected and contained: in a send data buffer the packet ends with an EEP, in the receive data buffer the SDU is delivered with the error bit of M_Rx_TUser set; in a descriptor or an APID table entry the SDU is rejected (0x08) or the packet discarded (0x1B). A table entry with a double error stays so until it is written again ECC_STATUS (double error per channel), ECC_SELECT and ECC_COUNT (SEC and DED counters per channel, channels 0 to 7), EVENTS.ECC_SEC and ECC_DED with Irq, Err_* with 0x08 and 0x1B; error injection through the ECC_INJECT register
Clock domain crossings and reset synchronisers None in the core: it runs in one clock domain, and the releases of Rst and DpRst are synchronised outside the core (section 3). Use triplicated synchronisers there (SyncTmr_g = true, for example olo_base_reset_gen): three synchroniser chains and a majority voter. Their registers carry the Synplify attribute syn_radhardlevel = none, so the TMR of the synthesis tool adds no voters between the stages none
State machines Recovery state through the when others branch and the reset none
All other logic: registers of the control and data paths, counters, pointers, pipeline registers TMR of the synthesis tool (for example syn_radhardlevel = tmr with Synplify, or the equivalent setting of the tool chain). The core adds no protection of its own for this logic; without TMR, an upset in it is not covered synthesis report

The integrator:

  • enables the TMR of the synthesis tool for the core and the logic around it,
  • checks in the synthesis report that TMR was applied, that the synchroniser chains of the crossings were not triplicated a second time, and that no register-based storage meant to be protected by TMR was inferred as a RAM primitive,
  • requests safe state machines, so that synthesis keeps the when others branches (AMD Vivado: property FSM_SAFE_STATE = default_state on the state registers; Synplify: attribute syn_encoding = safe),
  • protects the configuration memory of SRAM-based FPGAs by scrubbing; this is part of the FPGA design, not of the core.

The packetizer spp_packetizer protects its segment buffer and descriptors with the same SECDED code. A double error is reported on Ecc_Ded, and the packet is still sent; this is the protection of the packetizer by design. Crc_g is the detection at the receiver: the CRC is computed before the buffer, so it exposes a double error in the segment and in the length or CRC of its descriptor. A double error in a descriptor gives one of two packets: a length with another number of beats makes the Packet Data Length differ from the bytes, and the send port of the core rejects the packet (0x04); a length with the same number of beats (an error in its lowest bits) gives a well-formed packet with bytes missing or with bytes that were not part of the segment, which the core sends and which, without Crc_g, only Ecc_Ded reports. The packet boundaries in its buffer are kept in flip-flops (TMR of the synthesis tool), so a double error never changes the framing. The Packet Secondary Header, Cfg_Apid and Cfg_Type come from the user and are protected neither by the SECDED code nor by the CRC.

The ECC paths are verified in simulation by error injection. Whether the protection as a whole meets the requirements of a mission is shown by a radiation test with the core in operation (TRL 5).

7. Performance

The figures are clock cycles of Clk for back-to-back packets of one length without stalls at the outputs, with B = DataWidth_g / 8 bytes per beat. They follow from the design and are measured by the core test TC-CO-12 at 32, 64 and 128 bits (verification report). All rates scale with the frequency of Clk; the core has no clock ratio constraint.

7.1 Packet lengths

Length Bytes
Space Packet Lsp Octet String plus 6 (Packet Primary Header); at a Packet Service port the SDU itself
Link packet Llink With the CPTP layer Lsp + 4 + A (Target Logical Address, Protocol Identifier, Reserved, User Application value; A address bytes of the destination, 0 to SpwAddrBytes_g); without it Lsp
Delivered SDU The receiving end removes CONFIG.RX_STRIP + 4 bytes (CPTP layer) and, at an Octet String port, the 6 bytes of the Packet Primary Header

7.2 Data rate per interface

With N = ceil(Llink / B) link beats of a packet:

Interface Beats per clock cycle Clock cycles per packet
S_Tx_* (each send port) 1 while its buffer has room (TxMaxPackets_g SDUs, TxBufferBytes_g) ceil(SDU / B): no cycle between SDUs
M_Link_* 1 during a packet max(N + e, 5), e 0 or 1 (below)
S_Link_* 1 while the receive buffer has room (RxMaxPackets_g packets, RxBufferBytes_g) N, at most one cycle more for the removal of the CPTP header
M_Rx_* (the port of the packet) 1 during an SDU max(ceil(Lsp / B) + 1, 5)

Both directions therefore carry at least one packet per max(N + 1, 5) clock cycles. The receiving end delivers a packet in max(ceil(Lsp / B) + 1, 5) cycles: the one cycle is the read of the next packet from the receive buffer. The sending end needs e = 1 cycle per packet to pass from one SDU in the send buffer to the next; this cycle is hidden (e = 0) when a header insertion outputs a final beat with the bytes it shifted past the last input beat. A header of h bytes in front of n bytes does so when ceil((n + h) / B) > floor(h / B) + ceil(n / B), with h = 6 for the Packet Primary Header of an Octet String and h = 4 + A for the CPTP header in front of the Space Packet. Packet Service ports without the CPTP layer always have e = 1. The lower limit of five cycles per packet is the preparation of a packet (choice of the port, descriptor, access to the APID table) at the sending end and the lookup of the receive APID table at the receiving end; both overlap the transfer of the previous packet, so they limit only packets of up to four link beats.

Measured cycles per packet with the CPTP layer and a destination without Target SpaceWire Address (TC-CO-12):

Packets 32 bits: N M_Link M_Rx 128 bits: N M_Link M_Rx
Octet Strings of 1 byte 3 5 5 1 5 5
Octet Strings of 61 bytes 18 19 18 5 5 6
Octet Strings of 256 bytes 67 67 67 17 17 18
Octet Strings of 1024 bytes 259 259 259 65 65 66
Space Packets of 67 bytes (Packet Service) 18 19 18 5 6 6
Space Packets of 1030 bytes (Packet Service) 259 260 259 65 66 66

From end to end the slower of both ends sets the rate: at 100 MHz Octet Strings of 1024 bytes pass at 3.16 Gbit/s of SDU data at 32 bits (259 cycles) and at 12.4 Gbit/s at 128 bits (66 cycles).

7.3 Several active ports

  • The multiplexer chooses the next packet when the transfer of the current packet starts, among the send ports with a complete SDU in their buffer. A change of the port costs no cycle: two ports that alternate keep the cycles per packet of one port.
  • Round robin (CONFIG.ROUND_ROBIN = '1'): the ports with a complete SDU take turns packet by packet. With k active ports each gets every k-th packet, so its share of the link is in proportion to the lengths of its packets (fair per packet, not per byte).
  • Fixed priority (CONFIG.ROUND_ROBIN = '0'): the send port with the lowest index and a complete SDU is chosen. A port that always has a complete SDU blocks all higher ports; their S_Tx_Ready stays low once their buffers are full.
  • Receiving end: all receive ports share one buffer and get their packets in the order of arrival. A receive port that does not take its SDU stops the delivery to all ports (section 8).

7.4 Latency

Both ends store and forward: a packet is sent only after the last beat of its SDU is in the send buffer, and an SDU is delivered only after the last beat of its packet is in the receive buffer. The latency of a packet therefore contains its own length twice, once at each end, besides the preparation and the pipeline stages.

7.5 N-Char adapter

spp_nchar converts a link packet of n bytes into n data characters and the end of packet marker, one character per clock cycle; at widths above 8 bits one cycle separates two packets, so a packet needs at most n + 2 cycles. In the receive direction the adapter takes one character per clock cycle (TC-AD-03).

8. Integration constraints

Constraint Reason
TMR of the synthesis tool enabled for the core The core protects its buffers and APID tables itself and relies on TMR for all other logic (section 6)
Serve every receive port, or place a buffer behind a port whose user can stall for long All receive ports share one receive buffer: a packet waits at its port and the packets behind it wait for it
TxBufferBytes_g holds the longest SDU of the port, RxBufferBytes_g the longest Space Packet The core sends and delivers only complete SDUs and packets; longer ones are rejected (0x01) or discarded (0x17)
Hold TUser of a send port constant during an SDU The parameters are recorded with the SDU
The user supplies the Packet Secondary Header at the start of the Octet String and keeps the Secondary Header Flag of an APID static SPP 4.1.4.2, 4.1.3.3.3.3: the core does not interpret the secondary header
Err_* shows one event per cycle Events of several sources in the same cycle are all counted; the output and LAST_ERROR show the one of the lowest source (send ports, decapsulation, receiving end)
The subnetwork returns S_Link_Ready flow control to its sender The receiving end stalls the link while its buffer is full
The ECC injection (ECC_INJECT) is for tests only An injected double error discards an SDU or packet or ends it with an EEP
Packetizer: its send port and the receive ports of its APID use the Packet Service SPP 4.1.3.4.2.3: the Octet String Service never carries the Sequence Flags '01', '00' and '10'; a receive port of the Octet String Service discards such packets (0x1A)
Packetizer: its APID is used by no other source on the managed data path, and it is not the Idle APID The count of the instance is the Packet Sequence Count of the APID (SPP 4.1.3.4.3.3); the packets carry user data
Packetizer: MAX_LENGTH of the core and TxBufferBytes_g of its send port hold the longest packet, 6 + SecHdrBytes_g + ChunkBytes_g bytes plus 2 with Crc_g Longer packets are rejected by the send port (0x01); a send buffer of two such packets lets the next packet enter while one leaves
Packetizer: Cfg_Apid and Cfg_Type change only while the packetizer holds no data They are sampled per packet; a change inside a data unit would split it between two APIDs
Packetizer: reset it together with the core (Rst or DpRst), or only while no packet is between it and the send port A packet cut off by the reset of the packetizer would merge with the next one in the send buffer, which the core rejects (0x04)
DpRst is synchronous to Clk like Rst; tie it to '0' or leave it open when it is not used Both are synchronous resets of the Open Logic convention; DpRst has the default '0'
Reset the sources of the send ports and the sinks of the receive ports together with the core, or reset the core only while no SDU is in transfer at its user ports After a reset the core takes the rest of an interrupted SDU as a new SDU and ends an SDU in delivery without its last beat (section 3.2)
Reset the link side (SpaceWire or SpaceFibre port, spp_nchar) with the reset of the link, never with DpRst The EEP that ends an interrupted packet must reach the far end (section 3.1)
The port behind M_Link sends the valid bytes of a last beat before its EEP The far end receives one fill byte 0x00 before the EEP of an interrupted packet and discards the packet (CPTP 5.5.4.4a); a counter of the bytes of discarded packets at the far end counts it
The far end of the link sends nothing to the core while the core is in reset With the CPTP layer the core discards the beats it takes during a reset without a count; the rest of an interrupted packet is checked as a packet of its own after the release (section 3.2)
No register access while a reset is applied or about to be applied; run the programming sequence after every reset (section 5) The register port answers no access during a reset, an access accepted before the reset edge gets no response, and every register returns to its reset value

9. Conformance

9.1 Space Packet Protocol (CCSDS 133.0-B-2, Annex A)

OpenSPP implements the Packet Service and the Octet String Service at the sending and the receiving end. The support column of the requirements list of the PICS proforma (Annex A2.2) for a core with ports of both services:

Item Description Reference Status Support
SPP-1 Space Packet SDU 3.2.2 M Yes
SPP-2 Octet String SDU 3.2.3 M Yes
SPP-3 APID (Packet Service) 3.3.2.2 M Yes
SPP-4 Packet Loss Indicator 3.3.2.3 O Yes, per APID (RX_TABLE_ENTRY.CHECK)
SPP-5 QoS Requirement 3.3.2.4 O No: one quality of service
SPP-6 Octet String 3.4.2.1 M Yes, 1 to 65536 bytes
SPP-7 APID (Octet String Service) 3.4.2.2 M Yes
SPP-8 Secondary Header Indicator 3.4.2.3 M Yes
SPP-9 Data Loss Indicator 3.4.2.4 O Yes, per APID (RX_TABLE_ENTRY.CHECK)
SPP-10 PACKET.request 3.3.3.2 M Yes
SPP-11 PACKET.indication 3.3.3.3 M Yes
SPP-12 OCTET_STRING.request 3.4.3.2 M Yes
SPP-13 OCTET_STRING.indication 3.4.3.3 M Yes
SPP-14 Space Packet 4.1 M Yes
SPP-15 Packet Primary Header 4.1.3 M Yes
SPP-16 Packet Data Field 4.1.4 M Yes
SPP-17 Packet Secondary Header 4.1.4.2 C1 Yes, supplied by the user in the Octet String, or from SecHdr_Data by spp_packetizer
SPP-18 User Data Field 4.1.4.3 C2 Yes
SPP-19 Packet Assembly Function 4.2.2 M Yes
SPP-20 Packet Transfer Function 4.2.3 M Yes
SPP-21 Packet Extraction Function 4.3.2 M Yes
SPP-22 Packet Reception Function 4.3.3 M Yes
SPP-23 Maximum Packet Length (octets) Table 5-1 M Yes: 7 to 65542 (MAX_LENGTH), limited by the buffers
SPP-24 Packet Type of Outgoing Packets Table 5-1 M Yes: per Octet String in TUser (Table 5-1 note 2), in the header of a Space Packet of the Packet Service
SPP-25 Packet Multiplexing Scheme Table 5-1 O Yes: fixed priority or round robin (CONFIG.ROUND_ROBIN)
SPP-26 Service Type Table 5-1 M Yes: per port (TxOctetString_g, RxOctetString_g); the APID tables assign each APID to a port

The Packet Secondary Header Contents (Table 5-1) are agreed between the users by management; the core passes them unchanged. The Sequence Flags of segmented user data (4.1.3.4.2.2) are set by the user of the Packet Service; the packetizer spp_packetizer is such a user (section 4.7), the core itself never segments. The interpretations of the standard are listed in the sections "Interpretation of the standard" of the module specifications, for example that the APID parameter of PACKET.request is the APID of the submitted packet.

9.2 CCSDS packet transfer protocol (ECSS-E-ST-50-53C)

With Encapsulation_g true the core is initiator and target of the CCSDS packet transfer protocol:

Clauses Function Implementation
5.1, 5.2 Service parameters and primitives CCSDS_PACKET_SEND.request is the transfer of a Space Packet of the sending end with the destination of its APID; CCSDS_PACKET_RECEIVED.indication is the delivery at a receive port with the User Application value in TUser; status codes 0x01 and 0x02 are the error events 0x10 and 0x12
5.3, 5.4 Fields and format Target SpaceWire Address of 0 to SpwAddrBytes_g bytes, Target Logical Address and User Application value per destination, Protocol Identifier 0x02, Reserved 0x00
5.5.2 Send request A request with a packet longer than the maximum is rejected and reported (0x01)
5.5.3 Transfer packet One CPTP packet per Space Packet, ended with an EOP; an EEP after a double error in the send buffer, or when DpRst interrupts the packet on the link (section 3.1)
5.5.4 Receive packet Packets ended with an EEP or with a Reserved field other than zero are discarded and reported to the user (error events, counters, interrupt); packets with another Protocol Identifier are discarded and reported as well; the Target Logical Address filter is optional (CONFIG.TLA_CHECK); the rest of a packet interrupted by a reset of the core is checked as a packet of its own (section 3.2)
Annex A Managed parameters Minimum Space Packet length 7 bytes (fixed, SPP 4.1.2); maximum Space Packet size MAX_LENGTH

The compliance matrix lists the requirements and the test cases of every clause.

10. Verification and tools

python run.py -p 4                          # regression with GHDL
python run.py --questa -p 1                 # regression with QuestaSim, full optimisation
python run.py --questa --coverage -p 1      # code coverage with QuestaSim
python lint/lint.py                         # VSG
python lint/synth_check.py                  # synthesizability of the core, the adapter and the packetizer, bounds
python tools/compliance.py --check          # traceability of SPP and CPTP
python tools/regmap.py --check              # generated register map up to date
python run.py --compile-order               # compile_order.txt of the synthesis sources

--questa takes QuestaSim from VUNIT_MODELSIM_PATH (the directory of vsim) or from vsim on the PATH.