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

Subversion Repositories plasma

[/] [plasma/] [trunk/] [vhdl/] [mlite_cpu.vhd] - Diff between revs 194 and 202

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

Rev 194 Rev 202
Line 15... Line 15...
-- Executes all MIPS I(tm) opcodes but exceptions and non-aligned
-- Executes all MIPS I(tm) opcodes but exceptions and non-aligned
-- memory accesses.  Based on information found in:
-- memory accesses.  Based on information found in:
--    "MIPS RISC Architecture" by Gerry Kane and Joe Heinrich
--    "MIPS RISC Architecture" by Gerry Kane and Joe Heinrich
--    and "The Designer's Guide to VHDL" by Peter J. Ashenden
--    and "The Designer's Guide to VHDL" by Peter J. Ashenden
--
--
-- The CPU is implemented as a three or four stage pipeline.
-- The CPU is implemented as a two or three stage pipeline.
-- An add instruction would take the following steps (see cpu.gif):
-- An add instruction would take the following steps (see cpu.gif):
-- Stage #1:
-- Stage #0:
--    1.  The "pc_next" entity passes the program counter (PC) to the 
--    1.  The "pc_next" entity passes the program counter (PC) to the 
--        "mem_ctrl" entity which fetches the opcode from memory.
--        "mem_ctrl" entity which fetches the opcode from memory.
-- Stage #2:
-- Stage #1:
--    2.  The memory returns the opcode.
--    2.  The memory returns the opcode.
-- Stage #3:
-- Stage #2:
--    3.  "Mem_ctrl" passes the opcode to the "control" entity.
--    3.  "Mem_ctrl" passes the opcode to the "control" entity.
--    4.  "Control" converts the 32-bit opcode to a 60-bit VLWI opcode
--    4.  "Control" converts the 32-bit opcode to a 60-bit VLWI opcode
--        and sends control signals to the other entities.
--        and sends control signals to the other entities.
--    5.  Based on the rs_index and rt_index control signals, "reg_bank" 
--    5.  Based on the rs_index and rt_index control signals, "reg_bank" 
--        sends the 32-bit reg_source and reg_target to "bus_mux".
--        sends the 32-bit reg_source and reg_target to "bus_mux".
--    6.  Based on the a_source and b_source control signals, "bus_mux"
--    6.  Based on the a_source and b_source control signals, "bus_mux"
--        multiplexes reg_source onto a_bus and reg_target onto b_bus.
--        multiplexes reg_source onto a_bus and reg_target onto b_bus.
-- Stage #4 (part of stage #3 if using three stage pipeline):
-- Stage #3 (part of stage #2 if using two stage pipeline):
--    7.  Based on the alu_func control signals, "alu" adds the values
--    7.  Based on the alu_func control signals, "alu" adds the values
--        from a_bus and b_bus and places the result on c_bus.
--        from a_bus and b_bus and places the result on c_bus.
--    8.  Based on the c_source control signals, "bus_bux" multiplexes
--    8.  Based on the c_source control signals, "bus_bux" multiplexes
--        c_bus onto reg_dest.
--        c_bus onto reg_dest.
--    9.  Based on the rd_index control signal, "reg_bank" saves
--    9.  Based on the rd_index control signal, "reg_bank" saves
--        reg_dest into the correct register.
--        reg_dest into the correct register.
-- Stage #4b:
-- Stage #3b:
--   10.  Read or write memory if needed.
--   10.  Read or write memory if needed.
--
--
-- All signals are active high. 
-- All signals are active high. 
-- Here are the signals for writing a character to address 0xffff
-- Here are the signals for writing a character to address 0xffff
-- when using a three stage pipeline:
-- when using a two stage pipeline:
--
--
-- Program:
-- Program:
-- addr     value  opcode 
-- addr     value  opcode 
-- =============================
-- =============================
--   3c: 00000000  nop
--   3c: 00000000  nop
Line 75... Line 75...
entity mlite_cpu is
entity mlite_cpu is
   generic(memory_type     : string  := "XILINX_16X"; --ALTERA_LPM, or DUAL_PORT_
   generic(memory_type     : string  := "XILINX_16X"; --ALTERA_LPM, or DUAL_PORT_
           mult_type       : string  := "DEFAULT"; --AREA_OPTIMIZED
           mult_type       : string  := "DEFAULT"; --AREA_OPTIMIZED
           shifter_type    : string  := "DEFAULT"; --AREA_OPTIMIZED
           shifter_type    : string  := "DEFAULT"; --AREA_OPTIMIZED
           alu_type        : string  := "DEFAULT"; --AREA_OPTIMIZED
           alu_type        : string  := "DEFAULT"; --AREA_OPTIMIZED
           pipeline_stages : natural := 3); --3 or 4
           pipeline_stages : natural := 2); --2 or 3
   port(clk         : in std_logic;
   port(clk         : in std_logic;
        reset_in    : in std_logic;
        reset_in    : in std_logic;
        intr_in     : in std_logic;
        intr_in     : in std_logic;
 
 
        mem_address : out std_logic_vector(31 downto 0);
        mem_address : out std_logic_vector(31 downto 0);
Line 88... Line 88...
        mem_byte_we : out std_logic_vector(3 downto 0);
        mem_byte_we : out std_logic_vector(3 downto 0);
        mem_pause   : in std_logic);
        mem_pause   : in std_logic);
end; --entity mlite_cpu
end; --entity mlite_cpu
 
 
architecture logic of mlite_cpu is
architecture logic of mlite_cpu is
   --When using a three stage pipeline "sigD <= sig".
   --When using a two stage pipeline "sigD <= sig".
   --When using a four stage pipeline "sigD <= sig when rising_edge(clk)",
   --When using a three stage pipeline "sigD <= sig when rising_edge(clk)",
   --  so sigD is delayed by one clock cycle.
   --  so sigD is delayed by one clock cycle.
   signal opcode         : std_logic_vector(31 downto 0);
   signal opcode         : std_logic_vector(31 downto 0);
   signal rs_index       : std_logic_vector(5 downto 0);
   signal rs_index       : std_logic_vector(5 downto 0);
   signal rt_index       : std_logic_vector(5 downto 0);
   signal rt_index       : std_logic_vector(5 downto 0);
   signal rd_index       : std_logic_vector(5 downto 0);
   signal rd_index       : std_logic_vector(5 downto 0);
Line 287... Line 287...
        b         => b_busD,
        b         => b_busD,
        mult_func => mult_funcD,
        mult_func => mult_funcD,
        c_mult    => c_mult,
        c_mult    => c_mult,
        pause_out => pause_mult);
        pause_out => pause_mult);
 
 
   pipeline3: if pipeline_stages <= 3 generate
   pipeline2: if pipeline_stages <= 2 generate
      a_busD <= a_bus;
      a_busD <= a_bus;
      b_busD <= b_bus;
      b_busD <= b_bus;
      alu_funcD <= alu_func;
      alu_funcD <= alu_func;
      shift_funcD <= shift_func;
      shift_funcD <= shift_func;
      mult_funcD <= mult_func;
      mult_funcD <= mult_func;
      rd_indexD <= rd_index;
      rd_indexD <= rd_index;
      reg_destD <= reg_dest;
      reg_destD <= reg_dest;
      pause_pipeline <= '0';
      pause_pipeline <= '0';
   end generate; --pipeline2
   end generate; --pipeline2
 
 
   pipeline4: if pipeline_stages > 3 generate
   pipeline3: if pipeline_stages > 2 generate
      --When operating in four stage pipeline mode, the following signals
      --When operating in three stage pipeline mode, the following signals
      --are delayed by one clock cycle:  a_bus, b_bus, alu/shift/mult_func,
      --are delayed by one clock cycle:  a_bus, b_bus, alu/shift/mult_func,
      --c_source, and rd_index.
      --c_source, and rd_index.
   u9_pipeline: pipeline port map (
   u9_pipeline: pipeline port map (
        clk            => clk,
        clk            => clk,
        reset          => reset,
        reset          => reset,
Line 331... Line 331...
        c_source       => c_source,
        c_source       => c_source,
        c_bus          => c_bus,
        c_bus          => c_bus,
        pause_any      => pause_any,
        pause_any      => pause_any,
        pause_pipeline => pause_pipeline);
        pause_pipeline => pause_pipeline);
 
 
   end generate; --pipeline4
   end generate; --pipeline3
 
 
end; --architecture logic
end; --architecture logic
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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