Google Search

Thursday, February 25, 2010

VHDL MODEL OF ROM

ROM is simply the Read Only Memory. That is ,we cannot write or add anything to this type of memory.Here ,I designed a ROM chip with 8 locations.In ROM ,all data values are writing in coding stage itself.So ,if you need more size(say 256 bytes or 1 KB),you have to take more time to design and code it.So I used a ROM with only 8 locations.But you can edit this code as your wish ,for your purposes.

Working:In this design,I used only 8 locations.So I need only 3 bit address bus.Also we need a clock input ,because it is a synchronous circuit.These are the two input ports.And we need an 8 bit output port.If you apply clock,and give any address in the range "000" to "111" as input values,you can see the data from the specified address as output value.

In my code ,the contents of ROM are listed here.

ADDRESS CONTENT
000 00000000
001 00000001
010 00001111
011 00001100
100 00001100
101 00001000
110 00001101
111 00110000

Now the simplified block diagram is given



The VHDL code of ROM chip is given below.This code is useful when you are designing a microprocessor or micro controller.You can use this type of ROM (With more size-You can edit this code) to store program code (Hex code),needed for the working of processor.

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
--prepared by BIJOY K JOSEPH
ENTITY ROM IS
PORT(ADDR:IN STD_LOGIC_VECTOR(2 DOWNTO 0);CLOCK:IN STD_LOGIC;DOUT:OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
END ROM;
ARCHITECTURE BEH123 OF ROM IS
TYPE ROM_ARR IS ARRAY(0 TO 7)OF STD_LOGIC_VECTOR(7 DOWNTO 0);
CONSTANT MEM:ROM_ARR:=
( "00000000","00000001","00001111","00001100","00001100","00001000","00001101","00110000");
BEGIN
PROCESS(CLOCK)
BEGIN
IF RISING_EDGE(CLOCK) THEN
DOUT<=MEM(CONV_INTEGER(ADDR));
END IF;
END PROCESS;
END BEH123;
--success getting output

No comments: