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

Subversion Repositories g729a_codec

[/] [g729a_codec/] [trunk/] [VHDL/] [G729A_asip_arith_pkg.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 madsilicon
-----------------------------------------------------------------
2
--                                                             --
3
-----------------------------------------------------------------
4
--                                                             --
5
-- Copyright (C) 2013 Stefano Tonello                          --
6
--                                                             --
7
-- This source file may be used and distributed without        --
8
-- restriction provided that this copyright statement is not   --
9
-- removed from the file and that any derivative work contains --
10
-- the original copyright notice and the associated disclaimer.--
11
--                                                             --
12
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY         --
13
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   --
14
-- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   --
15
-- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      --
16
-- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         --
17
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    --
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   --
19
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        --
20
-- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  --
21
-- LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  --
22
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  --
23
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         --
24
-- POSSIBILITY OF SUCH DAMAGE.                                 --
25
--                                                             --
26
-----------------------------------------------------------------
27
 
28
---------------------------------------------------------------
29
-- Arithmetic operations macros and shifting functions
30
---------------------------------------------------------------
31
 
32
library IEEE;
33
use IEEE.std_logic_1164.all;
34
use IEEE.numeric_std.all;
35
 
36
library WORK;
37
use WORK.G729A_ASIP_PKG.all;
38
use WORK.G729A_ASIP_BASIC_PKG.all;
39
 
40
package G729A_ASIP_ARITH_PKG is
41
 
42
  type ADD_CTRL is (
43
    AC_ABS,
44
    AC_ADD,
45
    AC_NEG,
46
    AC_SUB,
47
    AC_LABS,
48
    AC_LADD,
49
    AC_LNEG,
50
    AC_LSUB,
51
    AC_LEXT,
52
    AC_RND,
53
    AC_INC,
54
    AC_DEC,
55
    AC_NIL
56
  );
57
 
58
  type MUL_CTRL is (
59
    MC_MUL,
60
    MC_LMUL,
61
    MC_MULA,
62
    MC_MULR,
63
    MC_LMAC,
64
    MC_LMSU,
65
    MC_M3216,
66
    MC_M32,
67
    MC_NIL
68
  );
69
 
70
  type SHF_CTRL is (
71
    SC_SHL,
72
    SC_SHR,
73
    SC_LSHL,
74
    SC_LSHR,
75
    SC_NRMS,
76
    SC_NRML,
77
    SC_NIL
78
  );
79
 
80
  type LOG_CTRL is (
81
    LC_AND,
82
    LC_OR,
83
    LC_ANDL,
84
    LC_ANDH,
85
    LC_ORL,
86
    LC_ORH,
87
    LC_NIL
88
  );
89
 
90
  function shift_left16(SI : SDWORD_T;SHFT : LONG_SHIFT_T) return SDWORD_T;
91
 
92
  function shift_right16(SI : SDWORD_T;SHFT : LONG_SHIFT_T) return SDWORD_T;
93
 
94
  function shift_left32(SI : LDWORD_T;SHFT : LONG_SHIFT_T) return LDWORD_T;
95
 
96
  function shift_right32(SI : LDWORD_T;SHFT : LONG_SHIFT_T) return LDWORD_T;
97
 
98
end G729A_ASIP_ARITH_PKG;
99
 
100
package body G729A_ASIP_ARITH_PKG is
101
 
102
  function shift_left16(SI : SDWORD_T;SHFT : LONG_SHIFT_T) return SDWORD_T is
103
    variable SO : SDWORD_T;
104
  begin
105
    case SHFT is
106
      when  0 => SO := shift_left(SI, 0);
107
      when  1 => SO := shift_left(SI, 1);
108
      when  2 => SO := shift_left(SI, 2);
109
      when  3 => SO := shift_left(SI, 3);
110
      when  4 => SO := shift_left(SI, 4);
111
      when  5 => SO := shift_left(SI, 5);
112
      when  6 => SO := shift_left(SI, 6);
113
      when  7 => SO := shift_left(SI, 7);
114
      when  8 => SO := shift_left(SI, 8);
115
      when  9 => SO := shift_left(SI, 9);
116
      when 10 => SO := shift_left(SI,10);
117
      when 11 => SO := shift_left(SI,11);
118
      when 12 => SO := shift_left(SI,12);
119
      when 13 => SO := shift_left(SI,13);
120
      when 14 => SO := shift_left(SI,14);
121
      when others => SO := shift_left(SI,15);
122
    end case;
123
    return(SO);
124
  end function;
125
 
126
  function shift_right16(SI : SDWORD_T;SHFT : LONG_SHIFT_T) return SDWORD_T is
127
    variable SO : SDWORD_T;
128
  begin
129
    case SHFT is
130
      when  0 => SO := shift_right(SI, 0);
131
      when  1 => SO := shift_right(SI, 1);
132
      when  2 => SO := shift_right(SI, 2);
133
      when  3 => SO := shift_right(SI, 3);
134
      when  4 => SO := shift_right(SI, 4);
135
      when  5 => SO := shift_right(SI, 5);
136
      when  6 => SO := shift_right(SI, 6);
137
      when  7 => SO := shift_right(SI, 7);
138
      when  8 => SO := shift_right(SI, 8);
139
      when  9 => SO := shift_right(SI, 9);
140
      when 10 => SO := shift_right(SI,10);
141
      when 11 => SO := shift_right(SI,11);
142
      when 12 => SO := shift_right(SI,12);
143
      when 13 => SO := shift_right(SI,13);
144
      when 14 => SO := shift_right(SI,14);
145
      when others => SO := shift_right(SI,15);
146
    end case;
147
    return(SO);
148
  end function;
149
 
150
  function shift_left32(SI : LDWORD_T;SHFT : LONG_SHIFT_T) return LDWORD_T is
151
    variable SO : LDWORD_T;
152
  begin
153
    case SHFT is
154
      when  0 => SO := shift_left(SI, 0);
155
      when  1 => SO := shift_left(SI, 1);
156
      when  2 => SO := shift_left(SI, 2);
157
      when  3 => SO := shift_left(SI, 3);
158
      when  4 => SO := shift_left(SI, 4);
159
      when  5 => SO := shift_left(SI, 5);
160
      when  6 => SO := shift_left(SI, 6);
161
      when  7 => SO := shift_left(SI, 7);
162
      when  8 => SO := shift_left(SI, 8);
163
      when  9 => SO := shift_left(SI, 9);
164
      when 10 => SO := shift_left(SI,10);
165
      when 11 => SO := shift_left(SI,11);
166
      when 12 => SO := shift_left(SI,12);
167
      when 13 => SO := shift_left(SI,13);
168
      when 14 => SO := shift_left(SI,14);
169
      when 15 => SO := shift_left(SI,15);
170
      when 16 => SO := shift_left(SI,16);
171
      when 17 => SO := shift_left(SI,17);
172
      when 18 => SO := shift_left(SI,18);
173
      when 19 => SO := shift_left(SI,19);
174
      when 20 => SO := shift_left(SI,20);
175
      when 21 => SO := shift_left(SI,21);
176
      when 22 => SO := shift_left(SI,22);
177
      when 23 => SO := shift_left(SI,23);
178
      when 24 => SO := shift_left(SI,24);
179
      when 25 => SO := shift_left(SI,25);
180
      when 26 => SO := shift_left(SI,26);
181
      when 27 => SO := shift_left(SI,27);
182
      when 28 => SO := shift_left(SI,28);
183
      when 29 => SO := shift_left(SI,29);
184
      when 30 => SO := shift_left(SI,30);
185
      when others => SO := shift_left(SI,31);
186
    end case;
187
    return(SO);
188
  end function;
189
 
190
  function shift_right32(SI : LDWORD_T;SHFT : LONG_SHIFT_T) return LDWORD_T is
191
    variable SO : LDWORD_T;
192
  begin
193
    case SHFT is
194
      when  0 => SO := shift_right(SI, 0);
195
      when  1 => SO := shift_right(SI, 1);
196
      when  2 => SO := shift_right(SI, 2);
197
      when  3 => SO := shift_right(SI, 3);
198
      when  4 => SO := shift_right(SI, 4);
199
      when  5 => SO := shift_right(SI, 5);
200
      when  6 => SO := shift_right(SI, 6);
201
      when  7 => SO := shift_right(SI, 7);
202
      when  8 => SO := shift_right(SI, 8);
203
      when  9 => SO := shift_right(SI, 9);
204
      when 10 => SO := shift_right(SI,10);
205
      when 11 => SO := shift_right(SI,11);
206
      when 12 => SO := shift_right(SI,12);
207
      when 13 => SO := shift_right(SI,13);
208
      when 14 => SO := shift_right(SI,14);
209
      when 15 => SO := shift_right(SI,15);
210
      when 16 => SO := shift_right(SI,16);
211
      when 17 => SO := shift_right(SI,17);
212
      when 18 => SO := shift_right(SI,18);
213
      when 19 => SO := shift_right(SI,19);
214
      when 20 => SO := shift_right(SI,20);
215
      when 21 => SO := shift_right(SI,21);
216
      when 22 => SO := shift_right(SI,22);
217
      when 23 => SO := shift_right(SI,23);
218
      when 24 => SO := shift_right(SI,24);
219
      when 25 => SO := shift_right(SI,25);
220
      when 26 => SO := shift_right(SI,26);
221
      when 27 => SO := shift_right(SI,27);
222
      when 28 => SO := shift_right(SI,28);
223
      when 29 => SO := shift_right(SI,29);
224
      when 30 => SO := shift_right(SI,30);
225
      when others => SO := shift_right(SI,31);
226
    end case;
227
    return(SO);
228
  end function;
229
 
230
end G729A_ASIP_ARITH_PKG;

powered by: WebSVN 2.1.0

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