【IC设计】Vivado单口RAM的使用和时序分析

文章目录

创建单口RAM IP

IP Catalog中选择单口RAM IP

Basic

Port A Options

Other Options

仿真

找到IP例化原语

IP Sources-Instantiation Template-veo文件中找到IP例化原语

编写Testbench

创建single_port_ram_test.v,代码如下:

c 复制代码
`timescale 1ns / 1ps

//功能:测试单口ram
//ena means port a clock enable:
//enables read,write and reset operations through port A.Optional in all configurations.
//wea means port a write enbale:
//enables write operations through port a available in all ram configurations.
module single_port_ram_test();
    reg clk;

    //ena使能
    reg ena;
    
    //write enable a port
    //wea为0时处于读取状态,读取有1个周期的时延,wea为1时处于写入状态
    reg wea;
    
    //地址宽度为10,ram中最多存1024个数据
    reg [9:0] addra;

    //输入数据宽度为32,即4个16进制数据
    reg [31:0] dina;

    //输出数据douta
    wire [31:0] douta;

    reg [3:0] count;
    
    reg rst ;
    
    initial begin
        clk=1;
        rst = 0 ;
        count=4'b0;
        wea=0;
        ena=0;
        @ (negedge clk) ena = 1 ;
        #90;
        dina=32'habcd;
        #20;
        dina=32'h000a;
        #20;
        dina=32'h00ba;
        #20;
        dina=32'h0bcd;
        #20;
        dina=32'hxxxx;
        #120;
        $finish;
    end
    always begin
        #10;
        clk=~clk;
    end

    always @ ( posedge clk , posedge rst ) begin
        if (rst)
            count  <= 'b0 ;
        else if ( count < 'd3  && ena )
            count <= count + 'b1 ;
        else
            count <= 0 ;
    end
    
    //初始状态rst=0,所以将addra置为0
    always @ ( posedge clk , posedge rst ) begin
        if ( rst )
            addra <= 'b0 ;
        //每个上升沿addra+1
        else if ( addra < 3  && ena)
            addra <= addra + 1 ;
        else
            addra <= 'b0 ;
    end
    
    always @ ( posedge clk , posedge rst ) begin
        if (rst)
            wea <= 'b0 ; 
        else if (count == 'd3) 
            wea <= ~ wea ; 
        else
            wea <= wea ;
    end
    
    

    //单口ram实例
    blk_mem_gen_1 single_port_ram_inst (
        .clka(clk),    // input wire clka
        .ena(ena),      // input wire ena
        .wea(wea),      // input wire [0 : 0] wea
        .addra(addra),  // input wire [9 : 0] addra
        .dina(dina),    // input wire [31 : 0] dina
        .douta(douta)  // output wire [31 : 0] douta
    );
endmodule

波形分析

相关推荐
黄埔数据分析2 小时前
QDMA把描述符当数据搬移, 不用desc engine
fpga开发
南檐巷上学9 小时前
基于FPGA的正弦信号发生器、滤波器的设计(DAC输出点数受限条件下的完整正弦波产生器)
fpga开发·数字信号处理·dsp·dds
嵌入式-老费13 小时前
Linux Camera驱动开发(fpga + csi rx/csi tx)
fpga开发
ALINX技术博客1 天前
【202601芯动态】全球 FPGA 异构热潮,ALINX 高性能异构新品预告
人工智能·fpga开发·gpu算力·fpga
JJRainbow1 天前
SN75176 芯片设计RS-232 转 RS-485 通信模块设计原理图
stm32·单片机·嵌入式硬件·fpga开发·硬件工程
s9123601011 天前
FPGA眼图
fpga开发
北京青翼科技1 天前
【PCIe732】青翼PCIe采集卡-优质光纤卡- PCIe接口-万兆光纤卡
图像处理·人工智能·fpga开发·智能硬件·嵌入式实时数据库
minglie11 天前
verilog信号命名规范
fpga开发
XINVRY-FPGA2 天前
中阶FPGA效能红线重新划定! AMD第2代Kintex UltraScale+登场,记忆体频宽跃升5倍
嵌入式硬件·fpga开发·硬件工程·dsp开发·fpga
南檐巷上学2 天前
基于FPGA的音频信号监测识别系统
fpga开发·音频·verilog·fpga·傅立叶分析·fft·快速傅里叶变换