Transforming the data format is one of the common tasks in digital design. 1
This lecture will explain how to describe these transformations in HLS. 2
Encoder and Decoder circuits are combinational logics that transform the shape of their received data. 3
They transform data from one format to another. An encoder usually transforms the original data format 4
into a coded format for different reasons such as security, compression, transmission, error-prone 5
safety, to name a few. 6
A decoder usually performs the reverse function and transforms a coded data format into the original 7
data format. A classical encoder/decoder receives n-bit input data and generates m-bit output 8
data. 9
Let’s take an example and clarify the concept of encoder and decoder. Our examples in this slide and 10
the next slide is octal to binary encoder/decoder. 11
The octal to binary encoder consists of eight inputs and three outputs. Each input corresponds to an octal digit, 12
and three outputs represent the corresponding binary code. 13
It is to be assumed that only one input is active or has the value of 1 at any given time; 14
otherwise, the circuit has no meaning. 15
For example, if input (D7, D6, D5, D4, D3, D2, D1, D0) is (0,0,0,1,0,0,0,0) then the output will be (Y2, Y1, Y0) = 100. 16
And the input (0,0,0,1,0,0,1,0) is not possible 17
as two input lines are 1. 18
The octal decoder performs the reverse function. It has three inputs and eight outputs. It receives a 3-bit 19
binary code and activates the corresponding octal output. 20
For example, if the inputs are 010 then the outputs are 00000100. 21
00000100. 22
A classic general binary encoder in digital design is a combinational circuit that receives 23
the maximum of 2 to the nth power binary inputs and generates n binary outputs. Its role in the logic design 24
is encoding a given input and provide an encoded output which is the compact form of the input. 25
This table describes a 4 by 2 binary encoder. 26
In this encoder, only one of the inputs can be 1 and others must be 0. As it can be seen, 27
the output is the binary value of the position index of the only one in the inputs. 28
A classic general binary decoder in digital design is a combinational circuit that receives the maximum 29
of n binary inputs and generates 2 to the nth power binary outputs. 30
Its role in the logic design is decoding a given coded data and provides the original data. 31
This table describes a 2 by 4 binary decoder. As can be seen, only one of the outputs is 1 and 32
rests are 0. 33
Also, the binary input represents the position index of the 1 in the outputs. 34
The switch case programming structure in HLS code can be used to describe the binary encoders 35
and decoders. For example, let's consider this 2 by 4 binary decoder, 36
then this function containing a switch statement represents this decoder. 37
Each case in the switch statement determines one possible output value corresponding to the input 38
values. 39
In other words, each case represents one row of the left-hand side table. 40
A typical HLS tool synthesises a switch case with multiplexers. 41
If we consider the 2 by 4 decoder shown in the previous slide, then a 4 by 1 multiplexer can 42
implement the switch-case representation. 43
Now that we have understood how to describe a classic encoder/decoder in HLS software, the next lecture 44
will describe more detains on using the switch-case software statement to describe similar ideas by taking 45
an example called leading one. 46
These are our takeaway messages. Encoder and decoder are hardware circuits to change a data format. 47
The switch-case statement in HLS code can represent a typical encoder/decoder circuit. 48
Now the quiz question. Use a switch-case statement in HLS to describe an 8 by 3 encoder circuit.