viewof defbWordBits = Inputs.range([8, 32], {value: 16, step: 8, label: "Signed word width (bits)"})
viewof defbFractionBits = Inputs.range([0, 24], {value: 8, step: 1, label: "Requested fractional bits"})
viewof defbFixedInput = Inputs.range([-200, 200], {value: 12.375, step: 0.125, label: "Value to encode"})
viewof defbSamples = Inputs.range([100, 10000], {value: 1000, step: 100, label: "Samples in the buffer"})
viewof defbFixedCycles = Inputs.range([1, 40], {value: 4, step: 1, label: "Measured fixed-point cycles per operation"})
viewof defbFloatCycles = Inputs.range([1, 80], {value: 18, step: 1, label: "Measured floating-point cycles per operation"})Compiler And Fixed-Point Lab
Compiler And Fixed-Point Lab
animation
prototyping
microcontrollers
Try Change Requested fractional bits, then press Calculate.
Observe Press Calculate and compare Representable range, Resolution, and Decoded value and absolute error.
Explain Explain why more fractional bits reduce range when you press Calculate.
Technical boundaries. The lab saturates deliberately and clamps fractional bits to leave sign and magnitude. Cycle inputs are a transparent comparison model, not a processor claim; replace them with measured target counts.
Compiler And Fixed-Point Lab
A compiler may schedule independent instructions in a useful order. A vector instruction applies an operation to several values at once when the target supports it. This is called single instruction, multiple data (SIMD). Predicated work executes an operation only when its condition is true, which can avoid a short branch on supported targets. None of those transformations removes the need for evidence. Inspect the generated code, time the actual target, and keep the input distribution with the result. A faster loop on a desktop compiler does not prove the same saving on an MCU with a different instruction set, memory system, or floating-point unit.
Fixed-point arithmetic makes that evidence boundary visible. In signed Q-format, a stored integer is interpreted with a scale of , where is the number of fractional bits. More fractional bits improve resolution but reduce range. Fewer fractional bits widen the range but increase quantization error. Overflow is not a small accuracy loss: wraparound can reverse a sign or turn a large control demand into a small one, so the lab saturates deliberately and reports the event.
Run three evidence cases: a value near zero to expose quantization, the largest expected field value, and a value just beyond the representable range. Then compile the same multiply-accumulate loop with optimization disabled and enabled. Record compiler version and flags, inspect whether SIMD or predication was emitted, and compare measured cycles, code size, buffer memory, numerical error, and overflow behavior. Keep floating point if it is accurate enough and the measured target cost is acceptable; fixed point earns its complexity only when the evidence shows a useful resource gain.