七段数码管0~9循环计数显示FPGA(EP4CE6)实验Verilog逻辑源码Quartus工程文件+文档说明资料, FPGA为CYCLONE4系列中的EP4CE6E22C8. 完整的工程文件,可以做为你的学习设计参考。 1 SEG_LED七段数码管 1.1数码管简介 数码管由七个条状和一个点状发光二极管管芯制成,称为七段数码管。数码管是一类价格便宜、使用简单,通过对其不同的管脚输入相对的电流,使其发亮。从而显示出数字使其能够表示时间、温度、日期等一切可以使用数字表示的参数的器件。 数码管在电器特别是家电领域应用十分广泛,如显示屏、空调、热水器、冰箱等等。绝大多数热水器使用的都是数码管,也有的家电使用液晶屏或荧光屏。 1.2实验任务 编写逻辑使数码管从0~9循环计数,时间间隔为1秒。 module remote_rcv ( //input input sys_clk , //系统时钟 input sys_rst_n , //系统复位信号,低电平有效 input remote_in , //红外接收信号 //output output reg [15:0] data_buf , // for not optimize output beep , // for shut beep output reg [7:0] led //指示LED ); //reg define reg [11:0] div_cnt ; //分频计数器 reg div_clk ; reg remote_in_dly ; reg [6:0] start_cnt ; reg [6:0] start_cnt1 ; reg [5:0] start_cnt2 ; reg [5:0] user_cnt ; reg [5:0] data_cnt ; reg [14:0] data_judge_cnt ; reg [14:0] noise_cnt ; reg [4:0] curr_st ; reg [4:0] next_st ; //wire define wire remote_pos ; wire remote_neg ; //fsm define parameter IDLE = 3'b000 ; parameter CHECK_START_9MS = 3'b001 ; parameter CHECK_START_4MS = 3'b010 ; parameter CHECK_USER_CODE = 3'b011 ; parameter CHECK_DATA_CODE = 3'b100 ;
VGA显示一个小方块,FPGA(EP4CE6)实验Verilog逻辑源码Quartus工程文件+文档资料,FPGA为CYCLONE4系列中的EP4CE6E22C8. 完整的工程文件,可以做为你的学习设计参考。 ********************************************************************************************************/ //上电后,VGA显示一个移动的小块,碰到边框的时候被弹开。 module VGA_Moving_Block ( input sys_clk , input sys_rst_n , output wire Hs , output wire Vs , output wire VGA_G , output wire VGA_B , output wire VGA_R ); //Reg define reg sys_clk_pixel ; reg [9:0] x_count ; reg [9:0] y_count ; reg hsync ; reg vsync ; reg [17:0] clk_cnt ; reg clkout ; reg up_down_x; reg up_down_y; //上升和下降信号 reg [9:0] x_pos ; //小方块左上角坐标 reg [9:0] y_pos ; //小方块左上角坐标 //Wire define wire valid_mov; wire valid_1 ; wire valid_2 ; wire valid_3 ; wire valid_4 ; wire valid_s ; //************************************************************************************ //** Main Program //** //************************************************************************************ //像素时钟 分频产生 25Mhz 时钟 always @ (posedge sys_clk or negedge sys_rst_n) begin if (!sys_rst_n) sys_clk_pixel <= 1'b0; else sys_clk_pixel <= ~sys_clk_pixel; end //行坐标和纵坐标 always @ (posedge sys_clk_pixel) begin if (!sys_rst_n) begin x_count <= 0; y_count <= 0; end else if (x_count == 10'd799) begin x_count <= 10'd0; if (y_count == 10'd519) y_count <= 10'd0; else y_count <= y_count+1'b1; end else x_count <= x_count+1'b1; end //同步信号 always @ (posedge sys_clk_pixel) begin if (x_count <= 10'd95) hsync <= 1'b0; else hsync <= 1'b1; end always @ (posedge sys_clk_pixel) begin if (y_count <= 1'd1) vsync <= 1'b0; else vsync <= 1'b1; end assign Hs = hsync; assign
华邦w25x16 SPIFlash Read ID FPGA(EP4CE6)实验Verilog逻辑源码Quartus工程文件+文档说明资料,FPGA为CYCLONE4系列中的EP4CE6E22C8. 完整的工程文件,可以做为你的学习设计参考。 **------------------------------------------------------------------------------------------------------ ** Modified by: ** Modified date: ** Version: ** Descriptions: Read the Device ID of the W25X16 Flash ** **------------------------------------------------------------------------------------------------------ ********************************************************************************************************/ module W25X16 ( //input signal input sys_clk , input sys_rst_n , input W25X16_DO , //output signal output reg W25X16_CS , output reg W25X16_CLK , output reg W25X16_DIO , output reg [7:0] LED ); //reg define reg [5:0] counter ; reg [5:0] clk_cnt ; reg [15:0] shift_buf ; //wire define wire div_clk1 ; wire div_clk2 ; /******************************************************************************************************* ** Main Program ** ********************************************************************************************************/ //creat a clock about 1MHz always @(posedge sys_clk or negedge sys_rst_n) begin if ( sys_rst_n ==1'b0 ) clk_cnt <= 6'b0; else clk_cnt <= clk_cnt + 1'b1; end assign div_clk1 = clk_cnt[5]; assign div_clk2 = ~clk_cnt[5]; //get a counter that width is 6 bits always @(posedge div_clk1 or negedge sys_rst_n) begin if ( sys_rst_n ==1'b0 ) counter <= 6'b0; else counter = 8 && counter <= 58 ) W25X16_CS <= 1'b0;
28BYJ-48步进电机(EP4CE6)FPGA控制Verilog逻辑源码Quartus工程文件+文档资料, 28BYJ-48步进电机: 步进电机是一种将电脉冲转化为角位移的执行机构。通俗一点讲:当步进驱动器接收到一个脉冲信号,它就驱动步进电机按设定的方向转动一个固定的角度(及步进角)。您可以通过控制脉冲个来控制角位移量,从而达到准确定位的目的;同时您可以通过控制脉冲频率来控制电机转动的速度和加速度,从而达到调速的目的。 2. 步进电机规格: 步进电机28BYJ48型四相八拍电机,电压为DC5V—DC12V。 3. 实现原理 当对步进电机施加一系列连续不断的控制脉冲时,它可以连续不断地转动。每一个脉冲信号对应步进电机的某一相或两相绕组的通电状态改变一次,也就对应转子转过一定的角度(一个步距角)。当通电状态的改变完成一个循环时,转子转过一个齿距。四相步进电机可以在不同的通电方式下运行 module STEP_MOTO_V1_0 ( //input input sys_clk , input sys_rst_n , input [2:0] key , output reg mot_out_a , output reg mot_out_b , output reg mot_out_c , output reg mot_out_d ); //reg define //reg [8-1:0] counter ; //reg [8-1:0] count ; reg [25:0] clk_cnt ; reg [ 2:0] step_cnt ; //wire wire step_en ; //wire define //parameter define /******************************************************************************************************* ** Main Program ** ********************************************************************************************************/ // gen a time counter , 5500000 * 20ns always @(posedge sys_clk or negedge sys_rst_n) begin if (sys_rst_n ==1'b0) clk_cnt <= 26'b0; else if (key[1]==1'd0 && key[2]==1'd1 && clk_cnt == 26'd250000 ) clk_cnt <= 26'b0; else if ( key[1]==1'd1 && key[2]==1'd0 && clk_cnt == 26'd600000 ) clk_cnt <= 26'b0; else if (clk_cnt == 26'd400000 ) clk_cnt <= 26'b0; else clk_cnt <= clk_cnt + 26'b1; end // step enable is active 500000 * 20ns assign step_en = ( clk_cnt == 26'b0 ) ? 1:0 ; always @(posedge step_en or negedge sys_rst_n) begin if
FPGA(EP4CE6)控制步进电机实验Verilog逻辑源码Quartus工程文件+文档资料, module STEP_MOTO_V1_0 ( //input input sys_clk , input [3:0] key , output reg mot_out_a , output reg mot_out_b , output reg mot_out_c , output reg mot_out_d ); //reg define reg [8-1:0] counter ; reg [8-1:0] count ; reg [25:0] clk_cnt ; reg [ 2:0] step_cnt ; //wire wire step_en ; //wire define //parameter define assign sys_rst_n = 1'b1 ; // gen a time counter , 5500000 * 20ns always @(posedge sys_clk or negedge sys_rst_n) begin if (sys_rst_n ==1'b0) clk_cnt <= 26'b0; else if ( clk_cnt == 26'd500000 ) clk_cnt <= 26'b0; else clk_cnt <= clk_cnt + 26'b1; end // step enable is active 5500000 * 20ns assign step_en = ( clk_cnt == 26'b0 ) ? 1:0 ; always @(posedge step_en or negedge sys_rst_n) begin if (sys_rst_n ==1'b0) step_cnt <= 3'b0; else step_cnt <= step_cnt + 3'b1; end always @(posedge step_en or negedge sys_rst_n) begin if (sys_rst_n ==1'b0) begin mot_out_a <= 1'b0; mot_out_b <= 1'b0; mot_out_c <= 1'b0; mot_out_d <= 1'b0; end else if ( step_cnt == 0 ) begin mot_out_a <= 1'b0; // 6 mot_out_b <= 1'b0; mot_out_c <= 1'b0; mot_out_d <= 1'b1; end else if ( step_cnt == 1 ) begin mot_out_a <= 1'b0; mot_out_b <= 1'b0; mot_out_c <= 1'b1; mot_out_d <= 1'b1; end else if ( step_cnt == 2 ) begin mot_out_a <= 1'b0;