Microcontroller Code Decompression With Dictionary Masks and Branch Offsets
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing decompression methods for executable code require significant overhead due to the use of look-up tables and indeterminate or non-converging offset values, especially when handling branch instructions, leading to inefficient memory usage and execution.
Innovation Solution
A decompression engine that uses a dictionary part and a compressed code part with segments containing mask types, locations, and patterns, along with an index to the dictionary, allowing for efficient decompression by applying masks using exclusive OR operations to form corrected instruction values, and adjusts branch instructions with offset values to ensure accurate address retrieval.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Ease of operation
If the entire compressed file is decompressed into RAM, then random access to instructions is enabled, but RAM size must be four times the size of flash memory
Solution Approach 1:
The compressed file is divided into multiple segments, each corresponding to a specific address range. The decompression engine only decompresses and loads the required segment into RAM when a branch instruction jumps to that segment's address range, rather than decompressing the entire file. This segmentation enables random access capability while significantly reducing the amount of RAM needed at any given time.
Solution Approach 2:
The compressed file is pre-divided into segments during the compression phase, with each segment marked to indicate its address range. This preliminary segmentation allows the decompression engine to quickly identify and load only the necessary segment when a branch instruction is encountered, avoiding the need to decompress the entire file beforehand.
2Quantity of substance
If multiple segments and look-up tables are used for decompression, then memory requirements are reduced, but overhead increases
Solution Approach 1:
The segment table and decompression logic are merged into a single integrated structure. The segment table contains not only address range information but also direct references to the compressed segment data. This merging eliminates the need for separate look-up tables and reduces the overhead of multiple data structures, while still enabling efficient segment identification and loading.
Solution Approach 2:
The segment table serves multiple functions: it acts as a look-up table for address range identification, a directory for locating compressed segments, and a mapping structure for translating branch addresses to segment indices. This multi-functionality reduces the need for separate data structures and reduces overall overhead.
3Quantity of substance
If variable length compression is used, then compression ratio is improved, but symbol boundaries become indeterminate making granular access difficult
Solution Approach 1:
The compressed data is organized into fixed-length segments rather than variable-length symbols. Each segment contains a fixed number of compressed instructions and is assigned a specific address range. This segmentation maintains the benefits of variable-length compression within segments while enabling deterministic access to specific segments based on address ranges, thus restoring granular access capability.
Solution Approach 2:
Variable-length compression is applied locally within each segment to achieve high compression ratios, while the segment boundaries themselves are fixed and deterministic. This allows the system to enjoy the space efficiency of variable-length encoding without sacrificing the addressability provided by fixed boundaries.
Data Source
AI summary
A code decompression engine reads compressed code from a memory containing a compressed code part and a dictionary part. The compressed code part contains a series of instructions being either an uncompressed instruction preceded by an uncompressed code bit, or a compressed instruction having a compressed code bit followed by a number of segments field followed by segments, followed by a directory index indication a directory location to read. Each segment consists of a mask type, a mask offset, and a mask.


