Advertisement
Guest User

Untitled

a guest
May 30th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.18 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. use work.constants.all;
  5.  
  6. entity tb_top_level is
  7. end entity tb_top_level;
  8.  
  9. architecture RTL of tb_top_level is
  10.     constant period : time := 10 ns;
  11.     signal clk : std_logic;
  12.     signal rst : std_logic;
  13.     signal ready: std_logic;
  14.     signal cpu_rd: std_logic;
  15.     signal cpu_wr: std_logic;
  16.     signal dram_rd: std_logic;
  17.     signal dram_wr: std_logic;
  18.     signal done: std_logic;
  19.     signal address: std_logic_vector(15 downto 0);
  20.     signal data: std_logic_vector(15 downto 0);
  21.    
  22. begin
  23.     ClockDriver : process
  24.     begin
  25.         clk <= '0';
  26.         wait for period / 2;
  27.         clk <= '1';
  28.         wait for period / 2;
  29.     end process ClockDriver;
  30.    
  31.     Cache: entity work.cache_controller
  32.         port map(
  33.             clk     => clk,
  34.             rst     => rst,
  35.             ready   => ready,
  36.             cpu_rd  => cpu_rd,
  37.             cpu_wr  => cpu_wr,
  38.             dram_rd => dram_rd,
  39.             dram_wr => dram_wr,
  40.             done    => done,
  41.             address => address,
  42.             data    => data
  43.         );
  44.    
  45.     Testbench : process
  46.     begin
  47.         -- read with miss
  48.         cpu_rd  <= '1';
  49.         cpu_wr  <= '0';
  50.         done    <= '0';
  51.         address <= "0000000000000000";
  52.         data    <= "ZZZZZZZZZZZZZZZZ";
  53.         wait for 100 ns;
  54.         -- data read from dram simulation
  55.         cpu_rd  <= '0';
  56.         cpu_wr  <= '0';
  57.         done    <= '1';
  58.         address <= "0000000000000000";
  59.         data    <= "0000000000000001";
  60.         wait for 100 ns;
  61.         -- read with miss
  62.         cpu_rd  <= '1';
  63.         cpu_wr  <= '0';
  64.         done    <= '0';
  65.         address <= "0000000000000001";
  66.         data    <= "ZZZZZZZZZZZZZZZZ";
  67.         wait for 100 ns;
  68.         -- data read from dram simulation
  69.         cpu_rd  <= '0';
  70.         cpu_wr  <= '0';
  71.         done    <= '1';
  72.         address <= "0000000000000001";
  73.         data    <= "0000000000000011";
  74.         wait for 100 ns;
  75.         -- read with hit
  76.         cpu_rd  <= '1';
  77.         cpu_wr  <= '0';
  78.         done    <= '0';
  79.         address <= "0000000000000000";
  80.         wait for 100 ns;
  81.         -- write with hit
  82.         cpu_rd  <= '0';
  83.         cpu_wr  <= '1';
  84.         done    <= '0';
  85.         address <= "0000000000000001";
  86.         data    <= "0000000000000111";
  87.         wait for 100 ns;
  88.         -- write with miss
  89.         cpu_rd  <= '0';
  90.         cpu_wr  <= '1';
  91.         done    <= '0';
  92.         address <= "0000000000000010";
  93.         data    <= "0000000000000111";
  94.         wait for 100 ns;
  95.     end process
  96.  
  97. end architecture RTL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement