Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CODE
- ______________________
- LIBRARY ieee;
- USE ieee.std_logic_1164.ALL;
- use ieee.numeric_std.ALL;
- entity DataMEMORY is
- Port ( MAR : in STD_LOGIC_vector (15 downto 0);
- MDR : in STD_LOGIC_vector (15 downto 0);
- WE : in std_logic;
- Readdata : out STD_LOGIC_vector (15 downto 0));
- end DataMEMORY;
- architecture Behavioral of DataMEMORY is
- type dataMemory is array (0 to 65535) of std_logic_vector(15 downto 0);
- signal DM : dataMemory:=((others=> (others=>'0')));
- begin
- process (MAR)
- begin
- if (WE='1') then
- DM(to_integer(unsigned(MAR)))<=MDR;
- end if ;
- end process;
- Readdata<=DM(to_integer(unsigned(MAR)));
- end Behavioral;
- TESTBENCH
- ____________________________________
- LIBRARY ieee;
- USE ieee.std_logic_1164.ALL;
- use ieee.numeric_std.ALL;
- -- Uncomment the following library declaration if using
- -- arithmetic functions with Signed or Unsigned values
- --USE ieee.numeric_std.ALL;
- ENTITY DataMEMORYTB IS
- END DataMEMORYTB;
- ARCHITECTURE behavior OF DataMEMORYTB IS
- -- Component Declaration for the Unit Under Test (UUT)
- COMPONENT DataMEMORY
- PORT(
- MAR : IN std_logic_vector(15 downto 0);
- MDR : IN std_logic_vector(15 downto 0);
- WE : IN std_logic ;
- Readdata : OUT std_logic_vector(15 downto 0)
- );
- END COMPONENT;
- --Inputs
- signal MAR : std_logic_vector(15 downto 0) := (others => '0');
- signal MDR : std_logic_vector(15 downto 0) := (others => '0');
- signal WE : std_logic := '0';
- --Outputs
- signal Readdata : std_logic_vector(15 downto 0);
- -- No clocks detected in port list. Replace <clock> below with
- -- appropriate port name
- BEGIN
- -- Instantiate the Unit Under Test (UUT)
- uut: DataMEMORY PORT MAP (
- MAR => MAR,
- MDR => MDR,
- WE => WE,
- Readdata => Readdata
- );
- -- Stimulus process
- stim_proc: process
- begin
- -- insert stimulus here
- WE<='1';
- MAR<="1000000000000000";
- MDR<="1010101010101010";
- wait for 100 ns;
- WE<='0';
- MAR<="1000000000000000";
- wait for 100 ns;
- MAR<="1100000000000000";
- WE<='1';
- MDR<="1000000000000000";
- wait for 100 ns;
- MAR<="0000000000000000";
- WE<='0';
- wait for 100 ns;
- MAR<="0000000000000010";
- WE<='0';
- wait for 100 ns;
- wait;
- end process;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement