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

Subversion Repositories opencpu32

[/] [opencpu32/] [trunk/] [hdl/] [opencpu32/] [testControlUnit.vhd] - Blame information for rev 27

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

Line No. Rev Author Line
1 22 leonardoar
--! @file
2
--! @brief Testbench for ControlUnit
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
ENTITY testControlUnit IS
14
END testControlUnit;
15
 
16
--! @brief ControlUnit Testbench file
17
--! @details Exercise the control unit with a assembly program sample
18
--! for more information: http://vhdlguru.blogspot.com/2010/03/how-to-write-testbench.html
19
ARCHITECTURE behavior OF testControlUnit IS
20
 
21
    -- Component Declaration for the Unit Under Test (UUT)
22
 
23
    COMPONENT ControlUnit
24
    PORT(
25
         reset : IN  std_logic;
26
         clk : IN  std_logic;
27
         FlagsDp : IN  std_logic_vector(7 downto 0);
28
         DataDp : IN  std_logic_vector(7 downto 0);
29
         MuxDp : OUT  std_logic_vector(2 downto 0);
30
         ImmDp : OUT  std_logic_vector(7 downto 0);
31
         DpRegFileWriteAddr : OUT  std_logic;
32
         DpRegFileWriteEn : OUT  std_logic;
33
         DpRegFileReadAddrA : OUT  std_logic;
34
         DpRegFileReadAddrB : OUT  std_logic;
35
         DpRegFileReadEnA : OUT  std_logic;
36
         DpRegFileReadEnB : OUT  std_logic;
37
         MemoryDataInput : IN  std_logic_vector(7 downto 0);
38
         MemoryDataAddr : OUT  std_logic_vector(7 downto 0);
39
         MemoryDataOut : OUT  std_logic_vector(7 downto 0)
40
        );
41
    END COMPONENT;
42
 
43
 
44
   --Inputs
45
   signal reset : std_logic := '0';                                                                                                                      --! Wire to connect Test signal to component
46
   signal clk : std_logic := '0';                                                                                                                        --! Wire to connect Test signal to component
47
   signal FlagsDp : std_logic_vector(7 downto 0) := (others => '0');                              --! Wire to connect Test signal to component
48
   signal DataDp : std_logic_vector(7 downto 0) := (others => '0');                               --! Wire to connect Test signal to component
49
   signal MemoryDataInput : std_logic_vector(7 downto 0) := (others => '0');      --! Wire to connect Test signal to component
50
 
51
        --Outputs
52
   signal MuxDp : std_logic_vector(2 downto 0);                                                                                  --! Wire to connect Test signal to component
53
   signal ImmDp : std_logic_vector(7 downto 0);                                                                                  --! Wire to connect Test signal to component
54
   signal DpRegFileWriteAddr : std_logic;                                                                                                       --! Wire to connect Test signal to component
55
   signal DpRegFileWriteEn : std_logic;                                                                                                 --! Wire to connect Test signal to component
56
   signal DpRegFileReadAddrA : std_logic;                                                                                                       --! Wire to connect Test signal to component
57
   signal DpRegFileReadAddrB : std_logic;                                                                                                       --! Wire to connect Test signal to component
58
   signal DpRegFileReadEnA : std_logic;                                                                                                 --! Wire to connect Test signal to component
59
   signal DpRegFileReadEnB : std_logic;                                                                                                 --! Wire to connect Test signal to component
60
   signal MemoryDataAddr : std_logic_vector(7 downto 0);                                                         --! Wire to connect Test signal to component
61
   signal MemoryDataOut : std_logic_vector(7 downto 0);                                                          --! Wire to connect Test signal to component
62
 
63
   -- Clock period definitions
64
   constant clk_period : time := 10 ns;
65
 
66
BEGIN
67
 
68
        --! Instantiate the Unit Under Test (ControlUnit)
69
   uut: ControlUnit PORT MAP (
70
          reset => reset,
71
          clk => clk,
72
          FlagsDp => FlagsDp,
73
          DataDp => DataDp,
74
          MuxDp => MuxDp,
75
          ImmDp => ImmDp,
76
          DpRegFileWriteAddr => DpRegFileWriteAddr,
77
          DpRegFileWriteEn => DpRegFileWriteEn,
78
          DpRegFileReadAddrA => DpRegFileReadAddrA,
79
          DpRegFileReadAddrB => DpRegFileReadAddrB,
80
          DpRegFileReadEnA => DpRegFileReadEnA,
81
          DpRegFileReadEnB => DpRegFileReadEnB,
82
          MemoryDataInput => MemoryDataInput,
83
          MemoryDataAddr => MemoryDataAddr,
84
          MemoryDataOut => MemoryDataOut
85
        );
86
 
87
   -- Clock process definitions
88
   clk_process :process
89
   begin
90
                clk <= '0';
91
                wait for clk_period/2;
92
                clk <= '1';
93
                wait for clk_period/2;
94
   end process;
95
 
96
 
97
   -- Stimulus process
98
   stim_proc: process
99
   begin
100
      -- hold reset state for 100 ns.
101
      wait for 100 ns;
102
 
103
      wait for clk_period*10;
104
 
105
      -- insert stimulus here 
106
 
107
      wait;
108
   end process;
109
 
110
END;

powered by: WebSVN 2.1.0

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