OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [vhdl/] [tbench.vhd] - Blame information for rev 401

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 rhoads
---------------------------------------------------------------------
2
-- TITLE: Test Bench
3
-- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4
-- DATE CREATED: 4/21/01
5
-- FILENAME: tbench.vhd
6 43 rhoads
-- PROJECT: Plasma CPU core
7 2 rhoads
-- COPYRIGHT: Software placed into the public domain by the author.
8
--    Software 'as is' without warranty.  Author liable for nothing.
9
-- DESCRIPTION:
10 43 rhoads
--    This entity provides a test bench for testing the Plasma CPU core.
11 2 rhoads
---------------------------------------------------------------------
12
library ieee;
13
use ieee.std_logic_1164.all;
14 39 rhoads
use work.mlite_pack.all;
15 346 rhoads
use ieee.std_logic_unsigned.all;
16 2 rhoads
 
17
entity tbench is
18
end; --entity tbench
19
 
20
architecture logic of tbench is
21 48 rhoads
   constant memory_type : string :=
22 139 rhoads
   "TRI_PORT_X";
23
--   "DUAL_PORT_";
24
--   "ALTERA_LPM";
25
--   "XILINX_16X";
26 48 rhoads
 
27
   constant log_file  : string :=
28 139 rhoads
--   "UNUSED";
29 48 rhoads
   "output.txt";
30
 
31 7 rhoads
   signal clk         : std_logic := '1';
32
   signal reset       : std_logic := '1';
33 2 rhoads
   signal interrupt   : std_logic := '0';
34
   signal mem_write   : std_logic;
35 346 rhoads
   signal address     : std_logic_vector(31 downto 2);
36
   signal data_write  : std_logic_vector(31 downto 0);
37
   signal data_read   : std_logic_vector(31 downto 0);
38
   signal pause1      : std_logic := '0';
39
   signal pause2      : std_logic := '0';
40
   signal pause       : std_logic;
41
   signal no_ddr_start: std_logic;
42
   signal no_ddr_stop : std_logic;
43
   signal byte_we     : std_logic_vector(3 downto 0);
44 48 rhoads
   signal uart_write  : std_logic;
45 346 rhoads
   signal gpioA_in    : std_logic_vector(31 downto 0) := (others => '0');
46 2 rhoads
begin  --architecture
47 139 rhoads
   --Uncomment the line below to test interrupts
48
   interrupt <= '1' after 20 us when interrupt = '0' else '0' after 445 ns;
49
 
50
   clk   <= not clk after 50 ns;
51 48 rhoads
   reset <= '0' after 500 ns;
52 346 rhoads
   pause1 <= '1' after 700 ns when pause1 = '0' else '0' after 200 ns;
53
   pause2 <= '1' after 300 ns when pause2 = '0' else '0' after 200 ns;
54
   pause <= pause1 or pause2;
55
   gpioA_in(20) <= not gpioA_in(20) after 200 ns; --E_RX_CLK
56
   gpioA_in(19) <= not gpioA_in(19) after 20 us;  --E_RX_DV
57
   gpioA_in(18 downto 15) <= gpioA_in(18 downto 15) + 1 after 400 ns; --E_RX_RXD
58
   gpioA_in(14) <= not gpioA_in(14) after 200 ns; --E_TX_CLK
59 2 rhoads
 
60 139 rhoads
   u1_plasma: plasma
61 48 rhoads
      generic map (memory_type => memory_type,
62 346 rhoads
                   ethernet    => '1',
63
                   use_cache   => '1',
64 48 rhoads
                   log_file    => log_file)
65 47 rhoads
      PORT MAP (
66 139 rhoads
         clk               => clk,
67
         reset             => reset,
68
         uart_read         => uart_write,
69
         uart_write        => uart_write,
70 47 rhoads
 
71 346 rhoads
         address           => address,
72
         byte_we           => byte_we,
73
         data_write        => data_write,
74 139 rhoads
         data_read         => data_read,
75 346 rhoads
         mem_pause_in      => pause,
76
         no_ddr_start      => no_ddr_start,
77
         no_ddr_stop       => no_ddr_stop,
78 139 rhoads
 
79
         gpio0_out         => open,
80 346 rhoads
         gpioA_in          => gpioA_in);
81 2 rhoads
 
82 346 rhoads
   dram_proc: process(clk, address, byte_we, data_write, pause)
83
      constant ADDRESS_WIDTH : natural := 16;
84
      type storage_array is
85
         array(natural range 0 to (2 ** ADDRESS_WIDTH) / 4 - 1) of
86
         std_logic_vector(31 downto 0);
87
      variable storage : storage_array;
88
      variable data    : std_logic_vector(31 downto 0);
89
      variable index   : natural := 0;
90
   begin
91
      index := conv_integer(address(ADDRESS_WIDTH-1 downto 2));
92
      data := storage(index);
93
 
94
      if byte_we(0) = '1' then
95
         data(7 downto 0) := data_write(7 downto 0);
96
      end if;
97
      if byte_we(1) = '1' then
98
         data(15 downto 8) := data_write(15 downto 8);
99
      end if;
100
      if byte_we(2) = '1' then
101
         data(23 downto 16) := data_write(23 downto 16);
102
      end if;
103
      if byte_we(3) = '1' then
104
         data(31 downto 24) := data_write(31 downto 24);
105
      end if;
106
 
107
      if rising_edge(clk) then
108
         if address(30 downto 28) = "001" and byte_we /= "0000" then
109
            storage(index) := data;
110
         end if;
111
      end if;
112
 
113
      if pause = '0' then
114
         data_read <= data;
115
      end if;
116
   end process;
117
 
118
 
119 2 rhoads
end; --architecture logic

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.