This document defines the architecture of OpenCompact, an implementation of the compressor of CCSDS 123.0-B-2,
Low-Complexity Lossless and Near-Lossless Multispectral and Hyperspectral Image Compression. Together with the
standard it is the basis for the implementation: it fixes the building blocks, their interfaces, the clauses each
block owns and the Open Logic entities each block is built from.
The complete compressor of CCSDS 123.0-B-2: image properties (section 3), predictor with full and reduced
prediction, the four local sum types, default and custom weight initialisation, weight exponent offsets, the
quantizer with lossless, absolute, relative and combined fidelity control including band-dependent error limits
and periodic error limit updating, sample representatives (section 4), the header with all optional tables, the
band-interleaved and band-sequential input orders and the sample-adaptive, hybrid and block-adaptive entropy coders
(section 5).
The adaptive entropy coder of CCSDS 121.0-B-3 with the preprocessor bypassed, as the block-adaptive coder of
CCSDS 123.0-B-2 5.4.3.4 requires.
Fault tolerance of the memories, the verification architecture and the verification against the CNES reference
software.
The decompressor. CCSDS 123.0-B-2 specifies the compressed image; a ground segment decompresses it with software.
The verification decompresses the compressed images of the testbenches with the decoder of the CNES reference
software.
The transport of the compressed image (Space Packets, file systems). The compressed image leaves the core as a
stream of words with an end-of-image marker; the user packs it into the transport format of the mission (CCSDS
123.0-B-2 2.4).
The encoding of supplementary information tables from their values: the core inserts the tables into the header
as the user encodes them (tools/ocp_generics.py shows the encoding).
OpenCompact contains no vendor code. All memories are Open Logic fault-tolerant entities and all interfaces are
valid / ready streams with AXI4-Stream handshake semantics. The core runs on any FPGA.
OpenCompact is an open CCSDS 123.0-B-2 compressor based on the Open Logic VHDL Library. The code lives in
open-space-hdl/opencompact under the PSI HDL Library License,
Version 1.0, the licence of Open Logic. Open Logic is pinned to the tag 4.8.0-ft.2 (1f4a6c3) of the branch
fault-tolerant of open-space-hdl/open-logic-ft, the fault-tolerant fork of Open Logic, based on Open Logic 4.8.0.
Requirement references are clause numbers of CCSDS 123.0-B-2, for example CCSDS 4.10.3, and equation numbers in
parentheses. Clauses of CCSDS 121.0-B-3 are written LDC 3.5.
Coding conventions: those of Open Logic (naming, two-process style, synchronous high-active resets, VSG rules),
entity prefix ocp_, VHDL library opencompact; see conventions.md.
"FT" (fault-tolerant) means the Open Logic olo_ft_* entities: SECDED ECC on every memory.
Term
Meaning
NX, NY, NZ
Image width, height and number of spectral bands (CCSDS 3.2)
D
Dynamic range of the samples in bits (CCSDS 3.3)
t
Index of a sample within its band, t = y NX + x (CCSDS 3.4)
BI, BSQ
Band-interleaved and band-sequential input order (CCSDS 5.4.2); BIP and BIL are BI with M = NZ and M = 1
Mapped quantizer index
Unsigned integer delta that the entropy coder encodes (CCSDS 4.11)
Entropy coder input sequence
Mapped quantizer indices, and with periodic updating the error limit values, in input order (CCSDS 5.4.1)
Codeword
Bit string of at most 64 bits appended to the compressed image
The compressor predicts every sample from neighbouring samples in the current band and from the P preceding bands,
quantizes the prediction residual with a step size given by the error limits and maps the quantizer index to an
unsigned integer, which the entropy coder encodes (CCSDS 4.1, 5.1). Near-lossless compression bounds the error of
every reconstructed sample by an absolute and/or relative error limit; the lossless mode has error limit zero.
Function
CCSDS clauses
Image dimensions, dynamic range, supplementary information tables
Header: image, predictor and entropy coder metadata
5.3
Input order of the entropy coder
5.4.2
Sample-adaptive, hybrid and block-adaptive entropy coders
5.4.3
Three properties of the standard shape the architecture more than any single feature:
Prediction depends on reconstructed values. In near-lossless compression the predictor works on sample
representatives, which depend on the quantization of the sample itself (CCSDS 4.9). The central local difference
of a sample is known only after its quantization, and the next band at the same position needs it. A sample is
therefore processed completely, including the weight update, before the next sample starts.
The predictor needs a line of every band. Local sums use the previous row of the same band, inter-band
prediction the central local differences of the P preceding bands at the same position. The memory grows with
NX NZ in BI order and with NX NY P in BSQ order.
The compressed image is exactly defined. Header, codewords and fill bits are specified to the bit, so the
output of the core can be compared bit by bit with an independent implementation.
A block implements one part of the standard. Its specification names the clauses it owns; no clause is owned by two blocks.
P2
Streams everywhere
Every data path between blocks is a valid / ready stream (Open Logic AXI4-Stream conventions).
P3
One clock domain
All blocks run in Clk.
P4
Configuration by generics
Every parameter of the standard is a generic of ocp_core; per-band tables are integer_vector generics whose last element repeats.
P5
Fault tolerance by construction
All memories are olo_ft_* entities (SECDED ECC) with their single and double error events at the ports of the core. State machines have a defined recovery state. All other logic relies on the TMR of the synthesis tool (user guide, section 6).
P6
Exact to the bit
The compressed image is identical to the one of the CNES reference software for the same configuration and image.
P7
No hidden state between images
Every image starts with the initial state of the standard; consecutive images are independent compressed images.
P8
Verifiable in isolation
Each module has a specification and a testbench that drives only its ports. Reference data comes from the CNES reference software and from an independent reference model.
P9
Reuse before design
A function available in Open Logic (memory, ECC, FIFO) is instantiated, not rewritten.
The samples enter in the input order of the compressed image (BI with sub-frame interleaving depth M, or BSQ). The
predictor is a pipeline: it reads the neighbours and the weights, predicts, quantizes, computes the sample
representative, updates the weights and writes the state back, one stage per clock cycle, and starts a sample as soon
as the samples it depends on have left the feedback loops. Its output is the entropy coder input sequence. The entropy
coder selected by EntropyCoder_g turns it into codewords, one item per clock cycle; the bit packer appends the
header and the codewords to the compressed image, adds the fill bits after the last codeword and outputs words of
8 to 64 bits.
ocp_channel packages the core for a system (section 7.5): an input adapter turns SDUs of a byte stream into samples
and image ends, an output width converter turns the words of the core into the beats of a byte stream with one packet
per compressed image, and an AXI4-Lite slave reports the configuration and counts the images and errors.
One clock domain Clk, synchronous high-active reset Rst
The core is a stream processor; crossings belong to the integration
D2
All image and compression parameters are generics of ocp_core; the header is a constant computed at elaboration and streamed before the body of every image
The parameters of a compressor are fixed for a mission or an instrument mode; constants remove the logic of unused options and make the header exact by construction
D3
The entropy coder is chosen by EntropyCoder_g; only the selected coder is instantiated
The three coders share no state; one per configuration keeps the footprint small
D4
The predictor is a pipeline without internal stalls; its issue stage starts a sample once the samples it depends on (previous sample of the band, sample of the previous band at the same pixel) have left the feedback loops
The dependencies of the standard limit the throughput, not the arithmetic: with enough distance between dependent samples every configuration runs at one sample per clock cycle, and the same datapath is exact for every input order and every option. Throughput is a function of the configuration (section 6, performance)
D11
The error sign of the weight update is computed from the high-resolution sum by comparisons with thresholds of the sample; when consecutive samples belong to the same band the weight loop speculates over the signs of the two samples ahead (four weight vectors); in BI order with M = NZ near-lossless compression processes the samples of a pixel in stride order
The weight update depends on one bit per sample, so the loop closes after the dot product and can be unrolled over the unknown signs; the stride order makes the bands of a pixel independent of each other in the pipeline
D12
The entropy coders concatenate their codewords into words of up to 96 bits before an output FIFO
The FIFO then absorbs the header of the next image, and the bit packer catches up with several codewords per clock cycle
D5
Widths of the datapath derived from D, Omega and R: the dot product is computed without overflow and wrapped to R bits as (37) requires; weight increments are saturated to the weight range before clipping
The predicted values are exact for every allowed parameter, including D = 32, Omega = 19 and R = 64
D6
Neighbours are kept in a memory of the current row of every band (BI) or of row 0 of the current and the previous band and the current row (BSQ), the window of the previous row and the previous sample per band; the central local differences of the P preceding bands in one word per pixel of a row (BI with M < NZ) or of a band (BSQ); the weight vector of every band in one word
One read and one write per memory and sample; memories sized by the image
D7
Error limits for periodic updating enter on their own stream in the order of the entropy coder input sequence and are forwarded into it
The user supplies them every 2^u frames (CCSDS 4.8.2.4.2) from any source
D8
The image ends with the last codeword: the bit packer adds the fill bits up to the output word boundary of the whole compressed image and marks the last interface word with its valid bytes; the header of the next image starts once its first sample is accepted
Consecutive compressed images on one stream, each self-delimiting by the end-of-image marker
D9
The low-entropy codes of the hybrid coder are state machines whose states are the active prefixes; their code and flush tables (CCSDS annex B) are ROM constants generated from the tables of the standard
Exact transcription of the 32 normative tables; one table lookup per low-entropy symbol
D10
Supplementary information tables are given as their encoded header bits (SupTableData_g)
Tables are data for the user of the image, not used by the compression
D13
Byte n of an interface word is in bits 8n + 7 to 8n, the first byte of the compressed image in bits 7 to 0; within a byte the first bit is the most significant bit; the valid bytes of the last word are contiguous from byte 0
The standard fixes the bit order within a byte (CCSDS 1.6.3), not the place of a byte in a wider word. This order is the one of byte-addressed memory buses and of the Open Logic width converters, so the compressed image can be written into memory, converted in width or passed to a packet or encryption stage without reordering
D14
Optional image framing (UseInLast_g): an early In_Last aborts the image (the predictor and the entropy coder are cleared once the earlier images have left them, the image ends with fill bits at the bit packer); a missing In_Last completes the image and discards the samples up to the next In_Last; the error flag of every image travels in a queue of 16 register bits from the input to the last word of the image
A lost packet upstream must not shift every following image. Clearing only the predictor and the coder keeps the images before and after the damaged one intact and the stream aligned to B bytes. The flag is known at the input long before the last word leaves, so the output is never held. Sixteen flags of one bit are registers; a memory would need SECDED protection
All blocks run in Clk. The reset input Rst is synchronous and high-active (Open Logic convention); the integrator
synchronises it to Clk, for example with olo_base_reset_gen (SyncTmr_g = true for a triplicated synchroniser).
A reset at any time returns every block to the state
before the first image. The memories are not reset: every word is written in an image before the image reads it.
The predictor is a pipeline that takes one sample per clock cycle as long as dependent samples are far enough apart:
the previous sample of a band at least the length of the weight loop (7 to 11 cycles) and, in near-lossless
compression, of the sample representative loop (about 33 cycles), the sample of the previous band at the same pixel
in near-lossless compression also about 33 cycles. Three mechanisms provide that distance:
BI order spreads the samples of a band M samples apart: BIP (M = NZ) with enough bands runs at one sample per cycle.
When consecutive samples belong to the same band (BSQ, BI with M = 1), the weight loop speculates over the error
signs (at most three local differences; lossless, or absolute error limits with narrow local sums and reduced
prediction): one sample per cycle.
In BI order with M = NZ, near-lossless compression processes the samples of a pixel in stride order, the bands S
slots apart: one sample per cycle for NZ above about 33, and still a gain of a factor of ten for fewer bands.
The entropy coders take one item per cycle; the bit packer outputs OutWidth_g bits per cycle. The throughput model
tools/ocp_throughput.py gives the cycle in which the predictor issues every sample; the testbenches check the RTL
against it cycle by cycle. The user guide lists the throughput of the configurations of section 9.
The core has 13 building blocks in four groups, the channel three more (section 7.5). Each block lists its
responsibility, the Open Logic entities it is built from and the clauses it owns (P1: no clause is owned twice).
Position (x, y, z, t) of the next sample in BI or BSQ order or in stride order, flags of the first sample of a band (t = 0) and of the last sample, start of a sample once its dependencies have left the feedback loops, periodic error limit updating: read the limits at the start of every 2^u-th frame and forward them; output FIFO, in stride order input and output buffers
Neighbour memory, local sum of the four types, central and directional local differences, local difference vector
olo_ft_ram_sdp (neighbours, central differences)
4.2, 4.3, 4.4, 4.5
PR-3
Prediction
Weight memory, initial weights (default and custom), predicted central local difference, high-resolution, double-resolution and predicted sample values
olo_ft_ram_sdp (weights)
4.6, 4.7
PR-4
Quantizer
Prediction residual, maximum error from absolute and relative error limits, quantizer index, clipped bin center
none
4.8.1, 4.8.2.1, 4.8.2.2
PR-5
Sample representative and weight update
Sample representative with damping and offset, double-resolution prediction error, weight update scaling exponent, weight update with weight exponent offsets
Blocks of J values, zero padding, option selection (no compression, second extension, fundamental sequence, split samples, zero block with remainder of segment), coded data sets
Image metadata with supplementary information tables, predictor metadata with weight, quantization and sample representative subparts, entropy coder metadata
none
3.5, 5.3
CO-2
Bit packer
Codewords to interface words, fill bits up to the output word boundary, end of the compressed image
none
5.2
CO-3
Image sequencer
Header before the body of every image, end of the image after the last codeword, ECC events of all memories
none
5.2.1
CO-4
Image framer (UseInLast_g)
Check of In_Last against the number of samples of an image, abort of an image that ends early (clear of the predictor and the entropy coder, end at the bit packer), discard of the samples after a missing In_Last, image end with an error by In_Error, error flag of every image on its last word, framing error event
SDUs of big-endian sample containers to samples, end mark and faults from the user signal, image end with an error after a faulty SDU and discard of the rest of the image
olo_base_wconv_n2m
none
MB-1
Status interface
AXI4-Lite slave, identification, configuration registers from the generics, counters of images, SDUs and memory errors
olo_axi_lite_slave
none
CH-1
Channel
Input adapter, core with image framing, output width converter with the error flag of the image, status interface
The core is verified with VUnit and UVVM in a seven-phase module workflow (requirements, architecture, verification
plan, RTL, testbenches, verification, integration; see conventions.md). Every building block of
section 7 belongs to a module with its own specification, verification plan, testbench and verification report. Every
test case names the requirements it verifies, and every requirement names its clauses, so the traceability matrix of
section 10 is checked by tools/compliance.py.
Level
Scope
Bench
Checks
Unit
Predictor
ocp_predictor_tb: test image of a configuration in input order, periodic error limits
Entropy coder input sequence (values, kinds, bands, flags) against the reference model; cycles of the input (and in stride order of the output) against the throughput model
Unit
Entropy coders
ocp_entropy_coder_tb: entropy coder input sequence of the reference model, optional back pressure
Codewords joined into a bit stream against the body of the compressed image of the CNES reference software, including the tail and the fill bits
Unit
Bit packer
ocp_bit_packer_tb: random codewords of random images, interface widths of 8 to 64 bits, optional back pressure
Every output word, the valid bytes and the end-of-image marker against a model of the packing
Core
Header, predictor, entropy coders and bit packer
ocp_core_tb: two images in sequence, interface widths of 8 to 64 bits, optional back pressure
Compressed images byte by byte, including the end-of-image marker and the valid bytes, against the CNES reference software; for the throughput configurations the cycles of the input of both images against the throughput model
Core
Error injection
ocp_core_tb (test_ecc): a single and a double bit error into every memory of a configuration through ErrInj_Channel
A single error is corrected and flagged, the compressed image is unchanged; a double error is flagged
Core
Reset
ocp_core_tb (test_reset): resets at random times of an image
The image after every reset equals the CNES reference
tools/golden.py compresses the test image of every configuration of tools/ocp_configs.py with the CNES reference
software (lcnl_header_tool, lcnl_encoder) and decompresses it with lcnl_decoder: lossless images must be
reconstructed exactly, near-lossless images within the error limits. The test images, the compressed images, the
error limit values and the optional tables are stored in tb/golden/<configuration>/.
The reference model tools/ocp_model.py is an independent implementation of the compressor in Python, written from
the clauses of the standard. tools/golden.py requires it to produce the same compressed image as the CNES
software for every configuration; tools/check_model_testvectors.py checks it against the CCSDS test data set of
randomly configured images (TestVectors-B2, Test1-20181021): the model reproduces all 6474 compressed images of the
set, 347 with the sample-adaptive, 223 with the hybrid and 5904 with the block-adaptive coder. The model provides
the entropy coder input sequence for the unit testbench of the predictor.
The decoder of the reference model (ocp_model.decompress, user guide section 11) reconstructs every image of the
CCSDS test data set from its compressed image: the 4908 lossless images exactly, the 1566 near-lossless images
within the maximum error of every sample and bit for bit as the CNES reference decoder does
(tools/check_model_testvectors.py --decode). The tests in tools/tests (pytest, in the CI) check it against the
golden data of the regression and against the images that the CNES decoder reconstructs from the golden compressed
images of the 27 near-lossless configurations (tools/tests/golden_decoded/).
The test images are synthetic and deterministic: scenes of three materials with smooth spectra, edges and noise,
push-broom stripes, flat low-entropy images and uncorrelated noise.
Random configurations (random_config of tools/ocp_configs.py) draw every parameter of the standard in its range;
their golden data comes from the CNES reference software like that of the other configurations.
tools/ocp_testvectors.py selects test vectors of the CCSDS test data set that cover every parameter value of the
set and converts them into the format of tb/golden/ (test image in input order, compressed image, error limit
values, entropy coder input sequence of the reference model). The data set is not part of the repository; with the
environment variable OCP_TESTVECTORS the testbenches of the predictor, the entropy coders and the core also run
the selected vectors.
Signed samples, BI with M = 4, band-dependent relative error limits, narrow column-oriented local sums, reduced prediction with weight exponent offsets, hybrid coder
c06_near_both_block
Absolute and relative error limits, band-varying damping and offset tables, block-adaptive coder with reference interval 4
c07_lossless_block_bsq
Block-adaptive coder in BSQ order on a low-entropy image: zero blocks and remainder of segment, J = 64
c08_restricted_d4
4-bit samples, restricted set of code options, J = 8
Periodic error limit updating every two frames, band-dependent absolute and band-independent relative limits, BI with M = 2, hybrid coder
c11_wide_d32
32-bit samples, P = 15, Omega = 19, R = 64, Umax = 32, gamma* = 11, gamma0 = 8
c12_single_column
Image of width one: reduced prediction with narrow column-oriented local sums
c13_single_band_hybrid
One band, P = 0, hybrid coder on a low-entropy image (low-entropy codes, flush words)
c14_supplementary_tables
Four supplementary information tables (unsigned 1-D, signed 0-D, float 2-D-zx, unsigned 2-D-yx), user-defined data
c15_noise_escape
Uncorrelated noise: escape codewords at Umax = 8, fast rescaling with gamma* = 4, K = 0
c16_hybrid_low_entropy
Band-dependent absolute error limits from 0 to 255: all 16 low-entropy codes of the hybrid coder with escape symbols and flush words
c17_block_zero_runs
Constant bands with outliers in BSQ order: runs of all-zeros blocks up to a full segment, remainder of segment, reference interval of 70 blocks, J = 8
c18_block_d24_mixed
24-bit signed samples, noise in every second band: no-compression option and split-sample options with 5-bit identifiers, J = 32
c19_block_restricted_d2
2-bit samples, restricted set of code options with 1-bit identifiers, periodic error limits in the block-adaptive coder input, vanishing weight increments (vmax = 9, Omega = 4)
c20_hybrid_d28
28-bit samples with the hybrid coder: initial accumulators up to 2^33 - 1, 40-bit final accumulators
c21_sample_periodic
Sample-adaptive coder with periodic error limit updating every frame (absolute band-independent, relative band-dependent), BIL
c22_single_pixel_hybrid
Image of one pixel per band: uncoded samples only, hybrid coder tail with the initial accumulators
c23_extreme_weights
D = 3, Omega = 19, vmin = vmax = -6, weight exponent offsets -6: weight increments beyond the weight range
c24_reduced_p0
Reduced prediction with P = 0 (no weights), block-adaptive coder with J = 8
c25_tp_bsq_lossless
Throughput: BSQ, lossless, reduced prediction with P = 3, narrow local sums, D = 16, Omega = 19, R = 48: speculative weight loop
c26_tp_bil_near_abs
Throughput: BIL, absolute error limit with sample representatives, reduced prediction with P = 3, narrow column-oriented local sums, hybrid coder: speculative weight loop
c27_tp_bip_full
Throughput: BIP with 24 bands, full prediction with P = 3, block-adaptive coder
c28_tp_bsq_near_abs
Throughput: BSQ, absolute error limit, reduced prediction with P = 2, narrow neighbour-oriented local sums: speculative weight loop
c29_tp_bip_near_stride
Throughput: BIP with 40 bands, absolute error limit with sample representatives, full prediction with P = 3: stride order
c30_tp_bip_both_stride
Throughput: BIP with 48 bands, absolute and relative error limits, reduced prediction with P = 2, narrow column-oriented local sums, hybrid coder: stride order
c31_small_bi_periodic_abs
Small image for the error injection and reset tests: BI with M = 2, periodic updating of band-dependent absolute error limits, sample-adaptive coder
c32_small_bip_periodic_rel
Small image: BIP, periodic updating of band-dependent relative error limits, reduced prediction, hybrid coder
c33_small_bip_stride_block
Small image: BIP, absolute error limit with sample representatives (stride order), block-adaptive coder
c34_small_bsq_lossless
Small image: BSQ, lossless, sample-adaptive coder
c35_small_bil_periodic_spec
BIL with periodic updating of band-dependent absolute error limits every row, reduced prediction with narrow neighbour-oriented local sums: error limit values in the speculative weight loop
c36_block_j64_spikes
Block-adaptive coder with J = 64 on constant bands with spikes: two fundamental sequence codewords that do not fit into one codeword together, a run of all-zeros blocks before the last block
c37_block_d32_custom
Block-adaptive coder with D = 32 on noise: split-sample options with k >= 25 (fewer than four sets of split bits per codeword); custom weight initialization with Q = Omega + 3
c38_header_bounds
Bounds of the header fields: user-defined data 255, 15 supplementary information tables, error limit update period 2^9, DA = DR = 16, K = min(D - 2, 14), gamma* = gamma0 + 1
r01_random to r24_random
Random configurations: every parameter drawn in the range of the standard (image size, D, orders, prediction, error limits, sample representatives, weights, tables, coders)
VUnit (run.py) discovers and runs every test and is the CI regression; the configurations are VUnit
configurations of the testbenches (hdl/<module>/tb/vunit_config.py).
UVVM supplies alert and log handling, check_value and randomisation of the back pressure.
Simulator: GHDL for every test; QuestaSim for code coverage.
Every clause in the scope of section 1 has exactly one owner block. "First verified at" names the lowest verification
level at which the clause can be fully checked. The compliance matrix, generated from this table, the
module specifications and the verification plans, lists the requirements and test cases of every clause.
CCSDS clause
Title
Owner
Also involved
First verified at
3.2
Dimensions
PR-1
CO-1
Unit
3.3
Dynamic range
PR-1
PR-4
Unit
3.4
Sample coordinate indices
PR-1
Unit
3.5
Supplementary information tables
CO-1
Core
4.2
Number of bands for prediction
PR-2
PR-3
Unit
4.3
Full and reduced prediction modes
PR-2
PR-3
Unit
4.4
Local sum
PR-2
Unit
4.5
Local differences
PR-2
Unit
4.6
Weights
PR-3
CO-1
Unit
4.7
Prediction calculation
PR-3
Unit
4.8.1
Quantizer output
PR-4
Unit
4.8.2.1, 4.8.2.2
Controlling maximum error, allowed error limit values
Foundations: repository, reference model, golden data from the CNES reference software, regression and CI.
Predictor (PR-1 to PR-6) with the unit testbench against the reference model.
Entropy coders (EC-1 to EC-3), header generator and bit packer (CO-1 to CO-3) with the core testbench against the
CNES reference software.
Demonstrator: all configurations of section 9 bit-exact, synthesizability check, first performance estimates.
Throughput: pipelining of the predictor and the entropy coders towards one sample per clock cycle.
Verification closure: unit testbenches of the entropy coders and the bit packer, error injection into every
memory, resets at random times, random configurations and the CCSDS test data set, code coverage.
Hardware: synthesis with timing closure on a target FPGA and a hardware test.