Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > General Computer Support > vhdl code for serial RAM

Reply
Thread Tools

vhdl code for serial RAM

 
 
preithikashap preithikashap is offline
Junior Member
Join Date: Jun 2010
Posts: 1
 
      06-15-2010
hiii

i need a vhdl code for a serial ram (ram stores a 16 bit data and it shold output the data serially )code for my work immediately. please please can some one help me write the code.

its really urgent. thanks in advance.
 
Reply With Quote
 
 
 
 
faust861 faust861 is offline
Junior Member
Join Date: Jun 2010
Posts: 3
 
      06-23-2010
I would do that like this:

library ieee;
use ieee.std_logic_1164.all;

entity serial_ram is
generic (
n : integer := 16
);
port (
data : in std_logic;
clk : in std_logic;
en_write : in std_logic;
en_read : in std_logic;
q: out std_logic
);
end;

architecture behavioral of serial_ram is

signal memo : std_logic_vector(n-1 downto 0);

begin

write_data : process(clk,en_write)
variable i : integer := 0;
begin
if (rising_edge(clk) and en_write = '1') then
memo(i) <= data;
i := i+1;
end if;
if (i=n) then
i := 0;
end if;
end process;

read_data : process(clk,en_read)
variable k : integer := 0;
begin
if (rising_edge(clk) and en_read = '1') then
q <= memo(k);
k := k+1;
end if;
if (k=n) then
k := 0;
end if;
end process;

end behavioral;

I did it in 5 minutes, I don't think it's the best implementation but with a few simulation you can discover how to implement the best functionalities for your use.
For example, you have to read or write, never doing both...if both enables are '1' this Ram doesn't work as you wish.
Another thing, maybe the variables in the processes can annoy you...maybe you will prefer signals.
You must simulate and try.

Bye
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VHDL-2002 vs VHDL-93 vs VHDL-87? afd VHDL 1 03-23-2007 09:33 AM
350d serial number - what serial number?!? GT Digital Photography 6 04-07-2005 07:58 PM
Test Serial to Serial Connection, Protocol Down... Scooter Cisco 5 12-16-2004 04:38 PM
Can I connect router Serial interface directly to a PC serial port? Faustino Dina Cisco 2 08-18-2004 02:30 AM
Looking for a VHDL or Verilog RAM Model that modles Common RAM Faults Robert Posey VHDL 0 11-26-2003 07:50 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57