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

Subversion Repositories mlite

[/] [mlite/] [trunk/] [vhdl/] [pipeline.vhd] - Blame information for rev 82

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

Line No. Rev Author Line
1 69 rhoads
---------------------------------------------------------------------
2
-- TITLE: Pipeline
3
-- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4
-- DATE CREATED: 6/24/02
5
-- FILENAME: pipeline.vhd
6
-- PROJECT: Plasma CPU core
7
-- COPYRIGHT: Software placed into the public domain by the author.
8
--    Software 'as is' without warranty.  Author liable for nothing.
9
-- DESCRIPTION:
10
--    Controls the three stage pipeline by delaying the signals:
11
--      a_bus, b_bus, alu/shift/mult_func, c_source, and rs_index.
12
---------------------------------------------------------------------
13
library ieee;
14
use ieee.std_logic_1164.all;
15
use work.mlite_pack.all;
16
 
17
--Note: sigD <= sig after rising_edge(clk)
18
entity pipeline is
19
   port(clk            : in  std_logic;
20
        reset          : in  std_logic;
21
        a_bus          : in  std_logic_vector(31 downto 0);
22
        a_busD         : out std_logic_vector(31 downto 0);
23
        b_bus          : in  std_logic_vector(31 downto 0);
24
        b_busD         : out std_logic_vector(31 downto 0);
25
        alu_func       : in  alu_function_type;
26
        alu_funcD      : out alu_function_type;
27
        shift_func     : in  shift_function_type;
28
        shift_funcD    : out shift_function_type;
29
        mult_func      : in  mult_function_type;
30
        mult_funcD     : out mult_function_type;
31
        reg_dest       : in  std_logic_vector(31 downto 0);
32
        reg_destD      : out std_logic_vector(31 downto 0);
33
        rd_index       : in  std_logic_vector(5 downto 0);
34
        rd_indexD      : out std_logic_vector(5 downto 0);
35
 
36
        rs_index       : in  std_logic_vector(5 downto 0);
37
        rt_index       : in  std_logic_vector(5 downto 0);
38
        pc_source      : in  pc_source_type;
39
        mem_source     : in  mem_source_type;
40
        a_source       : in  a_source_type;
41
        b_source       : in  b_source_type;
42
        c_source       : in  c_source_type;
43
        c_bus          : in  std_logic_vector(31 downto 0);
44
        take_branch    : in  std_logic;
45
        take_branchD   : out std_logic;
46
        pause_any      : in  std_logic;
47
        pause_pipeline : out std_logic);
48
end; --entity pipeline
49
 
50
architecture logic of pipeline is
51 82 rhoads
   signal rd_index_reg : std_logic_vector(5 downto 0);
52
   signal reg_dest_reg : std_logic_vector(31 downto 0);
53
   signal c_source_reg : c_source_type;
54
   signal pause_reg    : std_logic;
55 69 rhoads
begin
56
 
57
--When operating in three stage pipeline mode, the following signals
58
--are delayed by one clock cycle:  a_bus, b_bus, alu/shift/mult_func,
59
--c_source, and rd_index.
60
pipeline3: process(clk, reset, a_bus, b_bus, alu_func, shift_func, mult_func,
61
      rd_index, rd_index_reg, pause_any, pause_reg,
62
      take_branch, rs_index, rt_index,
63 82 rhoads
      pc_source, mem_source, a_source, b_source, c_source, c_source_reg,
64
      reg_dest, reg_dest_reg, c_bus)
65 69 rhoads
   variable pause_mult_clock : std_logic;
66
begin
67
   if (pc_source /= from_inc4 and pc_source /= from_opcode25_0) or
68
      mem_source /= mem_fetch or
69
      (mult_func = mult_read_lo or mult_func = mult_read_hi) then
70
      pause_mult_clock := '1';
71
   else
72
      pause_mult_clock := '0';
73
   end if;
74
 
75
   pause_pipeline <= pause_mult_clock and pause_reg;
76
   take_branchD <= take_branch and not pause_any;
77
   rd_indexD <= rd_index_reg;
78
 
79
   if c_source_reg = c_from_alu then
80
      reg_destD <= c_bus;
81
   else
82
      reg_destD <= reg_dest_reg;
83
   end if;
84
 
85
   if rising_edge(clk) then
86
      if (rs_index = "000000" or rs_index /= rd_index_reg) or
87
            (a_source /= a_from_reg_source or pause_reg = '0') then
88
         a_busD <= a_bus;
89
      elsif c_source_reg = c_from_alu then
90
         a_busD <= c_bus;  --rs from previous operation (bypass stage)
91
      else
92
         a_busD <= reg_dest_reg;
93
      end if;
94
 
95
      if (rt_index = "000000" or rt_index /= rd_index_reg) or
96
            (b_source /= b_from_reg_target or pause_reg = '0') then
97
         b_busD <= b_bus;
98
      elsif c_source_reg = c_from_alu then
99
         b_busD <= c_bus;  --rt from previous operation
100
      else
101
         b_busD <= reg_dest_reg;
102
      end if;
103
 
104
      alu_funcD <= alu_func;
105
      shift_funcD <= shift_func;
106
      mult_funcD <= mult_func;
107
      reg_dest_reg <= reg_dest;
108
      c_source_reg <= c_source;
109
   end if;
110
 
111
   if reset = '1' then
112
      pause_reg <= '1';
113
      rd_index_reg <= "000000";
114
   elsif rising_edge(clk) then
115
      if pause_reg = '0' and pause_any = '0' then
116
         pause_reg <= '1';   --enable pause_pipeline
117
      elsif pause_mult_clock = '1' then
118
         pause_reg <= '0';   --disable pause_pipeline
119
      end if;
120
      rd_index_reg <= rd_index;
121
   end if;
122
 
123
end process; --pipeline3
124
 
125
end; --logic

powered by: WebSVN 2.1.0

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