Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
21618 Discussions

How to set content in a memory

Altera_Forum
Honored Contributor II
1,933 Views

............

0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
1,239 Views

with a mif or hex you can pre set a memory content

0 Kudos
Altera_Forum
Honored Contributor II
1,239 Views

Thanks Alexandre,  

I've checked your suggestion, but what if I've 2 memories? 

Apparently, mif and hex just assign width and depth.  

How to appoint mif A and mif B?
0 Kudos
Altera_Forum
Honored Contributor II
1,239 Views

Besides that,  

I've RAM infer, build in my project. Can I save a data on it in the same way with mif and hex?? 

module SRAM_INFERS(CLK, WA, WE, DI, RA, DO, RA0, DO0, RA1, DO1, RA2, DO2, RA3, DO3); input CLK; /* 256 bit Write port */ input WE; input WA; input DI; /* 256 bit Read port */ input RA; input DO; /* 8 bit Read ports */ input RA0, RA1; input RA2, RA3; output DO0, DO1; output DO2, DO3; wire DO0_tmp, DO1_tmp, DO2_tmp, DO3_tmp, DO_tmp; reg DO0, DO1; reg DO2, DO3; /* Memory */ reg Mem ; always @(posedge CLK) begin if(WE) Mem = DI; end assign DO_tmp = Mem; assign DO0_tmp = Mem]; assign DO1_tmp = Mem]; assign DO2_tmp = Mem]; assign DO3_tmp = Mem]; /* Subfield Extraction for 8 bit Read */ always @(DO0_tmp or RA0) begin casex(RA0) 5'b11111 : DO0 = DO0_tmp; 5'b11110 : DO0 = DO0_tmp; 5'b11101 : DO0 = DO0_tmp; 5'b11100 : DO0 = DO0_tmp; 5'b11011 : DO0 = DO0_tmp; . . . . end endmodule  

regards,
0 Kudos
Altera_Forum
Honored Contributor II
1,239 Views

That won't infer RAM due to asynchronous read. 

That said, you can initialize the RAM contents with a "inital" block and a $readmem function to read data from a file. 

 

Another way is to use a ATLSYNCRAM function and point the INIT_FILE parameter to a .MIF or .HEX file.
0 Kudos
Altera_Forum
Honored Contributor II
1,239 Views

use the mega wizard to create the memory.

0 Kudos
Reply