Hi everyone; I need to store data comes from an external ADC. So, i opted to use the internal Memory M9K implemented in my Cyclone IV FPGA. For that purpose, i used the mega-function ALTSYNCRAM provided by Altera. The code is below:
ENTITY RAM_2PORT IS PORT ( clock : IN STD_LOGIC := '1'; data : IN STD_LOGIC_VECTOR (31 DOWNTO 0); rdaddress : IN STD_LOGIC_VECTOR (12 DOWNTO 0); wraddress : IN STD_LOGIC_VECTOR (12 DOWNTO 0); wren : IN STD_LOGIC := '0'; q : OUT STD_LOGIC_VECTOR (31 DOWNTO 0) ); END RAM_2PORT;
For this RAM there are two addresses, one fro write operations and the other one for read operations. I have created init_file(ram.mif) with known values, to initialize the RAM. When i write a value in a specified address, i can read it after.
if(rising_edge(CLOCK_50)) then if(interrupt_timer='1') then -- interrupt that activate the the write in the RAM -- RAM dual port mode ----- RAM_W_address<='0' & X"001"; RAM_wren2<='1'; RAM_data_IN2<=X"55555557"; else -- RAM dual port RAM_wren2<='0'; RAM_R_address<='0' & X"001"; LED<=RAM_out2(15 downto 8); end if; end if;
The problem is I get only zero when i want to read an initialized value loaded from the init_file. Do you have an idea what would be the problem ? Thank for any help. Best Regards
Hi, jeorges FrenchRivera wrote: > The problem is I get only zero when i want to read an initialized value > loaded from the init_file. You describe that you write X"55555557" at address X"001", but you ask why you read '0' instead of an initialized value from the init_file. Why did you describe that and how you write? Why didn't you describe how your input file looks like and how you cared that it is really used in the Wizard? Do you read the written value X"55555557" at all? Regards
Thank you Uwe for your answer, i made a mistake about the address to read, i want to write RAM_R_address<='0' & X"003"; the input from the init_file associated to the address given is X"01234512". But as I described i obtained only Zero. On the other side, when i write and then read from the same address, it's ok Best regards,
Hi, there are still 2 of my 3 questions left: Why didn't you describe how your init_file looks like? Are you sure that the init_file is really used in the Wizard? Would you ask me for a assumption, I'd assume that you didn't enable the init_file in the Wizard. Regards, Uwe
Hi, the init-file is an .mif. Yes i'm sure that is used in the Wizard. But I noticed that the Wizard asks me this : The initial content file should conform to which port's dimensions ? there are two ports A and B, but we can select only B. What do you mean by enable the init-file ? and how? Thanks in advance
jeorges FrenchRivera wrote: > The initial content file should conform to which port's > dimensions ? there are two ports A and B, but we can select only B. Look at my example: This is a dual ported and initialized RAM where the written data (PORT_A) is 9 bits wide and the read data (PORT_B) is 36 bits wide. Thus I have to chose the Port. When both of your ports are equal, then there is nothing to chose. jeorges FrenchRivera wrote: > What do you mean by enable the init-file ? and how? When you have a setting like in my example then it is obviously ok. Obviously you have it, otherwise you wouldn't ask the previous question. In that case I'd suspect next that something with the .MIF file is wrong. Did you have a close look that no corresponding warning appears, e.g., somthing like "File xyz.MIF not found"?
No, i don't have any warning concerning the init_file. But I observe a strange behavior. If a write at a specified address for example RAM_W_address<='0' & X"005", when I read an initialized value from the init-file a for given address , the value read is always the value corresponding to the address '0' & X"005" in the init-file. Expect the case when the write and the read address are the same, there is no problem. What do you think about this issue? Best regards