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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [VHDL/] [control/] [ct.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
LIBRARY IEEE;
21
USE IEEE.STD_LOGIC_1164.ALL;
22
USE IEEE.NUMERIC_STD.ALL;
23
 
24
ENTITY ct IS
25
  PORT (reset       : IN  STD_LOGIC;
26
        clock       : IN  STD_LOGIC;
27
        ir_in       : IN  STD_LOGIC_VECTOR (15 DOWNTO 0);
28
        reg_a       : OUT STD_LOGIC_VECTOR (3 DOWNTO 0);
29
        reg_b       : OUT STD_LOGIC_VECTOR (3 DOWNTO 0);
30
        op_sel      : OUT STD_LOGIC_VECTOR (3 DOWNTO 0);
31
        reg_input   : OUT STD_LOGIC_VECTOR (1 DOWNTO 0);
32
        reg_write   : OUT STD_LOGIC;
33
        pc_input    : OUT STD_LOGIC_VECTOR (1 DOWNTO 0);
34
        addr_source : OUT STD_LOGIC;
35
        wr          : OUT STD_LOGIC;
36
        rd          : OUT STD_LOGIC;
37
        zero        : IN  STD_LOGIC;
38
        n_zero      : IN  STD_LOGIC);
39
END ct;
40
 
41
ARCHITECTURE Behavioral OF ct IS
42
 
43
  TYPE ctr_state IS (one, two, three, four, five, six, seven, eight);
44
 
45
  SIGNAL ir : STD_LOGIC_VECTOR(15 DOWNTO 0);
46
 
47
  SIGNAL cr_reg_a       : STD_LOGIC_VECTOR (3 DOWNTO 0);
48
  SIGNAL cr_reg_b       : STD_LOGIC_VECTOR (3 DOWNTO 0);
49
  SIGNAL cr_op_sel      : STD_LOGIC_VECTOR (3 DOWNTO 0);
50
  SIGNAL cr_reg_input   : STD_LOGIC_VECTOR (1 DOWNTO 0);
51
  SIGNAL cr_reg_write   : STD_LOGIC;
52
  SIGNAL cr_pc_input    : STD_LOGIC_VECTOR (1 DOWNTO 0);
53
  SIGNAL cr_addr_source : STD_LOGIC;
54
  SIGNAL cr_wr          : STD_LOGIC;
55
  SIGNAL cr_rd          : STD_LOGIC;
56
  SIGNAL cr_state       : ctr_state;
57
 
58
  SIGNAL nx_reg_a       : STD_LOGIC_VECTOR (3 DOWNTO 0);
59
  SIGNAL nx_reg_b       : STD_LOGIC_VECTOR (3 DOWNTO 0);
60
  SIGNAL nx_op_sel      : STD_LOGIC_VECTOR (3 DOWNTO 0);
61
  SIGNAL nx_reg_input   : STD_LOGIC_VECTOR (1 DOWNTO 0);
62
  SIGNAL nx_reg_write   : STD_LOGIC;
63
  SIGNAL nx_pc_input    : STD_LOGIC_VECTOR (1 DOWNTO 0);
64
  SIGNAL nx_addr_source : STD_LOGIC;
65
  SIGNAL nx_wr          : STD_LOGIC;
66
  SIGNAL nx_rd          : STD_LOGIC;
67
  SIGNAL nx_state       : ctr_state;
68
 
69
BEGIN
70
 
71
  -- purpose: This is the state controller register
72
  -- type   : sequential
73
  -- inputs : clock, reset, zero,n_zero, next_state
74
  -- outputs: cr_reg_a,cr_reg_b,cr_op_sel,cr_reg_input,cr_reg_write,cr_pc_input,cr_addr_source,cr_wr,cr_rd
75
  control_out : PROCESS (clock, reset)
76
  BEGIN  -- PROCESS control_out
77
    IF reset = '0' THEN                 -- asynchronous reset (active low)
78
      cr_reg_a       <= "0000";
79
      cr_reg_b       <= "0000";
80
      cr_op_sel      <= "0000";
81
      cr_reg_input   <= "00";
82
      cr_reg_write   <= '0';
83
      cr_pc_input    <= "00";
84
      cr_addr_source <= '0';
85
      cr_state       <= one;
86
    ELSIF rising_edge(clock) THEN       -- rising clock edge
87
      cr_reg_a       <= nx_reg_a;
88
      cr_reg_b       <= nx_reg_b;
89
      cr_op_sel      <= nx_op_sel;
90
      cr_reg_input   <= nx_reg_input;
91
      cr_reg_write   <= nx_reg_write;
92
      cr_pc_input    <= nx_pc_input;
93
      cr_addr_source <= nx_addr_source;
94
      cr_state       <= nx_state;
95
    END IF;
96
  END PROCESS control_out;
97
 
98
  -- purpose: Compute the next state and outputs from the current state
99
  -- type   : combinational
100
  -- inputs : state, zero, n_zero
101
  -- outputs: nx_reg_a,nx_reg_b,nx_op_sel,nx_reg_input,nx_reg_write,nx_pc_inpue,nx_addr_source,nx_state
102
  next_control : PROCESS (cr_state, zero, n_zero)
103
  BEGIN  -- PROCESS next_control
104
    nx_reg_a       <= "0000";
105
    nx_reg_b       <= "0000";
106
    nx_op_sel      <= "0000";
107
    nx_reg_input   <= "00";
108
    nx_reg_write   <= '0';
109
    nx_pc_input    <= "00";
110
    nx_addr_source <= '0';
111
    nx_state       <= one;
112
 
113
    CASE cr_state IS
114
      WHEN one =>
115
        nx_state <= two;
116
      WHEN two =>
117
        nx_state <= three;
118
      WHEN three =>
119
        nx_state <= four;
120
      WHEN four =>
121
        nx_state <= five;
122
      WHEN five =>
123
        nx_state <= six;
124
      WHEN six =>
125
        nx_state <= seven;
126
      WHEN seven =>
127
        nx_state <= one;
128
      WHEN eight =>
129
        nx_state <= one;
130
    END CASE;
131
  END PROCESS next_control;
132
 
133
  reg_a       <= cr_reg_a;
134
  reg_b       <= cr_reg_b;
135
  op_sel      <= cr_op_sel;
136
  reg_input   <= cr_reg_input;
137
  reg_write   <= cr_reg_write;
138
  pc_input    <= cr_pc_input;
139
  addr_source <= cr_addr_source;
140
  wr          <= cr_wr;
141
  rd          <= cr_rd;
142
 
143
END Behavioral;
144
 

powered by: WebSVN 2.1.0

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