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

Subversion Repositories pdp8

[/] [pdp8/] [trunk/] [pdp8/] [cpu/] [eae.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 trurl
------------------------------------------------------------------
2
--!
3
--! PDP-8 Processor
4
--!
5
--! \brief
6
--!      CPU Extended Arithmetic Element (EAE)
7
--!
8
--! \file
9
--!      eae.vhd
10
--!
11
--! \author
12
--!      Rob Doyle - doyle (at) cox (dot) net
13
--!
14
--------------------------------------------------------------------
15
--
16
--  Copyright (C) 2009, 2010, 2011, 2012 Rob Doyle
17
--
18
-- This source file may be used and distributed without
19
-- restriction provided that this copyright statement is not
20
-- removed from the file and that any derivative work contains
21
-- the original copyright notice and the associated disclaimer.
22
--
23
-- This source file is free software; you can redistribute it
24
-- and/or modify it under the terms of the GNU Lesser General
25
-- Public License as published by the Free Software Foundation;
26
-- version 2.1 of the License.
27
--
28
-- This source is distributed in the hope that it will be
29
-- useful, but WITHOUT ANY WARRANTY; without even the implied
30
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
31
-- PURPOSE. See the GNU Lesser General Public License for more
32
-- details.
33
--
34
-- You should have received a copy of the GNU Lesser General
35
-- Public License along with this source; if not, download it
36
-- from http://www.gnu.org/licenses/lgpl.txt
37
--
38
--------------------------------------------------------------------
39
--
40
-- Comments are formatted for doxygen
41
--
42
 
43
library ieee;                                   --! IEEE Library
44
use ieee.std_logic_1164.all;                    --! IEEE 1164
45
use ieee.numeric_std.all;                       --! IEEE Numeric Standard
46
use work.cpu_types.all;                         --! Types
47
 
48
--
49
--! CPU Extended Arithmetic Element (EAE) Entity
50
--
51
 
52
entity eEAE is
53
    port (
54
        sys   : in  sys_t;                      --! Clock/Reset
55
        eaeOP : in  eaeOP_t;                    --! EAE Operation
56
        MD    : in  data_t;                     --! MD Register
57
        MQ    : in  data_t;                     --! MQ Register
58
        AC    : in  data_t;                     --! AC register
59
        EAE   : out eae_t                       --! EAE Output
60
    );
61
end eEAE;
62
 
63
--
64
--! CPU Extended Arithmetic Element (EAE) RTL
65
--
66
 
67
architecture rtl of eEAE is
68
 
69
    signal eaeREG : eae_t;                      --! EAE Register
70
    signal eaeMUX : eae_t;                      --! EAE Multiplexer
71
    signal temp1  : unsigned(0 to 24);
72
 
73
    --
74
    -- Function to implement 24bit ASR
75
    --
76
 
77
    function asr24(i : std_logic_vector; sc : std_logic_vector) return std_logic_vector is
78
        constant count : integer  := to_integer(unsigned(sc));
79
    begin
80
        case count is
81
            when 0 =>
82
                return i(1) & i(1 to 24);
83
            when 1 =>
84
                return i(1) & i(1) & i(1 to 23);
85
            when 2 =>
86
                return i(1) & i(1) & i(1) & i(1 to 22);
87
            when 3 =>
88
                return i(1) & i(1) & i(1) & i(1) & i(1 to 21);
89
            when 4 =>
90
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1 to 20);
91
            when 5 =>
92
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1 to 19);
93
            when 6 =>
94
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1 to 18);
95
            when 7 =>
96
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1 to 17);
97
            when 8 =>
98
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
99
                       i(1 to 16);
100
            when 9 =>
101
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
102
                       i(1) & i(1 to 15);
103
            when 10 =>
104
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
105
                       i(1) & i(1) & i(1 to 14);
106
            when 11 =>
107
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
108
                       i(1) & i(1) &  i(1) & i(1 to 13);
109
            when 12 =>
110
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
111
                       i(1) & i(1) & i(1) & i(1) & i(1 to 12);
112
            when 13 =>
113
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
114
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1 to 11);
115
            when 14 =>
116
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
117
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1 to 10);
118
            when 15 =>
119
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
120
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1 to 9);
121
            when 16 =>
122
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
123
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1 to 8);
124
            when 17 =>
125
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
126
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
127
                       i(1 to 7);
128
            when 18 =>
129
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
130
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
131
                       i(1) & i(1 to 6);
132
            when 19 =>
133
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
134
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
135
                       i(1) & i(1) & i(1 to 5);
136
            when 20 =>
137
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
138
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
139
                       i(1) & i(1) & i(1) & i(1 to 4);
140
            when 21 =>
141
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
142
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
143
                       i(1) & i(1) & i(1) & i(1) & i(1 to 3);
144
            when 22 =>
145
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
146
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
147
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1 to 2);
148
            when 23 =>
149
                return i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
150
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1) &
151
                       i(1) & i(1) & i(1) & i(1) & i(1) & i(1) & i(1);
152
            when others =>
153
                return i;
154
 
155
        end case;
156
    end asr24;
157
 
158
    --
159
    -- Function to implement 24bit LSR
160
    --
161
 
162
    function lsr24(i : std_logic_vector; sc : std_logic_vector) return std_logic_vector is
163
        constant count : integer  := to_integer(unsigned(sc));
164
    begin
165
        case count is
166
            when 0 =>
167
                return '0' & i(1 to 24);
168
            when 1 =>
169
                return '0' & '0' & i(1 to 23);
170
            when 2 =>
171
                return '0' & '0' & '0' & i(1 to 22);
172
            when 3 =>
173
                return '0' & '0' & '0' & '0' & i(1 to 21);
174
            when 4 =>
175
                return '0' & '0' & '0' & '0' & '0' & i(1 to 20);
176
            when 5 =>
177
                return '0' & '0' & '0' & '0' & '0' & '0' & i(1 to 19);
178
            when 6 =>
179
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & i(1 to 18);
180
            when 7 =>
181
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & i(1 to 17);
182
            when 8 =>
183
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
184
                       i(1 to 16);
185
            when 9 =>
186
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
187
                       '0' & i(1 to 15);
188
            when 10 =>
189
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
190
                       '0' & '0' & i(1 to 14);
191
            when 11 =>
192
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
193
                       '0' & '0' &  '0' & i(1 to 13);
194
            when 12 =>
195
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
196
                       '0' & '0' & '0' & '0' & i(1 to 12);
197
            when 13 =>
198
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
199
                       '0' & '0' & '0' & '0' & '0' & i(1 to 11);
200
            when 14 =>
201
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
202
                       '0' & '0' & '0' & '0' & '0' & '0' & i(1 to 10);
203
            when 15 =>
204
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
205
                       '0' & '0' & '0' & '0' & '0' & '0' & '0' & i(1 to 9);
206
            when 16 =>
207
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
208
                       '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & i(1 to 8);
209
            when 17 =>
210
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
211
                       '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
212
                       i(1 to 7);
213
            when 18 =>
214
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
215
                       '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
216
                       '0' & i(1 to 6);
217
            when 19 =>
218
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
219
                       '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
220
                       '0' & '0' & i(1 to 5);
221
            when 20 =>
222
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
223
                       '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
224
                       '0' & '0' & '0' & i(1 to 4);
225
            when 21 =>
226
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
227
                       '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
228
                       '0' & '0' & '0' & '0' & i(1 to 3);
229
            when 22 =>
230
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
231
                       '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
232
                       '0' & '0' & '0' & '0' & '0' & i(1 to 2);
233
            when 23 =>
234
                return '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
235
                       '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' & '0' &
236
                       '0' & '0' & '0' & '0' & '0' & '0' & '0';
237
            when others =>
238
                return i;
239
        end case;
240
    end lsr24;
241
 
242
    --
243
    -- Function to implement 24bit SHL
244
    --
245
 
246
    function shl24(i : std_logic_vector; sc : std_logic_vector) return std_logic_vector is
247
        constant count : integer  := to_integer(unsigned(sc));
248
    begin
249
        case count is
250
            when 0 =>
251
                return i( 0 to 24);
252
            when 1 =>
253
                return i( 1 to 24) & "0";
254
            when 2 =>
255
                return i( 2 to 24) & "00";
256
            when 3 =>
257
                return i( 3 to 24) & "000";
258
            when 4 =>
259
                return i( 4 to 24) & "0000";
260
            when 5 =>
261
                return i( 5 to 24) & "00000";
262
            when 6 =>
263
                return i( 6 to 24) & "000000";
264
            when 7 =>
265
                return i( 7 to 24) & "0000000";
266
            when 8 =>
267
                return i( 8 to 24) & "00000000";
268
            when 9 =>
269
                return i( 9 to 24) & "000000000";
270
            when 10 =>
271
                return i(10 to 24) & "0000000000";
272
            when 11 =>
273
                return i(11 to 24) & "00000000000";
274
            when 12 =>
275
                return i(12 to 24) & "000000000000";
276
            when 13 =>
277
                return i(13 to 24) & "0000000000000";
278
            when 14 =>
279
                return i(14 to 24) & "00000000000000";
280
            when 15 =>
281
                return i(15 to 24) & "000000000000000";
282
            when 16 =>
283
                return i(16 to 24) & "0000000000000000";
284
            when 17 =>
285
                return i(17 to 24) & "00000000000000000";
286
            when 18 =>
287
                return i(18 to 24) & "000000000000000000";
288
            when 19 =>
289
                return i(19 to 24) & "0000000000000000000";
290
            when 20 =>
291
                return i(20 to 24) & "00000000000000000000";
292
            when 21 =>
293
                return i(21 to 24) & "000000000000000000000";
294
            when 22 =>
295
                return i(22 to 24) & "0000000000000000000000";
296
            when 23 =>
297
                return i(23 to 24) & "00000000000000000000000";
298
            when 24 =>
299
                return i(24 to 24) & "000000000000000000000000";
300
            when others =>
301
                return "0000000000000000000000000";
302
        end case;
303
    end shl24;
304
 
305
begin
306
 
307
    temp1 <= ('0' & unsigned(MD) * unsigned(MQ)) + unsigned(AC);
308
 
309
    --
310
    -- EAE Multiplexer
311
    --
312
 
313
    with eaeOP select
314
        eaeMUX <= eaeREG                   when eaeopNOP,       -- EAE <- EAE
315
                  std_logic_vector(temp1)  when eaeopMUY;       -- EAE <- (MQ * MD) + AC;
316
                --asr24(eaeREG, MD)        when eaeopASRMD,     -- EAE <- EAE ASR MD
317
                --lsr24(eaeREG, MD)        when eaeopLSRMD,     -- EAE <- EAE LSR MD
318
                --shl24(eaeREG, MD)        when eaeopSHLMD;     -- EAE <- EAE SHL MD
319
    --
320
    --! EAE Register
321
    --
322
 
323
    REG_EAE : process(sys)
324
    begin
325
        if sys.rst = '1' then
326
            eaeREG <= (others => '0');
327
        elsif rising_edge(sys.clk) then
328
            eaeREG <= eaeMUX;
329
        end if;
330
    end process REG_EAE;
331
 
332
    EAE <= eaeREG;
333
 
334
end rtl;

powered by: WebSVN 2.1.0

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