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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [VHDL/] [registers/] [control.vhdl] - Blame information for rev 39

Go to most recent revision | 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
LIBRARY ieee;
21
USE ieee.std_logic_1164.ALL;
22
 
23
ENTITY uctrl IS
24
 
25
  PORT (
26
    CLK    : IN  STD_LOGIC;
27
    RST    : IN  STD_LOGIC;
28
    RF_SEL : OUT STD_LOGIC_VECTOR(1 DOWNTO 0);
29
    A1     : OUT STD_LOGIC_VECTOR(1 DOWNTO 0);
30
    A2     : OUT STD_LOGIC_VECTOR(1 DOWNTO 0);
31
    LO_EN  : OUT STD_LOGIC;
32
    RO_EN  : OUT STD_LOGIC;
33
    OPCODE : OUT STD_LOGIC_VECTOR(1 DOWNTO 0);
34
    WR     : OUT STD_LOGIC);
35
 
36
END ENTITY uctrl;
37
 
38
ARCHITECTURE Mealy OF uctrl IS
39
 
40
  TYPE state IS (S0, S1, S2, S3, S4, S5, S6, S7, S8, S9);
41
 
42
  SIGNAL CURR_STATE : state;
43
  SIGNAL NEXT_STATE : state;
44
 
45
BEGIN  -- ARCHITECTURE Mealy
46
 
47
  -- Next state logic
48
  PROCESS (CURR_STATE)
49
  BEGIN
50
    CASE CURR_STATE IS
51
      WHEN S0 =>
52
        NEXT_STATE <= S1;
53
      WHEN S1 =>
54
        NEXT_STATE <= S2;
55
      WHEN S2 =>
56
        NEXT_STATE <= S3;
57
      WHEN S3 =>
58
        NEXT_STATE <= S4;
59
      WHEN S4 =>
60
        NEXT_STATE <= S5;
61
      WHEN S5 =>
62
        NEXT_STATE <= S6;
63
      WHEN S6 =>
64
        NEXT_STATE <= S7;
65
      WHEN S7 =>
66
        NEXT_STATE <= S8;
67
      WHEN S8 =>
68
        NEXT_STATE <= S9;
69
      WHEN S9 =>
70
        NEXT_STATE <= S9;
71
    END CASE;
72
  END PROCESS;
73
 
74
  -- State logic
75
  PROCESS (CLK, RST)
76
  BEGIN
77
    IF rising_edge(CLK) THEN
78
      IF RST = '0' THEN
79
        CURR_STATE <= NEXT_STATE;
80
      ELSE
81
        CURR_STATE <= S0;
82
      END IF;
83
    END IF;
84
  END PROCESS;
85
 
86
  -- Output logic
87
  PROCESS (CURR_STATE)
88
  BEGIN
89
    RF_SEL <= "00";
90
 
91
    CASE CURR_STATE IS
92
      WHEN S0 =>
93
        A1     <= "00";
94
        A2     <= "00";
95
        LO_EN  <= '0';
96
        RO_EN  <= '0';
97
        OPCODE <= "00";
98
        WR     <= '0';
99
      WHEN S1 =>
100
        A1     <= "00"; -- LD REG 0 with 0
101
        A2     <= "00";
102
        LO_EN  <= '0';
103
        RO_EN  <= '0';
104
        OPCODE <= "00";
105
        WR     <= '1';
106
      WHEN S2 =>
107
        A1     <= "01"; -- LD REG 1 with 0
108
        A2     <= "00";
109
        LO_EN  <= '0';
110
        RO_EN  <= '0';
111
        OPCODE <= "00";
112
        WR     <= '1';
113
      WHEN S3 =>
114
        A1     <= "00";
115
        A2     <= "00";
116
        LO_EN  <= '1'; -- LD Left op with REG 0
117
        RO_EN  <= '0';
118
        OPCODE <= "00";
119
        WR     <= '0';
120
      WHEN S4 =>
121
        A1     <= "00"; -- Store result in REG 0
122
        A2     <= "00";
123
        LO_EN  <= '0';
124
        RO_EN  <= '0';
125
        OPCODE <= "10";
126
        WR     <= '1';
127
      WHEN S5 =>
128
        A1     <= "01";
129
        A2     <= "00";
130
        LO_EN  <= '1'; -- LD Left op with REG 1
131
        RO_EN  <= '0';
132
        OPCODE <= "00";
133
        WR     <= '0';
134
      WHEN S6 =>
135
        A1     <= "01"; -- Store result in REG 1
136
        A2     <= "00";
137
        LO_EN  <= '0';
138
        RO_EN  <= '0';
139
        OPCODE <= "10";
140
        WR     <= '1';
141
      WHEN S7 =>
142
        A1     <= "00";
143
        A2     <= "01";
144
        LO_EN  <= '1';
145
        RO_EN  <= '1';
146
        OPCODE <= "00";
147
        WR     <= '0';
148
      WHEN S8 =>
149
        A1     <= "00";
150
        A2     <= "00";
151
        LO_EN  <= '0';
152
        RO_EN  <= '0';
153
        OPCODE <= "01";
154
        WR     <= '1';
155
      WHEN S9 =>
156
        A1     <= "00";
157
        A2     <= "00";
158
        LO_EN  <= '0';
159
        RO_EN  <= '0';
160
        OPCODE <= "00";
161
        WR     <= '0';
162
    END CASE;
163
  END PROCESS;
164
 
165
END ARCHITECTURE Mealy;

powered by: WebSVN 2.1.0

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