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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [VHDL/] [pipeline/] [pipeline_controller-rofsm.vhdl] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 lcdsgmtr
-- Copyright 2015, Jürgen Defurne
2
--
3
-- This file is part of the Experimental Unstable CPU System.
4
--
5
-- The Experimental Unstable CPU System Is free software: you can redistribute
6
-- it and/or modify it under the terms of the GNU Lesser General Public License
7
-- as published by the Free Software Foundation, either version 3 of the
8
-- License, or (at your option) any later version.
9
--
10
-- The Experimental Unstable CPU System is distributed in the hope that it will
11
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
13
-- General Public License for more details.
14
--
15
-- You should have received a copy of the GNU Lesser General Public License
16
-- along with Experimental Unstable CPU System. If not, see
17
-- http://www.gnu.org/licenses/lgpl.txt.
18
 
19
 
20
ARCHITECTURE rofsm OF pipeline_controller IS
21
 
22
  TYPE pl_state IS (S0, S1, S2, S3, S4);
23
 
24
  SIGNAL R_EN  : STD_LOGIC_VECTOR(2 DOWNTO 0);
25
  SIGNAL R_SUM : STD_LOGIC;
26
 
27
  SIGNAL R_FULL : STD_LOGIC;
28
 
29
  SIGNAL next_state   : pl_state := S0;
30
  SIGNAL pl_state_reg : pl_state := S0;
31
 
32
 
33
BEGIN  -- ARCHITECTURE rofsm
34
 
35
-- purpose: compute next state from current state
36
  -- type   : combinational
37
  -- inputs : pl_state_reg
38
  -- outputs: next_state
39
  next_state_logic : PROCESS (pl_state_reg, PULL) IS
40
  BEGIN  -- PROCESS next_state_logic
41
    CASE pl_state_reg IS
42
      WHEN S0 =>
43
        next_state <= S1;
44
      WHEN S1 =>
45
        next_state <= S2;
46
      WHEN S2 =>
47
        next_state <= S3;
48
      WHEN S3 =>
49
        next_state <= S4;
50
      WHEN S4 =>
51
        next_state <= S4;
52
    END CASE;
53
  END PROCESS next_state_logic;
54
 
55
  -- purpose: State register
56
  -- type   : sequential
57
  -- inputs : CLK, RST, next_state
58
  -- outputs: pl_state_reg
59
  state_register : PROCESS (CLK, RST) IS
60
  BEGIN  -- PROCESS state_register
61
    IF rising_edge(CLK) THEN            -- rising clock edge
62
      IF RST = '1' THEN
63
        pl_state_reg <= S0;
64
      ELSE
65
        pl_state_reg <= next_state;
66
      END IF;
67
    END IF;
68
  END PROCESS state_register;
69
 
70
  -- purpose: compute outputs based on state
71
  -- type   : combinational
72
  -- inputs : pl_state_reg
73
  -- outputs: EN(0),EN(1),EN(2)
74
  output_logic : PROCESS (next_state, PULL) IS
75
  BEGIN  -- PROCESS output_logic
76
    CASE next_state IS
77
      WHEN S0 =>
78
        R_SUM   <= '0';
79
        R_EN(0) <= '0';
80
        R_EN(1) <= '0';
81
        R_EN(2) <= '0';
82
        R_FULL  <= '0';
83
      WHEN S1 =>
84
        R_SUM   <= '0';
85
        R_EN(0) <= '1';
86
        R_EN(1) <= '0';
87
        R_EN(2) <= '0';
88
        R_FULL  <= '0';
89
      WHEN S2 =>
90
        R_SUM   <= '1';
91
        R_EN(0) <= '1';
92
        R_EN(1) <= '1';
93
        R_EN(2) <= '0';
94
        R_FULL  <= '0';
95
      WHEN S3 =>
96
        R_SUM   <= '1';
97
        R_EN(0) <= '1';
98
        R_EN(1) <= '1';
99
        R_EN(2) <= '1';
100
        R_FULL  <= '0';
101
      WHEN S4 =>
102
        IF PULL = '1' THEN
103
          R_SUM   <= '1';
104
          R_EN(0) <= '1';
105
          R_EN(1) <= '1';
106
          R_EN(2) <= '1';
107
          R_FULL  <= '1';
108
        ELSE
109
          R_SUM   <= '0';
110
          R_EN(0) <= '0';
111
          R_EN(1) <= '0';
112
          R_EN(2) <= '0';
113
          R_FULL  <= '1';
114
        END IF;
115
    END CASE;
116
  END PROCESS output_logic;
117
 
118
  output_registers : PROCESS (CLK, RST) IS
119
  BEGIN
120
    IF rising_edge(CLK) THEN
121
      IF RST = '1' THEN
122
        SUM   <= '0';
123
        EN(0) <= '0';
124
        EN(1) <= '0';
125
        EN(2) <= '0';
126
        FULL  <= '0';
127
      ELSE
128
        SUM   <= R_SUM;
129
        EN(0) <= R_EN(0);
130
        EN(1) <= R_EN(1);
131
        EN(2) <= R_EN(2);
132
        FULL  <= R_FULL;
133
      END IF;
134
    END IF;
135
  END PROCESS output_registers;
136
 
137
END ARCHITECTURE rofsm;

powered by: WebSVN 2.1.0

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