FPGA片内RAM读写测试 Verilog逻辑源码Quartus工程文件+文档说明,FPGA型号Cyclone4E系列中的EP4CE6F17C8,Quartus版本17.1。 imescale 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 );
FPGA读写SD卡测试实验 Verilog逻辑源码Quartus工程文件+文档说明,FPGA型号Cyclone4E系列中的EP4CE6F17C8,Quartus版本17.1。 // 2017/6/19 meisq 1.0 Original //*******************************************************************************/ module sd_card_test( input clk, input rst_n, input key1, output SD_nCS, output SD_DCLK, output SD_MOSI, input SD_MISO, output [5:0] seg_sel, output [7:0] seg_data ); parameter S_IDLE = 0; parameter S_READ = 1; parameter S_WRITE = 2; parameter S_END = 3; reg[3:0] state; wire sd_init_done; reg sd_sec_read; wire[31:0] sd_sec_read_addr; wire[7:0] sd_sec_read_data; wire sd_sec_read_data_valid; wire sd_sec_read_end; reg sd_sec_write; wire[31:0] sd_sec_write_addr; reg [7:0] sd_sec_write_data; wire sd_sec_write_data_req; wire sd_sec_write_end; reg[9:0] wr_cnt; reg[9:0] rd_cnt; wire button_negedge; reg[7:0] read_data; ax_debounce ax_debounce_m0 ( .clk (clk), .rst (~rst_n), .button_in (key1), .button_posedge (), .button_negedge (button_negedge), .button_out () ); wire[6:0] seg_data_0; seg_decoder seg_decoder_m0( .bin_data (read_data[3:0]), .seg_data (seg_data_0) ); wire[6:0] seg_data_1; seg_decoder seg_decoder_m1( .bin_data (read_data[7:4]), .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 ({sd_init_done,seg_data_0}) ); always@(posedge clk or negedge rst_n) begin if(rst_n == 1'b0) wr_cnt <= 10'd0; else if(state == S_WR
FPGA读写 AD9708+ AD9280 ADDA实验Verilog逻辑源码Quartus工程源码文件+文档说明,FPGA型号Cyclone4E系列中的EP4CE6F17C8,Quartus版本17.1。 //2017/7/20 1.0 Original //*******************************************************************************/ module top( input clk, input rst_n, //adc input[7:0] ad9280_data, output ad9280_clk, //dac output[7:0] ad9708_data, output ad9708_clk, //vga output output vga_out_hs, //vga horizontal synchronization output vga_out_vs, //vga vertical synchronization output[4:0] vga_out_r, //vga red output[5:0] vga_out_g, //vga green output[4:0] vga_out_b //vga blue ); wire video_clk; wire video_hs; wire video_vs; wire video_de; wire[7:0] video_r; wire[7:0] video_g; wire[7:0] video_b; wire grid_hs; wire grid_vs; wire grid_de; wire[7:0] grid_r; wire[7:0] grid_g; wire[7:0] grid_b; wire wave0_hs; wire wave0_vs; wire wave0_de; wire[7:0] wave0_r; wire[7:0] wave0_g; wire[7:0] wave0_b; wire adc_clk; wire adc0_buf_wr; wire[10:0] adc0_buf_addr; wire[7:0] adc0_buf_data; wire dac_clk; wire[7:0] dac_data; reg[8:0] rom_addr; assign vga_out_hs = wave0_hs; assign vga_out_vs = wave0_vs; assign vga_out_r = wave
cyclone4 FPGA读写片内ROM读写测试 Verilog逻辑源码Quartus工程文件+文档说明,FPGA型号Cyclone4E系列中的EP4CE6F17C8,Quartus版本17.1。 module rom_test( input clk, //50MHz时钟 input rst_n //复位信号,低电平有效 ); //----------------------------------------------------------- reg[4:0] rom_addr; //ROM输入地址 wire[7:0] rom_data; //ROM的数据 //产生ROM地址读取数据测试 always @(posedge clk or negedge rst_n) if(rst_n==1'b0) rom_addr <= 10'd0; else rom_addr <= rom_addr+1'b1; //----------------------------------------------------------- //实例化ROM rom_ip rom_ip_inst ( .clock (clk ), // input clock .address (rom_addr ), // input [4 : 0] address .q (rom_data ) // output [7 : 0] q );
cyclone4 FPGA 读写sdram_Verilog逻辑源码Quartus工程文件+文档说明,FPGA型号Cyclone4E系列中的EP4CE6F17C8,Quartus版本17.1。
cyclone4 FPGA 读写片内FIFO读写测试 Verilog逻辑源码Quartus工程文件+文档说明,FPGA型号Cyclone4E系列中的EP4CE6F17C8,Quartus版本17.1。
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设计控制蜂鸣器播放音乐实验的Verilog逻辑源码Quartus工程文件+文档说明,根据简谱不同简谱名频率让蜂鸣器发出不一样的响声,FPGA型号Cyclone4E系列中的EP4CE6F17C8,Quartus版本17.1。 module music_top ( input clk, input rst_n, input key1, output reg buzzer ) ; parameter CLK_FRE = 50 ; parameter music_len = 32'd78 ; wire [19:0] cycle ; reg [31:0] play_cnt ; reg [31:0] music_cnt ; reg [19:0] hz_cnt ; wire [4:0] hz_sel ; wire [7:0] rom_hz_data ; wire [7:0] rom_time_data ; reg [31:0] music_time ; wire button_negedge ; parameter IDLE = 2'd0 ; parameter PLAY = 2'd1 ; parameter PLAY_WAIT = 2'd2 ; parameter PLAY_END = 2'd3 ; reg [1:0] state ; reg [1:0] next_state ; always @(posedge clk or negedge rst_n) begin if (~rst_n) state <= IDLE ; else state <= next_state ; end always @(*) begin case(state) IDLE : begin if (button_negedge) next_state <= PLAY ; else next_state <= IDLE ; end PLAY : begin if (play_cnt == music_time) next_state <= PLAY_WAIT ; else next_state <= PLAY ; end PLAY_WAIT : begin if (music_cnt == music_len - 1) next_state <= PLAY_END ; else next_state <= PLAY ; end PLAY_END : next_state <= IDLE ; default : next_state <= IDLE ; endcase end ax_debounce ax_debounce_a0 ( .clk (clk), .rst (~rst_n), .button_in (key1), .button_posedge (), .button_negedge (button_negedge), .button_out () ); //play counter always @(posedge clk or negedge rst_n) begin if (~rst_n) music_time <= 32'hffff_ffff ; else music_time <= rom_time_data*(CLK_FRE*1000000/8) ; end //counter in every step, maximum value is cycle always @(posedge clk or negedge rst_n) begin if (~rst_n) hz_cnt <= 20'd0 ; else if (state == PLAY || state == PLAY_WAIT) begin if (hz_cnt == cycle - 1) hz_cnt <= 20'd0 ; else hz_cnt <=