EmbDev.net

Forum: FPGA, VHDL & Verilog Dual-port RAM


Author: jeorges FrenchRivera (Company: xlue) (khal1985)
Posted on:

Rate this post
0 useful
not useful
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

Author: Uwe Beis (uwe_beis)
Posted on:

Rate this post
0 useful
not useful
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

Author: jeorges FrenchRivera (Company: xlue) (khal1985)
Posted on:

Rate this post
0 useful
not useful
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,

Author: Uwe Beis (uwe_beis)
Posted on:

Rate this post
0 useful
not useful
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

Author: jeorges FrenchRivera (Company: xlue) (khal1985)
Posted on:

Rate this post
0 useful
not useful
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

Author: Uwe Beis (uwe_beis)
Posted on:
Attached files:

Rate this post
0 useful
not useful
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"?

Author: jeorges FrenchRivera (Company: xlue) (khal1985)
Posted on:

Rate this post
0 useful
not useful
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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.