|
Hello. This is Ignorant-Ignorant, who has moved on to step 2, hardware design, of the production practice, through a process of trial and error. This time, I'd like to talk about the second step, designing hardware in Verilog HDL.
|
Please click here to see the previous article, <Specification and Board Preparation>.
Table of Contents
Verilog HDL description
Hardware language that I had been keeping as far away from as soldering.
I have given up and designed a 7-segment LED clock (hereafter referred to as "7seg clock") in Verilog HDL.
7-segment clock
To make the clock, I needed to create a "one-second-interval pulse signal" in FPGA using a 50 MHz clock frequency input from an external source.
|
First, we built an up-counter running at the 50 MHz clock frequency on the board of the Cyclone® 10 LP evaluation kit. When it counted 50,000,000, it would be there for one second. We reset the counter and generated pulses for one clock cycle at the same time. |
If this pulse signal is used as a clock enable signal for the counter for seconds,
The counter that operates in one second is completed!
Next, counters for the first and second digits are prepared for the hour, minute, and second counters, respectively.
For the second and minute counters, pulses for one clock cycle are generated at the timing when the two digits reach 60, and the second and third digits are generated at the timing when the second and third digits reach 60.
As shown in the figure below, the minute and hour counters are used to enable the clock.
The 7seg can then select whether to display hours, minutes, or seconds depending on whether or not the pushbutton is being pressed.
Dot matrix LED
Using the dynamic lighting method that was used when the 7seg clock was written in Verilog HDL, a counter was used to control the turning on and off of all LEDs on a single dot matrix LED during the elapse of 50000ns.
In this way, to the human eye, it appears as if all the LEDs that are lit are lit at the same time!
Changing facial expressions
We used two variables to change the lighting pattern depending on the time on the 7seg clock and the state of the pushbutton press.
And so we finished the assignment for step 2.
In retrospect...
Things I didn't know
What is a decoder?
In the last issue <Specification and board creation>, I thought "Well, it's OK (laugh)" because I mistakenly thought that I could complete the project by creating the dotted line in the figure below.
I finished the clock circuit in Verilog HDL and thought to myself, "Good! I have defeated a powerful enemy!" I thought, "I've beaten my enemy!" but when I thought about pin assigning the output signal to
... Huh? How should I connect them?
What should I do to turn the LED on and off in the latter stage? It was a mystery. It was a mystery to the ignoramus.
When he consulted with his seniors, he heard the term "decoder.
When he found out what the process was, he said, "Really? That's what this is all about! I said out loud.
I had no idea there was such a powerful item. And I didn't know that.
At that time, I had nothing but despair for myself.
How to use dynamic lighting & case statements
|
In the previous #1 <Specification and board creation>, I understood that 7-segment LEDs are used to operate with dynamic lighting, but I had no idea how to actually do that. After asking Goole-san and other senior students, I somehow arrived at the following conclusion. |
For example, to display 1230, each LED must be turned on as shown in the figure below.
|
However, the pin specifications of the 4-digit 7seg LEDs are not 1-to-1, so they cannot be turned on simultaneously. Therefore, we decided to use a method in which the 7seg LEDs of each digit are turned on sequentially for a certain period of time. I checked with Dr. Goo0r, Specifically, I created a counter (cnt) that counts up 40000 times in 1ns cycles, and controlled it as follows using case statements. seg1 turns on at 0 ns ~ 9999 ns seg2 lights from 10000 ns to 19999 ns seg3 lights up from 20000 ns to 29999 ns seg4 lights up at 30000 ns ~ 399999 ns |
[The 10000 ns interval is too fast for the human eye to follow = the lights appear to be on at the same time!
Now, dynamic lighting is successfully achieved.
What I should have done
There were a few things I wished I had done during the hardware design (Step 2).
I should have understood the overall structure of my design (digital logic circuit).
... I should have written the specifications more carefully.
I should have done the exercises given in the language course during my training at
before suddenly describing my circuit in Verilog HDL.
Notice for next time
When he got carried away at the end of Step 1, he was immediately broken in Step 2, and he became a cautious man.
I won't make that mistake again!"
Next time: Software Design (feat. Nios® II)
New Engineer's Blush Blog Articles