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

Subversion Repositories opencpu32

[/] [opencpu32/] [trunk/] [hdl/] [opencpu32/] [testDataPath.vhd] - Blame information for rev 17

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

Line No. Rev Author Line
1 17 leonardoar
--! @file
2
--! @brief Testbench for Alu
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 testDataPath IS
14
END testDataPath;
15
 
16
--! @brief Alu Testbench file
17
--! @details Exercise each Alu operation to verify if the description work as planned 
18
--! for more information: http://vhdlguru.blogspot.com/2010/03/how-to-write-testbench.html
19
ARCHITECTURE behavior OF testDataPath IS
20
 
21
         --! Component declaration to instantiate the Alu circuit
22
    COMPONENT DataPath
23
    generic (n : integer := nBits - 1);                                                                 --! Generic value (Used to easily change the size of the Alu on the package)
24
         Port ( inputMm : in  STD_LOGIC_VECTOR (n downto 0);                     --! Input of Datapath from main memory       
25
                          inputImm : in  STD_LOGIC_VECTOR (n downto 0);                  --! Input of Datapath from imediate value (instructions...)
26
                          clk : in  STD_LOGIC;                                                                                          --! Clock signal
27
           outEn : in  typeEnDis;                                                                                       --! Enable/Disable datapath output
28
           aluOp : in  aluOps;                                                                                          --! Alu operations
29
           muxSel : in  STD_LOGIC_VECTOR (2 downto 0);                           --! Select inputs from dataPath(Memory,Imediate,RegisterFile,Alu)
30
           regFileWriteAddr : in  generalRegisters;                                     --! General register write address
31
           regFileWriteEn : in  STD_LOGIC;                                                              --! RegisterFile write enable signal
32
           regFileReadAddrA : in  generalRegisters;                                     --! General register read address (PortA)
33
           regFileReadAddrB : in  generalRegisters;                                     --! General register read address (PortB)
34
           regFileEnA : in  STD_LOGIC;                                                                          --! Enable RegisterFile PortA
35
           regFileEnB : in  STD_LOGIC;                                                                          --! Enable RegisterFile PortB
36
                          outputDp : out  STD_LOGIC_VECTOR (n downto 0);                 --! DataPath Output
37
           dpFlags : out  STD_LOGIC_VECTOR (n downto 0));                        --! Alu Flags
38
    END COMPONENT;
39
 
40
 
41
   --Inputs
42
   signal inputMm : std_logic_vector(31 downto 0) := (others => '0');     --! Wire to connect Test signal to component
43
   signal inputImm : std_logic_vector(31 downto 0) := (others => '0');    --! Wire to connect Test signal to component
44
   signal clk : std_logic := '0';                                                                                                        --! Wire to connect Test signal to component
45
   signal outEn : std_logic := '0';                                                                                                      --! Wire to connect Test signal to component
46
   signal aluOp : std_logic := '0';                                                                                                      --! Wire to connect Test signal to component
47
   signal muxSel : std_logic_vector(2 downto 0) := (others => '0');               --! Wire to connect Test signal to component
48
   signal regFileWriteAddr : std_logic := '0';                                                                   --! Wire to connect Test signal to component
49
   signal regFileWriteEn : std_logic := '0';                                                                             --! Wire to connect Test signal to component
50
   signal regFileReadAddrA : std_logic := '0';                                                                   --! Wire to connect Test signal to component
51
   signal regFileReadAddrB : std_logic := '0';                                                                   --! Wire to connect Test signal to component
52
   signal regFileEnA : std_logic := '0';                                                                                 --! Wire to connect Test signal to component
53
   signal regFileEnB : std_logic := '0';                                                                                 --! Wire to connect Test signal to component
54
 
55
        --Outputs
56
   signal outputDp : std_logic_vector(31 downto 0);                                                      --! Wire to connect Test signal to component
57
   signal dpFlags : std_logic_vector(31 downto 0);                                                               --! Wire to connect Test signal to component
58
 
59
 
60
BEGIN
61
 
62
        --! Instantiate the Unit Under Test (Alu) (Doxygen bug if it's not commented!)
63
   uut: DataPath PORT MAP (
64
          inputMm => inputMm,
65
          inputImm => inputImm,
66
          clk => clk,
67
          outEn => outEn,
68
          aluOp => aluOp,
69
          muxSel => muxSel,
70
          regFileWriteAddr => regFileWriteAddr,
71
          regFileWriteEn => regFileWriteEn,
72
          regFileReadAddrA => regFileReadAddrA,
73
          regFileReadAddrB => regFileReadAddrB,
74
          regFileEnA => regFileEnA,
75
          regFileEnB => regFileEnB,
76
          outputDp => outputDp,
77
          dpFlags => dpFlags
78
        );
79
 
80
   -- Stimulus process
81
   stim_proc: process
82
   begin
83
 
84
 
85
      -- insert stimulus here 
86
 
87
      wait;
88
   end process;
89
 
90
END;

powered by: WebSVN 2.1.0

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