Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21602 Discussions

sram read and write

Altera_Forum
Honored Contributor II
2,176 Views

i am trying to alter the data stored(by control panel) in sram .i wrote the vhdl program to alter the data and i am reading with control panel to see if it is changed...my problem is every time i am reading only "1" on the data pins...i learnt that before reading the datawe need to put the biderectional data pins in high impedance state.i tried that also...my program is 

 

LIBRARY ieee ; 

USE ieee.std_logic_1164.all ; 

use IEEE.std_logic_unsigned.all; 

entity abc is 

port(clk:in std_logic; --Input from FPGA switches 

din:inout std_logic_vector(15 downto 0); -- Data outputs/inputs from/to SRAM from/to FPGA 

 

ceo,oeo,weo,lbo,ubo:out std_logic; --Inputs to SRAM from FPGA 

addr:out std_logic_vector(17 downto 0)-- Address inputs to SRAM from FPGA 

); 

end; 

architecture abcd of abc is 

 

 

 

 

begin 

ceo <= '0'; 

oeo <= '0'; 

lbo <= '0'; 

ubo <= '0'; 

 

 

process(clk) 

variable temp_addr:std_logic_vector(17 downto 0) :="000010101011001010" ; 

variable temporary: std_logic_vector(15 downto 0); 

variable count,flg:integer range 0 to 100:=0; 

begin 

if clk'event and clk = '1' then 

if (count<=10) then  

if flg = 0 then 

 

 

 

flg:= 1; 

end if;  

if flg = 1 then 

din <= (others => 'Z');  

addr <= temp_addr; 

 

weo <= '1'; 

temporary := din; 

flg := 2; 

end if; 

if flg = 2 then 

temp_addr:=temp_addr+1;  

weo<='0'; 

din <= temporary and x"10ff" ; 

 

flg := 0; 

count := count+1; 

 

end if; 

end if; 

end if; 

end process; 

end; 

 

can anybody please help me find the problem
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
671 Views

It could be a good idea to observe the signals on the SRAM chip with signaltap to see if everything is working as expected. 

Did you check if the pins were mapped correctly? 

I think you need to deassert output enable (oeo?) in order to write.
0 Kudos
Altera_Forum
Honored Contributor II
671 Views

i tried that also,but no use...:(..(oeo is the output enable pin )..all the pins were connected properly,the data is perfectly writen but reading is the problem...it is always reading '1's.. 

can you please post any basic program to read and write the sram...i'll try to infer something from that...i tried searching all over the net ,but i couldn't find it..thanks
0 Kudos
Altera_Forum
Honored Contributor II
671 Views

in vhdl..........

0 Kudos
Altera_Forum
Honored Contributor II
671 Views

I think the problem is you are assigning temporary when din is not 'Z'. when temporary is assigned, din is probably '0'.

0 Kudos
Altera_Forum
Honored Contributor II
671 Views

i am actually new to this vhdl.....but please bear with me...as per i know we should apply 'z' before reading,and reading starts when i assign weo <='1'.so thats why i assigned first 'z' and then i placed address on ADDR port,and i gave weo <='1'...is'nt that the right order..how are you suggesting to do ?

0 Kudos
Altera_Forum
Honored Contributor II
671 Views

hello...............

0 Kudos
Altera_Forum
Honored Contributor II
671 Views

well helloooooooooooooooo triky

0 Kudos
Reply