IP-ROM

ROM

read only memory ## .coe文件生成

%% sin-cos wave data write in coe fileclear all ;clc ;N = 4096 ;y = zeros(N , 1) ;for i = 1:1:N
    x = i ;    y(i,1) = ceil( 127*sin(x*2*pi/N) ) + 127 ;    %y(i,1) = ceil( 127*cos(x*2*pi/N) ) + 127 ;end
plot(y);hold on;fid = fopen('cos_4096.coe','wt');
%- standard formatfprintf( fid, 'MEMORY_INITIALIZATION_RADIX = 10;\n');
fprintf( fid, 'MEMORY_INITIALIZATION_VECTOR =\n');%- write data in coe filefor i = 1:1:N    fprintf(fid,'%d,\n',y(i,1));
endfclose(fid);

摘取自#【FPGA】:matlab生成coe文件

Block Memory Generator参数

202401301745407.png

产生地址信号

module ADDR_Gen(
    clk,
    rst_n,
    addr,
    ena
    );
    input clk;
    input rst_n;
    output [11:0] addr;
    output ena;
    reg [11:0] addr;
    
    assign ena=1'b1;
    always @(posedge clk or negedge rst_n ) begin
        if(rst_n==1'b0)
        begin
            addr<=0;
        end
        else if(addr==12'b1111_1111_1111)begin
            addr<=12'b000_000_000_000;
        end  
        else begin
            addr<=addr+1'b1;
        end  
    end
endmodule

BD图

202401301111659.png

读取数据波形

202401301111205.png

posted @ 2024-02-07 22:09  moerjie  阅读(13)  评论(0编辑  收藏  举报