Cyclone2 FPGA读写SRAM IS61LV25616 实验Verilog逻辑源码Quartus工程文件 module SRAM_TEST ( //input input sys_clk , //system clock; input sys_rst_n , //system reset, low is active; //output inout [15:0] SRAM_DQ , output reg [17:0] SRAM_ADDR , output reg SRAM_CE , output reg SRAM_OE , output reg SRAM_WE , output reg SRAM_UB , output reg SRAM_LB , output reg [ 7:0] LED ); //Reg define reg [3:0] div_cnt ; reg sram_clk ; reg [5:0] ctrl_cnt ; reg [15:0] sram_data_lck ; reg [15:0] sram_din ; //Wire define //************************************************************************************ //** Main Program //** //************************************************************************************ // counter used for div osc clk to sram ctrl clk 50M/16 always @(posedge sys_clk or negedge sys_rst_n) begin if (sys_rst_n ==1'b0) div_cnt <= 4'b0; else div_cnt <= div_cnt + 4'b1; end //gen sram_clk always @(posedge sys_clk or negedge sys_rst_n) begin if (sys_rst_n ==1'b0) sram_clk <= 1'b0 ; else if ( div_cnt <= 4'd7 ) sram_clk <= 1'b1 ; else sram_clk <= 1'b0 ; end // sram ctrl signal gen // ctrl_cnt 0 - 31 is for write ctrl // ctrl_cnt 31 - 63 is for read ctrl always @(posedge sram_clk or negedge sys_rst_n) begin if (sys_rst_n ==1'b0) ctrl_cnt <= 6'b0; else ctrl_cnt <= ctrl_cnt + 6'b1; end always @(posedge sram_clk or negedge sys_rst_n) begin if (sys_rst_n ==1'b0) SRAM_ADDR <= 18'b0; else if ( ctrl_cnt
Cyclone4 FPGA读写高速AD-TLC549+DA-AD9708模块实验Verilog逻辑源码Quartus工程+文档资料 module DA_AD9708_BASE ( //input input sys_clk , //system clock; // input sys_rst_n , //system reset, low is active; input [3:0] key , //output output reg [7:0] DA_DATA , output reg DA_CLK , output reg [7:0] LED ); //Reg define reg [7:0] div_cnt ; //Wire define //************************************************************************************ //** Main Program //** //************************************************************************************ assign sys_rst_n = 1'b1 ; // counter used for div osc clk to ad ctrl clk 50M/4 = 12.5Mhz always @(posedge sys_clk or negedge sys_rst_n) begin if (sys_rst_n ==1'b0) div_cnt <= 8'b0; else div_cnt <= div_cnt + 8'b1; end //gen DA_CLK always @(posedge sys_clk or negedge sys_rst_n) begin if (sys_rst_n ==1'b0) DA_CLK <= 1'b0 ; else if ( div_cnt == 8'd0 ) DA_CLK <= ~DA_CLK ; else ; end //display AD sample data to LED always @(posedge DA_CLK or negedge sys_rst_n) begin if (sys_rst_n ==1'b0) DA_DATA <= 8'b0; else DA_DATA <= { key, key }; end //display AD sample data to LED always @(posedge DA_CLK or negedge sys_rst_n) begin if (sys_rst_n ==1'b0) LED <= 8'b0; else LED <= { key, key } ; end
FPGA读写SDRAM page fifo实验完整Verilog逻辑源码Quartus工程文件, Quartus软件版本11.0, FPGA型号为CYCLONE4E系列中的EP4CE6E22C8,可以做为你的学习设计参考。 module sdram_read_write( clk, reset_n, state_signal, rw_done_signal, ar_done_signal, sdram_bank_addr, write_data, read_data, io_ctl, sdram_command, sdram_address, sdram_dqm, sdram_data ); //参数定义 //端口定义 input clk; //时钟信号100MHz input reset_n; //复位信号,低电平有效 input [2:0] state_signal; //状态信号,用于控制对SDRAM进行读写和自刷新 input [21:0] sdram_bank_addr; //SDRAM最小单元地址,[21:20]块地址+[19:8]行地址Row+[7:0]列地址Column input [15:0] write_data; //写入SDRAM的数据 input io_ctl; output rw_done_signal; //读写完成信号 output ar_done_signal; //自动刷新完成信号 output [15:0] read_data; //从SDRAM读出的数据 output [4:0] sdram_command; //SDRAM指令,cke、cs_n、ras、cas_n、we_n,SDRAM指令信号 output [13:0] sdram_address; //SDRAM读写地址 output [1:0] sdram_dqm; //SDRAM数据掩码 inout [15:0] sdram_data; //sdram读写数据 //常量定义 parameter NOP = 5'b10111, //空操作 ACTIVE = 5'b10011, //行激活 READ = 5'b10101, //读操作 WRITE = 5'b10100, //写操作 PR = 5'b10010, //预充电 AR = 5'b10001, //自刷新 LMR = 5'b10000, //设置寄存器 BURST_STOP = 5'b10110; //突发停止指令 parameter ar_state = 3'b001, //自刷新状态 re
同步十位减法计数器Cyclone4E FPGA设计Verilog逻辑源码Quartus工程文件, Quartus软件版本11.0, FPGA型号为CYCLONE4E系列中的EP4CE6E22C8,可以做为你的学习设计参考。 module cnt_jf(clk,rst,q); input clk; //输入时钟 input rst; //输入复位信号,高电平有效 output[3:0] q; //输出计数端 reg[3:0] q; //输出计数端寄存器 always@(posedge clk) //时钟上升沿触发 begin if(rst) //判断rst是否有效 begin q<=0; //q清零 end else if(q==4'b0000) //q是否等于0 begin q<=4'b1001; //q置9 end else begin q<=q-4'b1; //q自减1
按键计数将结果通过8段数码管显示FPGA设计Verilog逻辑源码Quartus11.0工程文件,FPGA型号为CYCLONE4E系列中的EP4CE6E22C8,可以做为你的学习设计参考。 module key_counter(clk,key,reset,seg_duan,seg_wei); input clk,key,reset; output [7:0] seg_duan; output [2:0] seg_wei; wire clk,key,reset; reg [7:0] seg_duan;//数码管段选 reg [2:0] seg_wei;//数码管位选 reg key_out; parameter s0=2'b00,s1=2'b01,s2=2'b10,s3=2'b11; reg [1:0] state; reg [3:0] key_counter_ge;//按键计数个位 reg [3:0] key_counter_shi;//按键计数十位 reg [3:0] key_counter_bai;//按键计数百位 reg [9:0] div_count;//数码管扫描时钟分频计数 reg clk_scan;//位选时钟 reg [1:0] wei_select;//位选信号 /****************************按键消抖**********************************/ always @(posedge clk) begin case (state) s0: begin key_out<=1'b1; if(key==1'b0) state<=s1; else state<=s0; end s1: begin if(key==1'b0) state<=s2; else state<=s0; end s2: begin if(key==1'b0) state<=s3; else state<=s0; end s3: begin if(key==1'b0) begin key_out<=1'b0; state<=s3; end else begin key_out<=1'b1; state<=s0; end end default: state<=s0; endcase end /****************************按键计数**********************************/ always @(negedge key_out or negedge reset) begin if(!reset) begin key_counter_ge <=4'd0; key_counter_shi<=4'd0; key_counter_bai<=4'd0; end else begin if(!key_out)//判断按键是否按下 begin key_counter_ge<=key_counter_ge+1'b1;//按键计数个位加一 if(key_counter_ge==4'd9) begin key_counter_ge<=4'd0;//个位清零 key_counter_shi<=key_counter_shi+1'b1;//按键计数十位加一 if(key_counter_shi==4'd9) begin key_counter_shi<=4'd0;//十位清零
同步4位可逆计数器Cyclone4E FPGA设计Verilog逻辑源码Quartus工程文件, Quartus软件版本11.0, FPGA型号为CYCLONE4E系列中的EP4CE6E22C8,可以做为你的学习设计参考。 module cnt_kn(clk,clr,s,en,updn,d,co,q); input clk,clr,s,en,updn; //输入时钟、清零端(高电平有效)、置数端(高电平有效)、使能端、计数器方向控制端 input[3:0] d; //预置数据端 output[3:0] q; //计数输出端 output co; //进位端 reg[3:0] q; //计数输出寄存器 reg co; //进位输出寄存器 always@(posedge clk) //时钟上升沿触发 begin if(clr) //判断清零端是否有效 begin q<=0; //q置0 end else begin if(s) //判断置数端是否有效 begin q<=d; //q置d中的数据 end else if(en) //判断使能端是否有效 begin if(updn) //判断方向寄存器是否为1 begin if(q==4'b1111) //判断q是否为15 begin q<=4'b0000; //q清0 co<=1; //co置1 end else //q还没到15 begin q<=q+1; //q自加1 co<=0; //co置0
cyclone4 FPGA 按键消抖实验测试 Verilog逻辑源码Quartus工程文件+文档说明,FPGA型号Cyclone4E系列中的EP4CE6F17C8,Quartus版本17.1。
cyclone4 FPGA PWM蜂鸣器实验 Verilog逻辑源码Quartus工程文件+文档说明,FPGA型号Cyclone4E系列中的EP4CE6F17C8,Quartus版本17.1。
基于FPGA的按键消抖实验Verilog逻辑源码Quartus工程文件+文档说明,程序实现按键按下后数字加 1,并在数码管上显示出来,FPGA型号Cyclone4E系列中的EP4CE6F17C8,Quartus版本17.1。 module key_debounce( input clk, input rst_n, input key1, output [5:0] seg_sel, output [7:0] seg_data ); wire button_negedge; //Key falling edge ax_debounce ax_debounce_m0 ( .clk (clk), .rst (~rst_n), .button_in (key1), .button_posedge (), .button_negedge (button_negedge), .button_out () ); wire[3:0] count; wire t0; count_m10 count10_m0( .clk (clk), .rst_n (rst_n), .en (button_negedge), .clr (1'b0), .data (count), .t (t0) ); wire[3:0] count1; wire t1; count_m10 count10_m1( .clk (clk), .rst_n (rst_n), .en (t0), .clr (1'b0), .data (count1), .t (t1) ); //Count decoding wire[6:0] seg_data_0; seg_decoder seg_decoder_m0( .bin_data (count), .seg_data (seg_data_0) ); wire[6:0] seg_data_1; seg_decoder seg_decoder_m1( .bin_data (count1), .seg_data (seg_data_1) ); seg_scan seg_scan_m0( .clk (clk), .rst_n (rst_n), .seg_sel (seg_sel), .seg_data (seg_data), .seg_data_0 ({1'b1,7'b1111_111}), .seg_data_1 ({1'b1,7'b1111_111}), .seg_data_2 ({1'b1,7'b1111_111}), .seg_data_3 ({1'b1,7'b1111_111}), .seg_data_4 ({1'b1,seg_data_1}), .seg_data_5 ({1'b1,seg_data_0}) ); endmodule
FPGA片内RAM读写测试Verilog逻辑源码Quartus工程文件+文档说明,使用 FPGA 内部的 RAM 以及程序对该 RAM 的数据读写操作,FPGA型号Cyclone4E系列中的EP4CE6F17C8,Quartus版本17.1。 `timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// module ram_test( input clk, //50MHz时钟 input rst_n //复位信号,低电平有效 ); //----------------------------------------------------------- reg[8:0] w_addr; //RAM写地址 reg[15:0] w_data; //RAM写数据 reg wea; //RAM PORTA 使能 reg[8:0] r_addr; //RAM读地址 wire[15:0] r_data; //RAM读数据 //产生RAM地址读取数据测试 always @(posedge clk or negedge rst_n) if(rst_n==1'b0) r_addr <= 9'd0; else r_addr <= r_addr+1'b1; ///产生RAM写入的数据 always@(posedge clk or negedge rst_n) begin if(rst_n==1'b0) begin wea <= 1'b0; w_addr <= 9'd0; w_data <= 16'd0; end else begin if(w_addr==511) begin //ram写入完毕 wea <= 1'b0; end else begin wea<=1'b1; //ram写使能 w_addr <= w_addr + 1'b1; w_data <= w_data + 1'b1; end end end //----------------------------------------------------------- //实例化RAM ram_ip ram_ip_inst ( .wrclock (clk ), // input wrclock .wren (wea ), // input [0 : 0] wren .wraddress (w_addr ), // input [8 : 0] wraddress .data (w_data ), // input [15 : 0] data .rdclock (clk ), // input rdclock .rdaddress (r_addr ), // input [8 : 0] rdaddress .q (r_data ) // output [15 : 0] q ); endmodule