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

Subversion Repositories opencpu32

[/] [opencpu32/] [trunk/] [hdl/] [opencpu32/] [ControlUnit.vhd] - Diff between revs 29 and 30

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

Rev 29 Rev 30
Line 18... Line 18...
--! The purpose of datapaths is to provide routes for data to travel between functional units.
--! The purpose of datapaths is to provide routes for data to travel between functional units.
entity ControlUnit is
entity ControlUnit is
    generic (n : integer := nBits - 1);                                                                 --! Generic value (Used to easily change the size of the Alu on the package)
    generic (n : integer := nBits - 1);                                                                 --! Generic value (Used to easily change the size of the Alu on the package)
         Port ( reset : in  STD_LOGIC;
         Port ( reset : in  STD_LOGIC;
           clk : in  STD_LOGIC;                                                                                         --! Main system clock
           clk : in  STD_LOGIC;                                                                                         --! Main system clock
           FlagsDp : in  STD_LOGIC_VECTOR (n downto 0);                          --! Flags comming from the Datapath
           FlagsDp : in  STD_LOGIC_VECTOR (2 downto 0);                          --! Flags comming from the Datapath
           DataDp : in  STD_LOGIC_VECTOR (n downto 0);                           --! Data comming from the Datapath
           DataDp : in  STD_LOGIC_VECTOR (n downto 0);                           --! Data comming from the Datapath
           MuxDp : out  STD_LOGIC_VECTOR (2 downto 0);                           --! Select on datapath data from (Memory, Imediate, RegFileA, RegFileB, AluOut)
           MuxDp : out  STD_LOGIC_VECTOR (2 downto 0);                           --! Select on datapath data from (Memory, Imediate, RegFileA, RegFileB, AluOut)
                          MuxRegDp : out STD_LOGIC_VECTOR(1 downto 0);                           --! Select Alu InputA (Memory,Imediate,RegFileA)
                          MuxRegDp : out STD_LOGIC_VECTOR(1 downto 0);                           --! Select Alu InputA (Memory,Imediate,RegFileA)
           ImmDp : out  STD_LOGIC_VECTOR (n downto 0);                           --! Imediate value passed to the Datapath
           ImmDp : out  STD_LOGIC_VECTOR (n downto 0);                           --! Imediate value passed to the Datapath
           DpAluOp : out  aluOps;                                                                                       --! Alu operations
           DpAluOp : out  aluOps;                                                                                       --! Alu operations
Line 33... Line 33...
           DpRegFileReadEnA : out  STD_LOGIC;                                                   --! Enable register read (PortA)
           DpRegFileReadEnA : out  STD_LOGIC;                                                   --! Enable register read (PortA)
           DpRegFileReadEnB : out  STD_LOGIC;                                                   --! Enable register read (PortB)
           DpRegFileReadEnB : out  STD_LOGIC;                                                   --! Enable register read (PortB)
           MemoryDataReadEn : out std_logic;                                                            --! Enable Main memory read
           MemoryDataReadEn : out std_logic;                                                            --! Enable Main memory read
                          MemoryDataWriteEn: out std_logic;                                                             --! Enable Main memory write
                          MemoryDataWriteEn: out std_logic;                                                             --! Enable Main memory write
                          MemoryDataInput : in  STD_LOGIC_VECTOR (n downto 0);   --! Incoming data from main memory
                          MemoryDataInput : in  STD_LOGIC_VECTOR (n downto 0);   --! Incoming data from main memory
           MemoryDataAddr : out  STD_LOGIC_VECTOR (n downto 0);  --! Main memory write address
           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
           MemoryDataOut : out  STD_LOGIC_VECTOR (n downto 0));  --! Data to write on main memory
end ControlUnit;
end ControlUnit;
 
 
--! @brief ControlUnit http://en.wikipedia.org/wiki/Control_unit
--! @brief ControlUnit http://en.wikipedia.org/wiki/Control_unit
--! @details The control unit receives external instructions or commands which it converts into a sequence of control signals that the control \n
--! @details The control unit receives external instructions or commands which it converts into a sequence of control signals that the control \n
Line 89... Line 90...
                        -- Initial state left from reset ...
                        -- Initial state left from reset ...
                        when initial =>
                        when initial =>
                                cyclesExecute := 0;
                                cyclesExecute := 0;
                                PC <= (others => '0');
                                PC <= (others => '0');
                                IR <= (others => '0');
                                IR <= (others => '0');
                                MemoryDataAddr <= (others => '0');
                                MemoryDataRdAddr <= (others => '0');
                                MemoryDataReadEn <= '0';
                                MemoryDataReadEn <= '0';
                                MemoryDataWriteEn <= '0';
                                MemoryDataWriteEn <= '0';
                                MemoryDataAddr <= (others => '0');
 
                                nextCpuState <= fetch;
                                nextCpuState <= fetch;
 
 
                        -- Fetch state (Go to memory and get a instruction)
                        -- Fetch state (Go to memory and get a instruction)
                        when fetch =>
                        when fetch =>
                                -- Increment program counter (Remember that PC will be update only on the next cycle...
                                -- Increment program counter (Remember that PC will be update only on the next cycle...
                                PC <= PC + conv_std_logic_vector(1, nBits);
                                PC <= PC + conv_std_logic_vector(1, nBits);
                                MemoryDataAddr <= PC;   -- Warning PC is not 1 yet...
                                MemoryDataRdAddr <= PC; -- Warning PC is not 1 yet...
                                IR <= MemoryDataInput;
                                IR <= MemoryDataInput;
                                MemoryDataReadEn <= '1';
                                MemoryDataReadEn <= '1';
                                nextCpuState <= decode;
                                nextCpuState <= decode;
 
 
                        -- Detect with instruction came from memory, set the number of cycles to execute...
                        -- Detect with instruction came from memory, set the number of cycles to execute...

powered by: WebSVN 2.1.0

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