Verilog Hex to Seven Segment Display |
We will be moving on to write slightly more complex example, this time a hex to seven segment encoder. Basically LED number is displayed with 7 segments.
The hexadecimal to 7 segment encoder has 4 bit input and 7 output. Depending upon the input number, some of the 7 segments are displayed. The seven segments are represented as a,b,c,d,e,f,g. A high on one of these segements make it display. For example to write 1 we need to display segments b and C.
The 7 segment display also has a decimal point dp.
The figure below explains this Let write this example making use of the verilog case statement
|
Note that we had to assign out as a register in
reg out;
In our case, it was not required because we had only one statement. We now suggest that you write a test bench for this code and verify that it works. If you have sifficulty, you can check it with following test bench
|
Exercise
1. Change the above hex to BCD verilog code so that it take negative logic. A segment is on when it gets 0. A segment is off
when it gets logic 1.