First day of FPGA

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.