EmbDev.net

Forum: FPGA, VHDL & Verilog Dual-port RAM


von jeorges F. (Company: xlue) (khal1985)


Rate this post
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:
1
ENTITY RAM_2PORT IS
2
  PORT
3
  (
4
    clock    : IN STD_LOGIC  := '1';
5
    data    : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
6
    rdaddress    : IN STD_LOGIC_VECTOR (12 DOWNTO 0);
7
    wraddress    : IN STD_LOGIC_VECTOR (12 DOWNTO 0);
8
    wren    : IN STD_LOGIC  := '0';
9
    q    : OUT STD_LOGIC_VECTOR (31 DOWNTO 0)
10
  );
11
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.
1
 if(rising_edge(CLOCK_50)) then 
2
    
3
       if(interrupt_timer='1') then  -- interrupt that activate the the write in the RAM 
4
        -- RAM dual port mode -----
5
        RAM_W_address<='0' & X"001";
6
        RAM_wren2<='1';
7
        RAM_data_IN2<=X"55555557";
8
      
9
      else 
10
         
11
        -- RAM dual port 
12
        RAM_wren2<='0';
13
        RAM_R_address<='0' & X"001";
14
        LED<=RAM_out2(15 downto 8);
15
      end if; 
16
 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

von Uwe B. (uwe_beis)


Rate this post
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

von jeorges F. (Company: xlue) (khal1985)


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

von Uwe B. (uwe_beis)


Rate this post
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

von jeorges F. (Company: xlue) (khal1985)


Rate this post
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

von Uwe B. (uwe_beis)


Attached files:

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

von jeorges F. (Company: xlue) (khal1985)


Rate this post
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

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.