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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [VHDL/] [pipeline/] [pipeline_controller-moore.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 moore OF pipeline_controller IS
21
 
22
  TYPE pl_state IS (S0, S1, S2, S3, S4, S5);
23
 
24
  SIGNAL next_state   : pl_state := S0;
25
  SIGNAL pl_state_reg : pl_state := S0;
26
 
27
BEGIN  -- ARCHITECTURE moore
28
 
29
-- purpose: compute next state from current state
30
  -- type   : combinational
31
  -- inputs : pl_state_reg
32
  -- outputs: next_state
33
  next_state_logic : PROCESS (pl_state_reg, PULL) IS
34
  BEGIN  -- PROCESS next_state_logic
35
    CASE pl_state_reg IS
36
      WHEN S0 =>
37
        next_state <= S1;
38
      WHEN S1 =>
39
        next_state <= S2;
40
      WHEN S2 =>
41
        next_state <= S3;
42
      WHEN S3 =>
43
        next_state <= S4;
44
      WHEN S4 =>
45
        IF PULL = '0' THEN
46
          next_state <= S4;
47
        ELSE
48
          next_state <= S5;
49
        END IF;
50
      WHEN S5 =>
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 (pl_state_reg) IS
75
  BEGIN  -- PROCESS output_logic
76
    CASE pl_state_reg IS
77
      WHEN S0 =>                        -- Reset state
78
        SUM   <= '0';
79
        EN(0) <= '0';
80
        EN(1) <= '0';
81
        EN(2) <= '0';
82
        FULL  <= '0';
83
      WHEN S1 =>  -- Load first register with initial value
84
        SUM   <= '0';
85
        EN(0) <= '1';
86
        EN(1) <= '0';
87
        EN(2) <= '0';
88
        FULL  <= '0';
89
      WHEN S2 =>  -- Start increment and fill second stage
90
        SUM   <= '1';
91
        EN(0) <= '1';
92
        EN(1) <= '1';
93
        EN(2) <= '0';
94
        FULL  <= '0';
95
      WHEN S3 =>                        -- Fill last stage
96
        SUM   <= '1';
97
        EN(0) <= '1';
98
        EN(1) <= '1';
99
        EN(2) <= '1';
100
        FULL  <= '0';
101
      WHEN S4 =>                        -- Pipeline full
102
        SUM   <= '0';
103
        EN(0) <= '0';
104
        EN(1) <= '0';
105
        EN(2) <= '0';
106
        FULL  <= '1';
107
      WHEN S5 =>                        -- Execute pull request
108
        SUM   <= '1';
109
        EN(0) <= '1';
110
        EN(1) <= '1';
111
        EN(2) <= '1';
112
        FULL  <= '1';
113
    END CASE;
114
  END PROCESS output_logic;
115
 
116
END ARCHITECTURE moore;

powered by: WebSVN 2.1.0

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