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

Subversion Repositories opencpu32

[/] [opencpu32/] [trunk/] [hdl/] [opencpu32/] [testOpenCpu.vhd] - Blame information for rev 37

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

Line No. Rev Author Line
1 36 leonardoar
--! @file
2
--! @brief Testbench for OpenCpu top design
3
 
4
--! Use standard library and import the packages (std_logic_1164,std_logic_unsigned,std_logic_arith)
5
LIBRARY ieee;
6
use ieee.std_logic_1164.all;
7
use ieee.std_logic_unsigned.all;
8
use ieee.std_logic_arith.all;
9
 
10
--! Use CPU Definitions package
11
use work.pkgOpenCPU32.all;
12
 
13 37 leonardoar
--! Adding library for File I/O 
14
-- More information on this site:
15
-- http://eesun.free.fr/DOC/vhdlref/refguide/language_overview/test_benches/reading_and_writing_files_with_text_i_o.htm
16 36 leonardoar
use std.textio.ALL;
17
use ieee.std_logic_textio.all;
18
 
19
ENTITY testOpenCpu IS
20 37 leonardoar
generic (n : integer := nBits - 1);                                                                                     --! Generic value (Used to easily change the size of the Alu on the package)
21 36 leonardoar
END testOpenCpu;
22
 
23
--! @brief openCpu Testbench file
24
--! @details This is the top-level test...
25
ARCHITECTURE behavior OF testOpenCpu IS
26
 
27
    --! Component declaration to instantiate the Multiplexer circuit                    
28
    COMPONENT openCpu
29 37 leonardoar
    generic (n : integer := nBits - 1);                                                                 --! Generic value (Used to easily change the size of the Alu on the package)
30
         Port ( rst : in  STD_LOGIC;                                                                                            --! Reset signal
31
           clk : in  STD_LOGIC;                                                                                         --! Clock signal
32
           mem_rd : out  STD_LOGIC;                                                                                     --! Main memory Read enable
33
           mem_rd_addr : out  STD_LOGIC_VECTOR (n downto 0);             --! Main memory Read address
34
           mem_wr : out  STD_LOGIC;                                                                                     --! Main memory Write enable
35
           mem_wr_addr : out  STD_LOGIC_VECTOR (n downto 0);             --! Main memory Write address
36
                          mem_data_in : in  STD_LOGIC_VECTOR (n downto 0);                       --! Data comming from main memory
37
                          mem_data_out : out  STD_LOGIC_VECTOR (n downto 0)              --! Data to main memory
38
                          );
39 36 leonardoar
    END COMPONENT;
40
 
41
 
42
   --Inputs
43 37 leonardoar
   signal rst : std_logic := '0';                                                                                                                --! Wire to connect Test signal to component
44
   signal clk : std_logic := '0';                                                                                                                --! Wire to connect Test signal to component
45
   signal mem_data_in : std_logic_vector(n downto 0) := (others => '0');  --! Wire to connect Test signal to component
46 36 leonardoar
 
47
        --Outputs
48 37 leonardoar
   signal mem_rd : std_logic;                                                                                                                           --! Wire to connect Test signal to component
49
   signal mem_rd_addr : std_logic_vector(n downto 0);                                                            --! Wire to connect Test signal to component
50
   signal mem_wr : std_logic;                                                                                                                           --! Wire to connect Test signal to component
51
   signal mem_wr_addr : std_logic_vector(n downto 0);                                                            --! Wire to connect Test signal to component
52
   signal mem_data_out : std_logic_vector(n downto 0);                                                   --! Wire to connect Test signal to component
53 36 leonardoar
 
54
   -- Clock period definitions
55
   constant clk_period : time := 10 ns;
56
 
57
BEGIN
58
 
59 37 leonardoar
        --! Instantiate the Unit Under Test (openCpu) (Doxygen bug if it's not commented!)
60 36 leonardoar
   uut: openCpu PORT MAP (
61
          rst => rst,
62
          clk => clk,
63
          mem_rd => mem_rd,
64
          mem_rd_addr => mem_rd_addr,
65
          mem_wr => mem_wr,
66
          mem_wr_addr => mem_wr_addr,
67
          mem_data_in => mem_data_in,
68
          mem_data_out => mem_data_out
69
        );
70
 
71
   -- Clock process definitions
72
   clk_process :process
73
   begin
74
                clk <= '0';
75
                wait for clk_period/2;
76
                clk <= '1';
77
                wait for clk_period/2;
78
   end process;
79
 
80
 
81
   -- Stimulus process
82
   stim_proc: process
83
   begin
84
      -- Reset operation
85
                REPORT "RESET" SEVERITY NOTE;
86
                rst <= '1';
87
      wait for 2 ns;
88
                rst <= '0';
89
                wait for 2 ns;
90
 
91
      wait for clk_period*10;
92
 
93
      -- insert stimulus here 
94
 
95
      -- Finish simulation
96
                assert false report "NONE. End of simulation." severity failure;
97
                wait;
98
   end process;
99
 
100
END;

powered by: WebSVN 2.1.0

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