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

Subversion Repositories opencpu32

[/] [opencpu32/] [trunk/] [hdl/] [opencpu32/] [testControlUnit.vhd] - Diff between revs 22 and 32

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 22 Rev 32
Line 9... Line 9...
 
 
--! Use CPU Definitions package
--! Use CPU Definitions package
use work.pkgOpenCPU32.all;
use work.pkgOpenCPU32.all;
 
 
ENTITY testControlUnit IS
ENTITY testControlUnit IS
 
generic (n : integer := nBits - 1);                                                                     --! Generic value (Used to easily change the size of the Alu on the package)
END testControlUnit;
END testControlUnit;
 
 
--! @brief ControlUnit Testbench file
--! @brief ControlUnit Testbench file
--! @details Exercise the control unit with a assembly program sample
--! @details Exercise the control unit with a assembly program sample
--! for more information: http://vhdlguru.blogspot.com/2010/03/how-to-write-testbench.html
--! for more information: http://vhdlguru.blogspot.com/2010/03/how-to-write-testbench.html
ARCHITECTURE behavior OF testControlUnit IS
ARCHITECTURE behavior OF testControlUnit IS
 
 
    -- Component Declaration for the Unit Under Test (UUT)
    -- Component Declaration for the Unit Under Test (UUT)
 
 
    COMPONENT ControlUnit
    COMPONENT ControlUnit
    PORT(
    generic (n : integer := nBits - 1);                                                                 --! Generic value (Used to easily change the size of the Alu on the package)
         reset : IN  std_logic;
         Port ( reset : in  STD_LOGIC;
         clk : IN  std_logic;
           clk : in  STD_LOGIC;                                                                                         --! Main system clock
         FlagsDp : IN  std_logic_vector(7 downto 0);
           FlagsDp : in  STD_LOGIC_VECTOR (2 downto 0);                          --! Flags comming from the Datapath
         DataDp : IN  std_logic_vector(7 downto 0);
           DataDp : in  STD_LOGIC_VECTOR (n downto 0);                           --! Data comming from the Datapath
         MuxDp : OUT  std_logic_vector(2 downto 0);
                          outEnDp : out  typeEnDis;                                                                             --! Enable/Disable datapath output
         ImmDp : OUT  std_logic_vector(7 downto 0);
           MuxDp : out  STD_LOGIC_VECTOR (2 downto 0);                           --! Select on datapath data from (Memory, Imediate, RegFileA, RegFileB, AluOut)
         DpRegFileWriteAddr : OUT  std_logic;
                          MuxRegDp : out STD_LOGIC_VECTOR(1 downto 0);                           --! Select Alu InputA (Memory,Imediate,RegFileA)
         DpRegFileWriteEn : OUT  std_logic;
           ImmDp : out  STD_LOGIC_VECTOR (n downto 0);                           --! Imediate value passed to the Datapath
         DpRegFileReadAddrA : OUT  std_logic;
           DpAluOp : out  aluOps;                                                                                       --! Alu operations
         DpRegFileReadAddrB : OUT  std_logic;
                          DpRegFileWriteAddr : out  generalRegisters;                           --! General register address to write
         DpRegFileReadEnA : OUT  std_logic;
           DpRegFileWriteEn : out  STD_LOGIC;                                                   --! Enable register write
         DpRegFileReadEnB : OUT  std_logic;
           DpRegFileReadAddrA : out  generalRegisters;                          --! General register address to read
         MemoryDataInput : IN  std_logic_vector(7 downto 0);
           DpRegFileReadAddrB : out  generalRegisters;                          --! General register address to read
         MemoryDataAddr : OUT  std_logic_vector(7 downto 0);
           DpRegFileReadEnA : out  STD_LOGIC;                                                   --! Enable register read (PortA)
         MemoryDataOut : OUT  std_logic_vector(7 downto 0)
           DpRegFileReadEnB : out  STD_LOGIC;                                                   --! Enable register read (PortB)
        );
           MemoryDataReadEn : out std_logic;                                                            --! Enable Main memory read
 
                          MemoryDataWriteEn: out std_logic;                                                             --! Enable Main memory write
 
                          MemoryDataInput : in  STD_LOGIC_VECTOR (n downto 0);   --! Incoming data from main memory
 
           MemoryDataRdAddr : out  STD_LOGIC_VECTOR (n downto 0);        --! Main memory Read address
 
                          MemoryDataWrAddr : out  STD_LOGIC_VECTOR (n downto 0); --! Main memory Write address
 
           MemoryDataOut : out  STD_LOGIC_VECTOR (n downto 0));  --! Data to write on main memory
    END COMPONENT;
    END COMPONENT;
 
 
 
 
   --Inputs
   --Inputs
   signal reset : std_logic := '0';                                                                                                                      --! Wire to connect Test signal to component
   signal reset : std_logic := '0';                                                                                                                      --! Wire to connect Test signal to component
   signal clk : std_logic := '0';                                                                                                                        --! Wire to connect Test signal to component
   signal clk : std_logic := '0';                                                                                                                        --! Wire to connect Test signal to component
   signal FlagsDp : std_logic_vector(7 downto 0) := (others => '0');                              --! Wire to connect Test signal to component
   signal FlagsDp : std_logic_vector(2 downto 0) := (others => '0');                              --! Wire to connect Test signal to component
   signal DataDp : std_logic_vector(7 downto 0) := (others => '0');                               --! Wire to connect Test signal to component
   signal DataDp : std_logic_vector(n downto 0) := (others => '0');                               --! Wire to connect Test signal to component
   signal MemoryDataInput : std_logic_vector(7 downto 0) := (others => '0');      --! Wire to connect Test signal to component
   signal MemoryDataInput : std_logic_vector(n downto 0) := (others => '0');      --! Wire to connect Test signal to component
 
 
        --Outputs
        --Outputs
 
   signal outEnDp : typeEnDis;                                                                                                                          --! Wire to connect Test signal to component
   signal MuxDp : std_logic_vector(2 downto 0);                                                                                  --! Wire to connect Test signal to component
   signal MuxDp : std_logic_vector(2 downto 0);                                                                                  --! Wire to connect Test signal to component
   signal ImmDp : std_logic_vector(7 downto 0);                                                                                  --! Wire to connect Test signal to component
        signal MuxRegDp : std_logic_vector(1 downto 0);                                                                          --! Wire to connect Test signal to component
   signal DpRegFileWriteAddr : std_logic;                                                                                                       --! Wire to connect Test signal to component
   signal ImmDp : std_logic_vector(n downto 0);                                                                                  --! Wire to connect Test signal to component
 
        signal DpAluOp : aluOps;                                                                                                                                        --! Wire to connect Test signal to component
 
   signal DpRegFileWriteAddr : generalRegisters;                                                                                --! Wire to connect Test signal to component
   signal DpRegFileWriteEn : std_logic;                                                                                                 --! Wire to connect Test signal to component
   signal DpRegFileWriteEn : std_logic;                                                                                                 --! Wire to connect Test signal to component
   signal DpRegFileReadAddrA : std_logic;                                                                                                       --! Wire to connect Test signal to component
   signal DpRegFileReadAddrA : generalRegisters;                                                                                --! Wire to connect Test signal to component
   signal DpRegFileReadAddrB : std_logic;                                                                                                       --! Wire to connect Test signal to component
   signal DpRegFileReadAddrB : generalRegisters;                                                                                --! Wire to connect Test signal to component
   signal DpRegFileReadEnA : std_logic;                                                                                                 --! Wire to connect Test signal to component
   signal DpRegFileReadEnA : std_logic;                                                                                                 --! Wire to connect Test signal to component
   signal DpRegFileReadEnB : std_logic;                                                                                                 --! Wire to connect Test signal to component
   signal DpRegFileReadEnB : std_logic;                                                                                                 --! Wire to connect Test signal to component
   signal MemoryDataAddr : std_logic_vector(7 downto 0);                                                         --! Wire to connect Test signal to component
        signal MemoryDataReadEn : std_logic;                                                                                                    --! Wire to connect Test signal to component
   signal MemoryDataOut : std_logic_vector(7 downto 0);                                                          --! Wire to connect Test signal to component
        signal MemoryDataWriteEn : std_logic;                                                                                                   --! Wire to connect Test signal to component
 
        signal MemoryDataRdAddr : std_logic_vector(n downto 0);                                                  --! Wire to connect Test signal to component
 
   signal MemoryDataWrAddr : std_logic_vector(n downto 0);                                                       --! Wire to connect Test signal to component
 
   signal MemoryDataOut : std_logic_vector(n downto 0);                                                          --! Wire to connect Test signal to component
 
 
   -- Clock period definitions
   -- Clock period definitions
   constant clk_period : time := 10 ns;
   constant clk_period : time := 10 ns;
 
 
BEGIN
BEGIN
Line 69... Line 81...
   uut: ControlUnit PORT MAP (
   uut: ControlUnit PORT MAP (
          reset => reset,
          reset => reset,
          clk => clk,
          clk => clk,
          FlagsDp => FlagsDp,
          FlagsDp => FlagsDp,
          DataDp => DataDp,
          DataDp => DataDp,
 
                        outEnDp => outEnDp,
          MuxDp => MuxDp,
          MuxDp => MuxDp,
 
                        MuxRegDp => MuxRegDp,
          ImmDp => ImmDp,
          ImmDp => ImmDp,
 
                        DpAluOp => DpAluOp,
          DpRegFileWriteAddr => DpRegFileWriteAddr,
          DpRegFileWriteAddr => DpRegFileWriteAddr,
          DpRegFileWriteEn => DpRegFileWriteEn,
          DpRegFileWriteEn => DpRegFileWriteEn,
          DpRegFileReadAddrA => DpRegFileReadAddrA,
          DpRegFileReadAddrA => DpRegFileReadAddrA,
          DpRegFileReadAddrB => DpRegFileReadAddrB,
          DpRegFileReadAddrB => DpRegFileReadAddrB,
          DpRegFileReadEnA => DpRegFileReadEnA,
          DpRegFileReadEnA => DpRegFileReadEnA,
          DpRegFileReadEnB => DpRegFileReadEnB,
          DpRegFileReadEnB => DpRegFileReadEnB,
 
                        MemoryDataReadEn => MemoryDataReadEn,
 
                        MemoryDataWriteEn => MemoryDataWriteEn,
          MemoryDataInput => MemoryDataInput,
          MemoryDataInput => MemoryDataInput,
          MemoryDataAddr => MemoryDataAddr,
                        MemoryDataRdAddr => MemoryDataRdAddr,
 
                        MemoryDataWrAddr => MemoryDataWrAddr,
          MemoryDataOut => MemoryDataOut
          MemoryDataOut => MemoryDataOut
        );
        );
 
 
   -- Clock process definitions
   -- Clock process definitions
   clk_process :process
   clk_process :process
Line 95... Line 113...
 
 
 
 
   -- Stimulus process
   -- Stimulus process
   stim_proc: process
   stim_proc: process
   begin
   begin
      -- hold reset state for 100 ns.
                -- Reset operation
      wait for 100 ns;
                REPORT "RESET" SEVERITY NOTE;
 
                reset <= '1';
      wait for clk_period*10;
      wait for 2 ns;
 
                reset <= '0';
      -- insert stimulus here 
                wait for 2 ns;
 
 
 
      -- MOV r0,10d ---------------------------------------------------------------------------------
 
                REPORT "MOV r0,10" SEVERITY NOTE;
 
                wait for CLK_period;
 
 
      wait;
      wait;
   end process;
   end process;
 
 
END;
END;

powered by: WebSVN 2.1.0

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