Tunstall V2F Coding Algorithm • Assumption: – a binary instruction stream has i.i.d. – the probability of a bit to be 1 is Prob(1) and the probability of a bit to be 0 is Prob(0). • N-bit Tunstall codewords : number of codewords is 2N Tunstall V2F Coding Algorithm • Algorithm: – Step1: initiate the root and attach 2 nodes. – Step2: leaf node with higher probability is attached with 2 more nodes. – Step3: Repeat step2 until number of leaf nodes is 2N. – Step4: assign codewords to leaf nodes (length = N) An example: 2-bit Tunstall V2F coding 000 01 001 COMPRESSION 11 01 10 Improvement of Tunstall V2F Coding Algorithm • Using a Markov model to represent the dependence in data. • Procedure – Step1: statistics-gathering – Step2: codebook construction – Step3: compression Another example: 2-bit Tunstall V2F coding using Markov model 2 issues during compression • End of block – Pad extra bits when compression. – Truncate padded bits when decompression. • Byte alignment – To facilitate compression/decompression. – Pad extra bits if the compressing block is not a multiple of 8(in bits). Arithmetic V2F Coding Algorithm • Assumption: – a binary instruction stream has i.i.d. – the probability of a bit to be 1 is Prob(1) and the probability of a bit to be 0 is Prob(0). • N-bit arithmetic codewords : number of codewords is 2N Arithmetic V2F Coding Algorithm • Algorithm: – Step1: Initiate integer interval with range [0,2N) – Step2: If current interval is not a unit interval: • Divide the interval to be two subintervals. • Left subinterval is for input 0 and the right subinterval is for input 1. • The size of the subintervals is approximately proportional to the probability of the input bit. – Step3: Repeat step2 until all subintervals become unit intervals. – Step4: Assign codewords (length = N) to unit intervals. Arithmetic V2F Coding Algorithm • Each unit interval is disjointed from all other unit intervals. • Each unit interval uniquely represents a particular input binary sequence. An example: 2-bit Arithmetic V2F Coding 000 01 001 COMPRESSION 00 10 01 Another example: 2-bit Arithmetic V2F Coding using Markov model
© Copyright 2026 Paperzz