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

Subversion Repositories ecpu_alu

[/] [ecpu_alu/] [trunk/] [alu/] [rtl/] [vhdl/] [alu_controller.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 leonous
--------------------------------------------------------------------------------
2
--------------------------------------------------------------------------------
3
-- Module   - Introduction to VLSI Design [03ELD005]
4
-- Lecturer - Dr V. M. Dwyer
5
-- Course   - MEng Electronic and Electrical Engineering
6
-- Year     - Part D
7
-- Student  - Sahrfili Leonous Matturi A028459 [elslm]
8
--------------------------------------------------------------------------------
9
--------------------------------------------------------------------------------
10
-- Final coursework 2004
11
-- 
12
-- Details:     Design and Layout of an ALU
13
--------------------------------------------------------------------------------
14
--------------------------------------------------------------------------------
15
 
16
--      Description     :       ALU opcode_seller
17
--  Entity                      :       alu_opcode_seller
18
--      Architecture    :       behavioural
19
--  Created on          :       07/03/2004
20
 
21
library ieee;
22
 
23
use ieee.std_logic_1164.all;
24
use     ieee.std_logic_unsigned.all;
25
 
26
entity alu_controller is
27
        generic (
28
                        ALU_WIDTH : integer := 8
29
                        );
30
        port    (
31
                        add_AB          : out   std_logic;
32
                        sub_AB          : out   std_logic;
33
                        inc_A           : out   std_logic;
34
                        inc_B           : out   std_logic;
35
                        dec_A           : out   std_logic;
36
                        dec_B           : out   std_logic;
37
                        cmp_AB          : out   std_logic;
38
                        and_AB          : out   std_logic;
39
                        or_AB           : out   std_logic;
40
                        xor_AB          : out   std_logic;
41
                        cpl_B           : out   std_logic;
42
                        cpl_A           : out   std_logic;
43
                        sl_AB           : out   std_logic;
44
                        sr_AB           : out   std_logic;
45
                        clr                     : out   std_logic;
46
 
47
                        clr_Z           : out   std_logic;
48
                        clr_V           : out   std_logic;
49
                        clr_C           : out   std_logic;
50
 
51
                        load_inputs     : out   std_logic;
52
                        load_outputs: out       std_logic;
53
 
54
                        opcode          : in    std_logic_vector(3 downto 0);
55
                        reset           : in    std_logic;
56
                        clk                     : in    std_logic
57
                        );
58
 
59
end alu_controller;
60
 
61
 
62
architecture behavioural of alu_controller is
63
 
64
subtype         opcode_selLER_opcode is std_logic_vector(3 downto 0);
65
type            OPERATION is (add_op, inc_op, sub_op, cmp_op, and_op, or_op, xor_op, cpl_op, asl_op,asr_op, clr_op);
66
signal          this_opcode, next_opcode
67
                                                : opcode_selLER_opcode;
68
signal          opcode_sel              : std_logic_vector(16 downto 0);
69
signal          control                 : std_logic_vector(2 downto 0);
70
 
71
constant        addAB           :       integer := 00;
72
constant        subAB           :       integer := 01;
73
constant        incA            :       integer := 02;
74
constant        incB            :       integer := 03;
75
 
76
constant        decA            :       integer := 04;
77
constant        decB            :       integer := 05;
78
constant        cmpAB           :       integer := 06;
79
constant        andAB           :       integer := 07;
80
 
81
constant        orAB            :       integer := 08;
82
constant        xorAB           :       integer := 09;
83
constant        cplB            :       integer := 10;
84
constant        cplA            :       integer := 11;
85
 
86
constant        slAB            :       integer := 12;
87
constant        srAB            :       integer := 13;
88
constant        clrALL          :       integer := 14;
89
constant        clrZ            :       integer := 0;
90
 
91
constant        clrV            :       integer := 1;
92
constant        clrC            :       integer := 2;
93
 
94
constant        cADD_AB         : opcode_selLER_opcode  := "0000";
95
constant        cINC_A          : opcode_selLER_opcode  := "0001";
96
constant        cSUB_AB         : opcode_selLER_opcode  := "0010";
97
constant        cCMP_AB         : opcode_selLER_opcode  := "0011";
98
constant        cAND_AB         : opcode_selLER_opcode  := "1100";
99
constant        cOR_AB          : opcode_selLER_opcode  := "1101";
100
constant        cXOR_AB         : opcode_selLER_opcode  := "1110";
101
constant        cCPL_B          : opcode_selLER_opcode  := "1111";
102
constant        cASL_AbyB       : opcode_selLER_opcode  := "0100";
103
constant        cASR_AbyB       : opcode_selLER_opcode  := "0101";
104
constant        cCLR            : opcode_selLER_opcode  := "0110";
105
 
106
 
107
begin
108
 
109
 
110
        add_AB  <=      opcode_sel(addAB);
111
        sub_AB  <=      opcode_sel(subAB);
112
        inc_A   <=      opcode_sel(incA);
113
        inc_B   <=      opcode_sel(incB);
114
        dec_A   <=      opcode_sel(decA);
115
        dec_B   <=      opcode_sel(decB);
116
        cmp_AB  <=      opcode_sel(cmpAB);
117
        and_AB  <=      opcode_sel(andAB);
118
        or_AB   <=      opcode_sel(orAB);
119
        xor_AB  <=      opcode_sel(xorAB);
120
        cpl_B   <=      opcode_sel(cplB);
121
        cpl_A   <=      opcode_sel(cplA);
122
        sl_AB   <=      opcode_sel(slAB);
123
        sr_AB   <=      opcode_sel(srAB);
124
        clr             <=      opcode_sel(clrALL);
125
 
126
        clr_Z   <=      control(clrZ);
127
        clr_V   <=      control(clrV);
128
        clr_C   <=      control(clrC);
129
 
130
        state   :       process (clk)
131
                                begin
132
                                        if              (reset = '1') then
133
                                                this_opcode <= cCLR;
134
                                        elsif   (clk'event and clk = '1') then
135
                                                this_opcode <= opcode;
136
                                        end if;
137
                                end process state;
138
 
139
        comb    :       process (this_opcode)
140
                                begin
141
                                        -- reset opcode_sel signals
142
                                        opcode_sel <= (others => '0');
143
                                        load_inputs     <= '0';
144
                                        case (this_opcode) is
145
                                                when cCLR               =>
146
                                                        opcode_sel(clrALL)      <= '1'  ;
147
                                                when cADD_AB    =>
148
                                                        opcode_sel(addAB)       <= '1';
149
                                                        load_inputs     <= '1';
150
                                                        load_outputs    <= '1';
151
                                                when cINC_A             =>
152
                                                        opcode_sel(incA)        <= '1';
153
                                                        load_inputs     <= '1';
154
                                                        load_outputs    <= '1';
155
                                                when cSUB_AB    =>
156
                                                        opcode_sel(subAB)       <= '1';
157
                                                        load_inputs     <= '1';
158
                                                        load_outputs    <= '1';
159
                                                when cCMP_AB    =>
160
                                                        opcode_sel(cmpAB)       <= '1';
161
                                                        load_inputs     <= '1';
162
                                                when cAND_AB    =>
163
                                                        opcode_sel(andAB)       <= '1';
164
                                                        load_inputs     <= '1';
165
                                                        load_outputs    <= '1';
166
                                                when cOR_AB             =>
167
                                                        opcode_sel(orAB)        <= '1';
168
                                                        load_inputs     <= '1';
169
                                                        load_outputs    <= '1';
170
                                                when cXOR_AB    =>
171
                                                        opcode_sel(xorAB)       <= '1';
172
                                                        load_inputs     <= '1';
173
                                                        load_outputs    <= '1';
174
                                                when cCPL_B             =>
175
                                                        opcode_sel(cplB)        <= '1';
176
                                                        load_inputs     <= '1';
177
                                                        load_outputs    <= '1';
178
                                                when cASL_AbyB  =>
179
                                                        opcode_sel(slAB)        <= '1';
180
                                                        load_inputs     <= '1';
181
                                                        load_outputs    <= '1';
182
                                                when cASR_AbyB  =>
183
                                                        opcode_sel(srAB)        <= '1';
184
                                                        load_inputs     <= '1';
185
                                                        load_outputs    <= '1';
186
                                                when others             =>
187
                                                        next_opcode             <= this_opcode;
188
                                        end case;
189
                                end process comb;
190
end behavioural;

powered by: WebSVN 2.1.0

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