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

Subversion Repositories fpuvhdl

[/] [fpuvhdl/] [trunk/] [fpuvhdl/] [adder/] [fpadd_normalize_struct.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 gmarcus
-- VHDL Entity work.FPadd_normalize.symbol
2 3 gmarcus
--
3
-- Created by
4
-- Guillermo Marcus, gmarcus@ieee.org
5
-- using Mentor Graphics FPGA Advantage tools.
6
--
7
-- Visit "http://fpga.mty.itesm.mx" for more info.
8
--
9
-- 2003-2004. V1.0
10
--
11
 
12
LIBRARY ieee;
13
USE ieee.std_logic_1164.all;
14
USE ieee.std_logic_arith.all;
15
 
16
ENTITY FPadd_normalize IS
17
   PORT(
18
      EXP_in  : IN     std_logic_vector (7 DOWNTO 0);
19
      SIG_in  : IN     std_logic_vector (27 DOWNTO 0);
20
      EXP_out : OUT    std_logic_vector (7 DOWNTO 0);
21
      SIG_out : OUT    std_logic_vector (27 DOWNTO 0);
22
      zero    : OUT    std_logic
23
   );
24
 
25
-- Declarations
26
 
27
END FPadd_normalize ;
28
 
29
--
30 4 gmarcus
-- VHDL Architecture work.FPadd_normalize.struct
31 3 gmarcus
--
32
-- Created by
33
-- Guillermo Marcus, gmarcus@ieee.org
34
-- using Mentor Graphics FPGA Advantage tools.
35
--
36
-- Visit "http://fpga.mty.itesm.mx" for more info.
37
--
38
-- Copyright 2003-2004. V1.0
39
--
40
 
41
 
42
LIBRARY ieee;
43
USE ieee.std_logic_1164.all;
44
USE ieee.std_logic_arith.all;
45
USE ieee.std_logic_unsigned.all;
46
 
47
ARCHITECTURE struct OF FPadd_normalize IS
48
 
49
   -- Architecture declarations
50
 
51
   -- Internal signal declarations
52
   SIGNAL EXP_lshift : std_logic_vector(7 DOWNTO 0);
53
   SIGNAL EXP_rshift : std_logic_vector(7 DOWNTO 0);
54
   SIGNAL SIG_lshift : std_logic_vector(27 DOWNTO 0);
55
   SIGNAL SIG_rshift : std_logic_vector(27 DOWNTO 0);
56
   SIGNAL add_in     : std_logic_vector(7 DOWNTO 0);
57
   SIGNAL cin        : std_logic;
58
   SIGNAL count      : std_logic_vector(4 DOWNTO 0);
59
   SIGNAL isDN       : std_logic;
60
   SIGNAL shift_RL   : std_logic;
61
   SIGNAL word       : std_logic_vector(26 DOWNTO 0);
62
   SIGNAL zero_int   : std_logic;
63 8 gmarcus
   SIGNAL denormal   : std_logic;
64
        SIGNAL lshift_cnt : std_logic_vector(4 DOWNTO 0);
65 3 gmarcus
 
66
   -- Component Declarations
67
   COMPONENT FPlzc
68
   PORT (
69
      word  : IN     std_logic_vector (26 DOWNTO 0);
70
      zero  : OUT    std_logic ;
71
      count : OUT    std_logic_vector (4 DOWNTO 0)
72
   );
73
   END COMPONENT;
74
 
75
   -- Optional embedded configurations
76
   -- pragma synthesis_off
77 4 gmarcus
   FOR ALL : FPlzc USE ENTITY work.FPlzc;
78 3 gmarcus
   -- pragma synthesis_on
79
 
80
 
81
BEGIN
82
   -- Architecture concurrent statements
83
   -- HDL Embedded Text Block 1 eb1
84
   -- eb1 1                                        
85
   SIG_rshift <= '0' & SIG_in(27 DOWNTO 2) & (SIG_in(1) AND SIG_in(0));
86
 
87
   -- HDL Embedded Text Block 2 eb2
88
   -- eb2 2                    
89
   add_in <= "000" & count;
90
 
91 8 gmarcus
        -- limit the count to the exponent value
92
        PROCESS(count,EXP_in)
93
        BEGIN
94
                IF (signed(count) > signed(EXP_in)) THEN
95
                        lshift_cnt <= EXP_in(4 downto 0)-1;
96
                        denormal <= '1';
97
                ELSE
98
                        lshift_cnt <= count;
99
                        denormal <= '0';
100
                END IF;
101
        END PROCESS;
102
 
103 3 gmarcus
   -- HDL Embedded Text Block 3 eb3
104
   -- eb3 3
105 8 gmarcus
   PROCESS( isDN, shift_RL, EXP_lshift, EXP_rshift, EXP_in, SIG_lshift, SIG_rshift, SIG_in, denormal)
106 3 gmarcus
   BEGIN
107
   IF (isDN='1') THEN
108
      EXP_out <= X"00";
109
      SIG_out <= SIG_in;
110
   ELSE
111
      IF (shift_RL='1') THEN
112
         -- Shift Right
113
         IF (SIG_in(27)='1') THEN
114
            EXP_out <= EXP_rshift;
115
            SIG_out <= SIG_rshift;
116
         ELSE
117
            EXP_out <= EXP_in;
118
            SIG_out <= SIG_in;
119
         END IF;
120
      ELSE
121
         -- Shift Left
122 8 gmarcus
                        IF (denormal='1') THEN
123
                                EXP_out <= (OTHERS => '0');
124
                                SIG_out <= SIG_lshift;
125
                        ELSE
126
                                EXP_out <= EXP_lshift;
127
                                SIG_out <= SIG_lshift;
128
                        END IF;
129 3 gmarcus
      END IF;
130
   END IF;
131
   END PROCESS;
132
 
133
   -- HDL Embedded Text Block 4 eb4
134
   -- eb4 4
135
   zero <= zero_int AND NOT SIG_in(27);
136
 
137
   -- HDL Embedded Text Block 5 eb5
138
   -- eb5 5
139
   word <= SIG_in(26 DOWNTO 0);
140
 
141
   -- HDL Embedded Text Block 6 eb6
142
   -- eb6 6
143
   PROCESS(SIG_in,EXP_in)
144
   BEGIN
145
      IF (SIG_in(27)='0' AND SIG_in(26)='0' AND (EXP_in=X"01")) THEN
146
         isDN <= '1';
147
         shift_RL <= '0';
148
      ELSIF (SIG_in(27)='0' AND SIG_in(26)='0' AND (EXP_in/=X"00")) THEN
149
         isDN <= '0';
150
         shift_RL <= '0';
151
      ELSE
152
         isDN <= '0';
153
         shift_RL <= '1';
154
      END IF;
155
   END PROCESS;
156
 
157
 
158
   -- ModuleWare code(v1.1) for instance 'I3' of 'gnd'
159
   cin <= '0';
160
 
161
   -- ModuleWare code(v1.1) for instance 'I4' of 'inc'
162
   I4combo: PROCESS (EXP_in)
163
   VARIABLE t0 : std_logic_vector(8 DOWNTO 0);
164
   VARIABLE sum : signed(8 DOWNTO 0);
165
   VARIABLE din_l : std_logic_vector(7 DOWNTO 0);
166
   BEGIN
167
      din_l := EXP_in;
168
      t0 := din_l(7) & din_l;
169
      sum := (signed(t0) + '1');
170
      EXP_rshift <= conv_std_logic_vector(sum(7 DOWNTO 0),8);
171
   END PROCESS I4combo;
172
 
173
   -- ModuleWare code(v1.1) for instance 'I1' of 'lshift'
174 8 gmarcus
   I1combo : PROCESS (SIG_in, lshift_cnt)
175 3 gmarcus
   VARIABLE stemp : std_logic_vector (4 DOWNTO 0);
176
   VARIABLE dtemp : std_logic_vector (27 DOWNTO 0);
177
   VARIABLE temp : std_logic_vector (27 DOWNTO 0);
178
   BEGIN
179
      temp := (OTHERS=> 'X');
180 8 gmarcus
      stemp := lshift_cnt;
181 3 gmarcus
      temp := SIG_in;
182
      FOR i IN 4 DOWNTO 0 LOOP
183
         IF (i < 5) THEN
184
            IF (stemp(i) = '1' OR stemp(i) = 'H') THEN
185
               dtemp := (OTHERS => '0');
186
               dtemp(27 DOWNTO 2**i) := temp(27 - 2**i DOWNTO 0);
187
            ELSIF (stemp(i) = '0' OR stemp(i) = 'L') THEN
188
               dtemp := temp;
189
            ELSE
190
               dtemp := (OTHERS => 'X');
191
            END IF;
192
         ELSE
193
            IF (stemp(i) = '1' OR stemp(i) = 'H') THEN
194
               dtemp := (OTHERS => '0');
195
            ELSIF (stemp(i) = '0' OR stemp(i) = 'L') THEN
196
               dtemp := temp;
197
            ELSE
198
               dtemp := (OTHERS => 'X');
199
            END IF;
200
         END IF;
201
         temp := dtemp;
202
      END LOOP;
203
      SIG_lshift <= dtemp;
204
   END PROCESS I1combo;
205
 
206
   -- ModuleWare code(v1.1) for instance 'I2' of 'sub'
207
   I2combo: PROCESS (EXP_in, add_in, cin)
208
   VARIABLE mw_I2t0 : std_logic_vector(8 DOWNTO 0);
209
   VARIABLE mw_I2t1 : std_logic_vector(8 DOWNTO 0);
210
   VARIABLE diff : signed(8 DOWNTO 0);
211
   VARIABLE borrow : std_logic;
212
   BEGIN
213
      mw_I2t0 := EXP_in(7) & EXP_in;
214
      mw_I2t1 := add_in(7) & add_in;
215
      borrow := cin;
216
      diff := signed(mw_I2t0) - signed(mw_I2t1) - borrow;
217
      EXP_lshift <= conv_std_logic_vector(diff(7 DOWNTO 0),8);
218
   END PROCESS I2combo;
219
 
220
   -- Instance port mappings.
221
   I0 : FPlzc
222
      PORT MAP (
223
         word  => word,
224
         zero  => zero_int,
225
         count => count
226
      );
227
 
228
END struct;

powered by: WebSVN 2.1.0

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