-
Notifications
You must be signed in to change notification settings - Fork 1
Home
In general, the 7-segment-decoder takes a binary number as an input, converts it into a hexadecimal number which is represented by the output. The output is a signal with 7 bits, each representing a segment on the LED.
For the signal assignment, we used neither the conditional signal assignment nor the selected signal assignment. Instead, we drew seven Karnaugh maps with each bit of our input “code” as a variable and generated seven logic functions for each segment respectively. We know that the selected signal assignment is not only straightforward but also makes things easier here as the output and input are barely related by logic. Clearly, the selected signal assignment makes the code look cleaner and easier to write and check, while we still wanted to make our project unique. The way of getting logic functions was a bit harder -- but it did not take too long -- it was also a good practice.
After the implementation, we followed the given instruction and wrote the 7-segment decoder test. It runs from 0 to 15, covering every hexadecimal integer that can be represented by one hexadecimal digit, decodes each of them.
Even though we did not use the selected signal assignment, we clearly know the output corresponding to each input at the very beginning. So we just needed to check for each input, whether or not the code generated correct output. If it did correctly for all 16 numbers, then it worked.
Generally, the adder circuit takes two inputs, A and B, add them into the sum and outputs the three items, decoded form of A, decoded form of B and decoded form of sum.
Basically, our adder circuit can be divided into two parts: adder and decoder. Here we did not design our own adder, instead, we used the “+” operator from the STD_LOGIC_UNSIGNED package. Since both the inputs are binary and what we needed was actually hexadecimal, we decoded them using the 7-segment-decoder. Both inputs and the output were decoded and shown on the board by expectation.
However, the inputs and output of our adder cannot be directly poured into the decoder -- as they have different numbers of bits. In this case, A and B are both 5-bit binary numbers, while their sum is then possibly a 6-bit binary number. Therefore, each of them should be split into two 4-bit number, in order to fit into the input of the 7-bit-segment decoder. Similarly, the representation of the sum on LED was a 14-bit signal, which was also the concatenation of two outputs from decoder, each representing one digit of the hexadecimal number.
There are six instances of decoders in all. As we mentioned above, both the two inputs and the output should be converted into 7-bit signals to show the hexadecimal digits. Since all of them took more than 4 bits, each of them needed two hexadecimal digits. Two decoders for each three of the numbers, so we have six instances overall.
After we just finished compiling, we were about to write the test code to simulate the adder. However, we soon recognized that there were many of the input pairs that can be tested and the test outputs would be in the form of 7-segment LED signals, which were pretty hard to read and check. Therefore, we directly connected the board to the computer.
Luckily, the code of adder worked pretty well on the board. We can randomly pick the addends and see both inputs and result in a hexadecimal form. It was easy and fast to check, and the number of tests can be really large as we could change them as long as we wanted. Also since the inputs were decided randomly, it can easily detect whether the code only worked in some cases.
In our code, the A and B represent two input ports, which are the two 5-bit addends. The blue (partially green) circle with a “+” on it indicates the addition operation of A and B, which yields a 6-bit sum. After though, the A, B and their sum are sent to the seven-segment-decoders.
Since all of A, B, and their sum have more than 4 bits, we need to split them into two 4-bit numbers each, which are sent to the decoders respectively. The logic implementation follows our code, where each segment is decided by three inputs.
As we can see from the diagram, we used in total 52 pins. This is credit to 10 pins used by A & B inputs and 14 pins used by decoded A, decoded B and decoded sum of A and B separately.