A quick code to turn off every single segment onto a FPGA board.
For this tutorial we use the Altera DE1 board.
So if you have another one, just replace HEX0, HEX1, HEX2, HEX3 by your assignment.
Each number is a pin onto the board.
As there are 4 * 7 segments = 28 segments to light, so 28 pins.
So, to turn off all segments of a display, it's necessary to use 7'b1111111 as value.
Because by default, a "0" value is equal to light the corresponding segment.
Let's have a look to this diagram.
_0_
5 | | 1
|_6_|
4 | | 2
|___|
3
If 0 = ON and 1 = OFF, then:
// top-level entity: module top1
module top1(
output wire [6:0] HEX0, HEX1, HEX2, HEX3
);
// call nested module
segment_remove_all(
.h0(HEX0),
.h1(HEX1),
.h2(HEX2),
.h3(HEX3)
);
endmodule
// generic module: segment_remove_all
module segment_remove_all(
output reg [6:0] h0, h1, h2, h3
);
// parameter
parameter off = 7'b1111111;
// always
always @(*) begin
h0 <= off;
h1 <= off;
h2 <= off;
h3 <= off;
end
endmodule
Your 7-segment displays are now turned off.
And your eyes thank you for removing this red light.
Well done, you've made it. ![]()
Add new comment