As you certainly liked this Altera DE1 tutorial for blinking a LED on the board , you will love this one by doing the same easy thing but with GPIOs.
I’m sure you are really excited about that. So let’s go.
Explanation
On the DE1 board, there are many GPIOs.
What is a GPIO? –> GPIO stands for General Purpose Input Output.
It’s a group of pins that you can set to input or output individually.
It means that when a pin is set to ouput and when you send a 0 or a 1 on it, you can get this value outside the board.
And when it’s input, you get data from outside.
In this tutorial we are going to use output direction.
On the DE1 board, there are 2 GPIOs:
- GPIO_0
- GPIO_1
As you can see from the video, there are two green LEDs plugged to the breadboard (on the right).
Each green LED is paired with a 150 ohm resistor.
The black wire is the GND that I’ve taken from GPIO_0[11] and the red wire is the VCC (+3V) taken from GPIO_0[28].
This first green LED is just here to say there is a current through the breadboard.
Then I’ve taken a green wire to connect the + of the second LED to the GPIO_1[0].
It could be a bit difficult to understand that, especially because on the DE1_Schematics (that you can find easily on Internet) the first pin starts from 1 and not 0.
Furthermore we use CLOCK_24[1] instead of the famous CLOCK_50.
Code
// module blink_led_gpio
module blink_led_gpio(
input wire [1:0] CLOCK_24,
output wire [35:0] GPIO_1
);
// reg
reg [32:0] counter;
reg turn;
// assign
assign GPIO_1[0] = turn;
// always
always @(posedge CLOCK_24[1]) begin
counter <= counter + 1;
if (counter[25]) begin
turn <= 1'b1; // LED turned on
end else begin
turn <= 1'b0; // LED turned off
end
end
endmodule
Conclusion
After using the DE1 LEDs, you are now able to handle LEDs outside the board.
A new step for the glory.
Well done, you’ve made it.