banner
Moerjie

Moerjie

hello world

IP-ROM

ROM#

read only memory

.coe 文件生成#

%% sin-cos wave data write in coe file
clear 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 format
fprintf( fid, 'MEMORY_INITIALIZATION_RADIX = 10;\n');                     
fprintf( fid, 'MEMORY_INITIALIZATION_VECTOR =\n');
%- write data in coe file
for i = 1:1:N
    fprintf(fid,'%d,\n',y(i,1));  
end
fclose(fid);

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

Block Memory Generator 参数#

image.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 图#

image.png

读取数据波形#

image.png

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.