Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

McGill University

Lab 1 Report

Digital Logic; ECSE-222

Due on March 18th 2019


1. Description of the 7-segment decoder circuit.

To implement the 7-segment decoder, we decided to make a port that has an input (named
“code”) with four bits and an output (named “segments”) of 7 bits that displays the input of four
bits in hexadecimal form. To display the output in hexadecimal form, we used a LED display on a
DE1-SoC board. Indeed, the LED display consists of 7 ordered segments (bit 0, bit 1, bit 2…, bit 6)
and in relation to the inputs, a segment would “turn on” accordingly. To do this, we created and
architecture in our code. It contained a process to execute the “code” statements inside it
sequentially. Afterwards, we inserted a case statement to check for every possible 4-bit “code”
inputs which were used as signals for which segments to be “turned on”. For instance, when the
input “code” is “0000”, the program sends a signal to the output “segments” to be “0000001”,
and thus, the hexadecimal representation of the binary number “0000” is displayed by the
segments on the LED display. It’s important to note that “0” is a turned on bit and “1” is a
turned off bit. Hence, in the last example, every segment is turned on, except the last bit (bit 6
which corresponds to the middle segment in figure 1). We did this for 0 to F in hexadecimal.
Moreover, we added a case when the input is not among the 16 characters that represent 0 to
F, which would not turn any segments on. This is done to prevent irregular character
representations and exceptions.

Figure 1: LED display1

The 7-segment decoder circuit we coded did not use the conditional signal assignment because
the software would find the optimal way to implement the circuit. Also, it would be longer and
more complicated to use conditional signal assignment because we would have to do
corresponding Karnaugh Maps using the segments as inputs instead. Then, we would have to
find the logic function and simplify it to find the optimal function. This method would have
taken much more time.

1
Lab Assignment 1.pdf
2. Discussion about testing the 7-segment decoder

The 7-segment decoder was tested using the software program called ModelSim. We created a vht
file of the 7 segment decoder using the Test Bench Template Writer from Quartus. Then, we
modified the code of the vht file to test each input from 0 to F. Afterwards, this file was added file to
a project that we created in ModelSim and then, it was compiled to check for errors in the code.
Once the compilation was successful, we started a simulation which opened up the wave window
that was used to analyze the decoder. We dragged our file onto the wave window and started
running the simulation. Looking at the signal waveform on the Wave window, we observed the if
each input and its corresponding output matched together. It was also possible to see the order of
the iterations and to check if the process executed the statements sequentially.

Figure 2: Simulation plot of the first four hexadecimal characters


Figure 3: Simulation plot of the hexadecimal characters 4 to 7

Figure 4: Simulation plot of the hexadecimal characters 8 to B


Figure 5: Simulation plot of the hexadecimal characters C to F

The figures2 2, 3, 4 and 5 are simulation plots that demonstrate the results of our simulation. As
mentioned before, it can be observed that the inputs correspond correctly with the outputs.
Furthermore, it can be seen that at the bottom of the plot, there is an axis of time (ps). This is present
since we included a for loop in the vht file in order to test each case. The simulation would run each case
one at a time in a sequential way. Hence, the first loop tested the case when the input is 0000, giving a
segments output of 0000001, the second loop tested the case when the input is 0001, giving a segments
output of 1001111, and so on until the last input, 1111. Thus, every loop tested a pair of input-output
one after the other, which is demonstrated by the increase in time for each pair on the wave window.
On a side note, there is a difference of 1000 ps between each pair of input-output, showing that each
loop requires 1000 ps to run.

3.

2
The figures are screenshots from the simulation done in the ModelSim program

You might also like