Let's talk about it first. Use FPGA to allow buttons to control the display of digital tubes.
If you use Quartus II, you just need to find a book. There are image examples on the Internet. A typical example of FPGA application development.
Let the digital display, I still 51 Single-Chip Microcomputer idea, come to an input, then output control. Start with a simple
Copy a program from the Internet:
/*
The decoding circuit of the Seven-segment digital tube with a common anode, entering the numbers to be displayed, and outputting the Decoding signal of the Seven-segment code
*/
'Timescale 1ns/1ns
Module seg7_lut (dig_in, seg_o );
Input [3: 0] dig_in;
Output Reg [6:0] seg_o;
Always @ (dig_in)
Begin
Case (dig_in)
4 'h0: seg_o = 7' b000000 ;//-----
4 'h1: seg_o = 7' b1111001; // |
4 'h2: seg_o = 7' b0100100; // |
4 'h3: seg_o = 7' b0110000 ;//-----
4 'h4: seg_o = 7' b0011001; // |
4 'h5: seg_o = 7' b0010010; // |
4 'h6: seg_o = 7' b0000010 ;//-----
4 'h7: seg_o = 7' b1111000;
4 'h8: seg_o = 7' b0000000;
4 'h9: seg_o = 7' b0011000;
Default: seg_o = 7 'b1111111;
Endcase
End
Endmodule
Source: http://bbs.socvista.com/archiver? Tid-3353.html
According to the development board I bought myself, there are four buttons and several digital outputs on it. I made a slight change:
'Timescale 1ns/1ns
Module led7 (dig_in, seg_o, seg_s );
Input [3: 0] dig_in;
Output Reg [6:0] seg_o;
Output Reg seg_s; // This field is used to control the bit selection. This field first shows one (when done, then ^_^)
Always @ (dig_in)
Begin
Seg_s <= 0;
Case (dig_in)
4 'h0: seg_o = 7' b000000 ;//-----
4 'h1: seg_o = 7' b1111001; // |
4 'h2: seg_o = 7' b0100100; // |
4 'h3: seg_o = 7' b0110000 ;//-----
4 'h4: seg_o = 7' b0011001; // |
4 'h5: seg_o = 7' b0010010; // |
4 'h6: seg_o = 7' b0000010 ;//-----
4 'h7: seg_o = 7' b1111000;
4 'h8: seg_o = 7' b0000000;
4 'h9: seg_o = 7' b0011000;
Default: seg_o = 7 'b1011101;
Endcase
End
Endmodule
After selecting the pins, compiling and setting them according to the tools --> programmer in the book, download them to my Development Board. The result is OK.