标签:name after uil *** regular 信号 style 一个 声明
平臺:FPGA黑金开发板 AX301
開發環境:Quartus Prime Version 17.0.0 Build 595 04/25/2017 Standard Edition
引脚配置:鼠標托拉 Node Name 項到引脚圖即可
注意事項新建工程:Set Up Top-Level Entity 名字要對應
注意事項引脚復用:Assignments-->Device-->Device and Pin Options...-->Dual-Purpose pins-->nCEO -->Use as regular I/O
nCEO:Specifies how the nCEO pin should be used when the device is operating in user mode after configuration is complete. The nCEO pin can be reserved as dedicated nCEO programming pin or a regular I/O pin.
我的Top-Level:
1 module MyLED(CLK, RSTn, Run_LED); 2 3 input CLK; 4 input RSTn; 5 output [3:0]Run_LED;//I/O口的说明:input[信号位宽]端口名 6 7 /**********************************/ 8 9 wire [3:0]Run_LED;//定义输出信号 10 11 Run_LED U1(.CLK( CLK ), .RSTn( RSTn ), .LED_Out( Run_LED ) ); 12 13 /***********************************/ 14 15 assign Run_LED = Run_LED;//内部信号声明和功能定义 16 17 /**********************************/ 18 19 endmodule
我的Run_LED:
1 module Run_LED(CLK, RSTn, LED_Out); 2 3 input CLK; 4 input RSTn; 5 output [3:0]LED_Out; 6 7 /**************************/ 8 9 parameter T1MS = 16‘d49_999; //DB4CE15使用的晶振为50MHz,50M*0.001-1=49_999 10 11 /**************************/ 12 13 reg [15:0]Count1; 14 15 always @ ( posedge CLK or negedge RSTn )//1ms计数器 16 if( !RSTn ) 17 Count1 <= 16‘d0; 18 else if( Count1 == T1MS ) 19 Count1 <= 16‘d0; 20 else 21 Count1 <= Count1 + 1‘b1; 22 23 /*****************************************/ 24 25 reg [9:0]Count_MS; 26 27 always @ ( posedge CLK or negedge RSTn )//100ms计数器 28 if( !RSTn ) 29 Count_MS <= 10‘d0; 30 else if( Count_MS == 10‘d100 ) 31 Count_MS <= 10‘d0; 32 else if( Count1 == T1MS ) 33 Count_MS <= Count_MS + 1‘b1; 34 35 /***************************************/ 36 37 reg [3:0]rLED_Out; 38 39 always @ ( posedge CLK or negedge RSTn ) 40 if( !RSTn ) 41 rLED_Out <= 4‘b1111; 42 else if( Count_MS == 10‘d100 ) 43 begin 44 45 if( rLED_Out == 4‘b0000 ) 46 rLED_Out <= 4‘b0001; 47 else 48 rLED_Out <= { rLED_Out[2:0], 1‘b0 };//向左移位1bit操作 49 end 50 51 /**********************行48左移操作解釋*************************** 52 知識點1: reg [n-1:0] rega; //一个n位的寄存器 53 reg mema [n-1:0]; //一个由n个1位寄存器构成的存储器组 54 55 知識點2: 位拼接运算符(Concatation) {} 56 57 解釋:如果rLED_Out不是4‘b0000 就取rLED_Out后三位,并且與1‘b0合并成一个新的四位 58 59 ****************************************************************/ 60 61 assign LED_Out = rLED_Out; 62 63 /*****************************/ 64 endmodule
感謝:http://www.heijin.org/forum.php?mod=viewthread&tid=31002&pid=320054&page=1&extra=#pid320054
标签:name after uil *** regular 信号 style 一个 声明
原文地址:http://www.cnblogs.com/HelloSuvan/p/7281467.html