SlideShare a Scribd company logo
RAM SOURCE CODE & TEST BENCH

--SOURCE CODE
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;

entity ram is
port (address: in std_logic_vector(7 downto 0);
            data: inout std_logic_vector(7 downto 0);
            WE, CS, OE: in std_logic);
end entity ram;

architecture simple_ram of ram is
type ram_type is array (0 to 255) of std_logic_vector(7 downto 0);
signal ram1: ram_type:= (others => (others => '0'));

begin
ram1(conv_integer(address)) <= data when ((CS='0' and WE='0') and OE='1');
data <= ram1(conv_integer(address)) when ((CS='0' and WE='1') and OE='0') else
(others=>'Z');
end simple_ram;

--TEST BENCH

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;

ENTITY Ram_TB IS
END Ram_TB;

ARCHITECTURE behavior OF Ram_TB IS

    -- Component Declaration for the Unit Under Test (UUT)

    COMPONENT ram
    PORT(
          address : IN std_logic_vector(7 downto 0);
          data : INOUT std_logic_vector(7 downto 0);
          WE : IN std_logic;
          CS : IN std_logic;
          OE : IN std_logic
        );
    END COMPONENT;


   --Inputs
   signal address : std_logic_vector(7 downto 0) := (others => '0');
   signal WE : std_logic := '0';
   signal CS : std_logic := '0';
   signal OE : std_logic := '0';

      --Outputs
   signal data : std_logic_vector(7 downto 0);
   -- No clocks detected in port list. Replace <clock> below
----with
   -- appropriate port name
BEGIN

      -- Instantiate the Unit Under Test (UUT)
   uut: ram PORT MAP (
           address => address,
           data => data,
           WE => WE,
           CS => CS,
           OE => OE
        );

   -- Clock process definitions




   stim_proc: process
   begin
      -- hold reset state for 100 ns.
            WE<= '0';
         OE<= '1';
            Address<="00000001";
      Data<=   "00000001";wait for 10 ns;
            Address<="00000010";
            Data<=    "00000010";wait for 10   ns;
            Address<="00000100";
            Data<=    "00000100";wait for 10   ns;
            Address<="00001000";
            Data<=    "00001000";wait for 10   ns;
            Address<="00010000";
            Data<=    "00010000";wait for 10   ns;
            Address<="00100000";
            Data<=    "00100000";wait for 10   ns;
            Address<="01000000";
            Data<=    "01000000";wait for 10   ns;
            Address<="10000000";
            Data<=    "10000000";wait for 10   ns;
            WE<= '1';
         OE<= '0';
            Data<=    "ZZZZZZZZ";
            Address<="00000001";wait for 10    ns;
            Address<="00000010";wait for 10    ns;
            Address<="00000100";wait for 10    ns;
            Address<="00001000";wait for 10    ns;
            Address<="00010000";wait for 10    ns;
            Address<="00100000";wait for 10    ns;
            Address<="01000000";wait for 10    ns;
            Address<="10000000";wait for 10    ns;
            Address<="00000000";wait for 10    ns;
  end process;

END;

More Related Content

PDF
FPGA Design Challenges
PPTX
Routing Protocols in WSN
PDF
Cisco Live! :: Cisco ASR 9000 Architecture :: BRKARC-2003 | Milan Jan/2014
PDF
Xilinx lca and altera flex
PPT
Introduction to VHDL - Part 1
PDF
Full custom Ic design Implementation of low power priority encoder
PDF
Design and implementation of 32 bit alu using verilog
PPTX
FPGA Design Challenges
Routing Protocols in WSN
Cisco Live! :: Cisco ASR 9000 Architecture :: BRKARC-2003 | Milan Jan/2014
Xilinx lca and altera flex
Introduction to VHDL - Part 1
Full custom Ic design Implementation of low power priority encoder
Design and implementation of 32 bit alu using verilog

What's hot (20)

PPTX
Introduction to FPGAs
PDF
VLSI Fresher Resume
PPTX
Xilinx virtex 7 fpga - Semester Presentation
PPTX
LOGIC GATES VIDEO LECTURE IN HINDI|OR GATE,AND GATE &NOT GATE|LOGIC DIAGRAM &...
PDF
Introduction to Software Defined Networking (SDN)
PPTX
I2c protocol - Inter–Integrated Circuit Communication Protocol
PDF
Optical Transport Network
DOCX
Altera flex
PPT
Wireless routing protocols
PPTX
PPTX
Field programable gate array
ODP
APB protocol v1.0
PDF
Soc architecture and design
PPTX
PPTX
Dynamic Voltage and Frequency Scaling
PPT
Layer 2 switching fundamentals(networking)
PDF
AMBA 2.0 REPORT
PPTX
System partitioning in VLSI and its considerations
PPT
Ethernet protocol
Introduction to FPGAs
VLSI Fresher Resume
Xilinx virtex 7 fpga - Semester Presentation
LOGIC GATES VIDEO LECTURE IN HINDI|OR GATE,AND GATE &NOT GATE|LOGIC DIAGRAM &...
Introduction to Software Defined Networking (SDN)
I2c protocol - Inter–Integrated Circuit Communication Protocol
Optical Transport Network
Altera flex
Wireless routing protocols
Field programable gate array
APB protocol v1.0
Soc architecture and design
Dynamic Voltage and Frequency Scaling
Layer 2 switching fundamentals(networking)
AMBA 2.0 REPORT
System partitioning in VLSI and its considerations
Ethernet protocol
Ad

Viewers also liked (20)

DOCX
301378156 design-of-sram-in-verilog
TXT
Ram sourcecode&testbench
ODP
VHDL Packages, Coding Styles for Arithmetic Operations and VHDL-200x Additions
PDF
见微知著——无线产品交互细节
PPTX
Vhdl programming
PPTX
Interconnection Network
PDF
Programs of VHDL
PDF
TIPS ON SCIENTIFIC WRITING & EDITING METHODOLOGIES
DOCX
Rescue.asd
PDF
Avaya cc control manager 6.2 brochure
PDF
Yliko pake geniko_meros_201105.20-27
DOCX
Sahar Saqib - Transcript of Oral Presentation
PDF
Hacking your Kindle (OSCON Lightning Talk)
KEY
Intro to developing for @twitterapi (updated)
PDF
IBM Big Data References
PPTX
DOC
Text 4 superlatives ok
PPTX
CIF ppt 21.12.12
DOCX
No tlp Polisi
DOCX
Ikp'ko;b0yp
301378156 design-of-sram-in-verilog
Ram sourcecode&testbench
VHDL Packages, Coding Styles for Arithmetic Operations and VHDL-200x Additions
见微知著——无线产品交互细节
Vhdl programming
Interconnection Network
Programs of VHDL
TIPS ON SCIENTIFIC WRITING & EDITING METHODOLOGIES
Rescue.asd
Avaya cc control manager 6.2 brochure
Yliko pake geniko_meros_201105.20-27
Sahar Saqib - Transcript of Oral Presentation
Hacking your Kindle (OSCON Lightning Talk)
Intro to developing for @twitterapi (updated)
IBM Big Data References
Text 4 superlatives ok
CIF ppt 21.12.12
No tlp Polisi
Ikp'ko;b0yp
Ad

Similar to RAM Source code and Test Bench (6)

PDF
m4_VHDL_ED.pdf
PDF
I am try to create a program that takes a user typed MIPS instructio.pdf
DOCX
Adventure time
DOCX
Reporte vhd10
PDF
Nagios Conference 2013 - Michael Medin - NSClient++ Whats New
PDF
Ns client++ whats new (nwc2013)
m4_VHDL_ED.pdf
I am try to create a program that takes a user typed MIPS instructio.pdf
Adventure time
Reporte vhd10
Nagios Conference 2013 - Michael Medin - NSClient++ Whats New
Ns client++ whats new (nwc2013)

Recently uploaded (20)

PPT
EGWHermeneuticsffgggggggggggggggggggggggggggggggg.ppt
PPTX
Tenders & Contracts Works _ Services Afzal.pptx
PDF
Urban Design Final Project-Site Analysis
PPTX
BSCS lesson 3.pptxnbbjbb mnbkjbkbbkbbkjb
PPTX
ANATOMY OF ANTERIOR CHAMBER ANGLE AND GONIOSCOPY.pptx
DOCX
actividad 20% informatica microsoft project
PPT
pump pump is a mechanism that is used to transfer a liquid from one place to ...
PPTX
12. Community Pharmacy and How to organize it
PPT
UNIT I- Yarn, types, explanation, process
PDF
Facade & Landscape Lighting Techniques and Trends.pptx.pdf
PDF
Quality Control Management for RMG, Level- 4, Certificate
PDF
BRANDBOOK-Presidential Award Scheme-Kenya-2023
PPTX
mahatma gandhi bus terminal in india Case Study.pptx
PDF
GREEN BUILDING MATERIALS FOR SUISTAINABLE ARCHITECTURE AND BUILDING STUDY
PPTX
Wisp Textiles: Where Comfort Meets Everyday Style
PPTX
areprosthodontics and orthodonticsa text.pptx
PDF
Urban Design Final Project-Context
PDF
Integrated-2D-and-3D-Animation-Bridging-Dimensions-for-Impactful-Storytelling...
PPTX
HPE Aruba-master-icon-library_052722.pptx
PDF
Skskkxiixijsjsnwkwkaksixindndndjdjdjsjjssk
EGWHermeneuticsffgggggggggggggggggggggggggggggggg.ppt
Tenders & Contracts Works _ Services Afzal.pptx
Urban Design Final Project-Site Analysis
BSCS lesson 3.pptxnbbjbb mnbkjbkbbkbbkjb
ANATOMY OF ANTERIOR CHAMBER ANGLE AND GONIOSCOPY.pptx
actividad 20% informatica microsoft project
pump pump is a mechanism that is used to transfer a liquid from one place to ...
12. Community Pharmacy and How to organize it
UNIT I- Yarn, types, explanation, process
Facade & Landscape Lighting Techniques and Trends.pptx.pdf
Quality Control Management for RMG, Level- 4, Certificate
BRANDBOOK-Presidential Award Scheme-Kenya-2023
mahatma gandhi bus terminal in india Case Study.pptx
GREEN BUILDING MATERIALS FOR SUISTAINABLE ARCHITECTURE AND BUILDING STUDY
Wisp Textiles: Where Comfort Meets Everyday Style
areprosthodontics and orthodonticsa text.pptx
Urban Design Final Project-Context
Integrated-2D-and-3D-Animation-Bridging-Dimensions-for-Impactful-Storytelling...
HPE Aruba-master-icon-library_052722.pptx
Skskkxiixijsjsnwkwkaksixindndndjdjdjsjjssk

RAM Source code and Test Bench

  • 1. RAM SOURCE CODE & TEST BENCH --SOURCE CODE library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; USE ieee.numeric_std.ALL; entity ram is port (address: in std_logic_vector(7 downto 0); data: inout std_logic_vector(7 downto 0); WE, CS, OE: in std_logic); end entity ram; architecture simple_ram of ram is type ram_type is array (0 to 255) of std_logic_vector(7 downto 0); signal ram1: ram_type:= (others => (others => '0')); begin ram1(conv_integer(address)) <= data when ((CS='0' and WE='0') and OE='1'); data <= ram1(conv_integer(address)) when ((CS='0' and WE='1') and OE='0') else (others=>'Z'); end simple_ram; --TEST BENCH LIBRARY ieee; USE ieee.std_logic_1164.ALL; -- Uncomment the following library declaration if using -- arithmetic functions with Signed or Unsigned values --USE ieee.numeric_std.ALL; ENTITY Ram_TB IS END Ram_TB; ARCHITECTURE behavior OF Ram_TB IS -- Component Declaration for the Unit Under Test (UUT) COMPONENT ram PORT( address : IN std_logic_vector(7 downto 0); data : INOUT std_logic_vector(7 downto 0); WE : IN std_logic; CS : IN std_logic; OE : IN std_logic ); END COMPONENT; --Inputs signal address : std_logic_vector(7 downto 0) := (others => '0'); signal WE : std_logic := '0'; signal CS : std_logic := '0'; signal OE : std_logic := '0'; --Outputs signal data : std_logic_vector(7 downto 0); -- No clocks detected in port list. Replace <clock> below ----with -- appropriate port name
  • 2. BEGIN -- Instantiate the Unit Under Test (UUT) uut: ram PORT MAP ( address => address, data => data, WE => WE, CS => CS, OE => OE ); -- Clock process definitions stim_proc: process begin -- hold reset state for 100 ns. WE<= '0'; OE<= '1'; Address<="00000001"; Data<= "00000001";wait for 10 ns; Address<="00000010"; Data<= "00000010";wait for 10 ns; Address<="00000100"; Data<= "00000100";wait for 10 ns; Address<="00001000"; Data<= "00001000";wait for 10 ns; Address<="00010000"; Data<= "00010000";wait for 10 ns; Address<="00100000"; Data<= "00100000";wait for 10 ns; Address<="01000000"; Data<= "01000000";wait for 10 ns; Address<="10000000"; Data<= "10000000";wait for 10 ns; WE<= '1'; OE<= '0'; Data<= "ZZZZZZZZ"; Address<="00000001";wait for 10 ns; Address<="00000010";wait for 10 ns; Address<="00000100";wait for 10 ns; Address<="00001000";wait for 10 ns; Address<="00010000";wait for 10 ns; Address<="00100000";wait for 10 ns; Address<="01000000";wait for 10 ns; Address<="10000000";wait for 10 ns; Address<="00000000";wait for 10 ns; end process; END;