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

Subversion Repositories g729a_codec

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

Go to most recent revision | 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
-- G.729a ASIP 16x16 Register File
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
 
39
entity G729A_ASIP_REGFILE_16X16_2W is
40
  port(
41
    CLK_i : in std_logic;
42
    RA0_i : in RID_T;
43
    RA1_i : in RID_T;
44
    RA2_i : in RID_T;
45
    RA3_i : in RID_T;
46
    WA0_i : in RID_T;
47
    WA1_i : in RID_T;
48
    LR0_i : in std_logic;
49
    LR1_i : in std_logic;
50
    LR2_i : in std_logic;
51
    LR3_i : in std_logic;
52
    LW0_i : in std_logic;
53
    LW1_i : in std_logic;
54
    WE0_i : in std_logic;
55
    WE1_i : in std_logic;
56
    D0_i : in std_logic_vector(LDLEN-1 downto 0);
57
    D1_i : in std_logic_vector(LDLEN-1 downto 0);
58
 
59
    Q0_o : out std_logic_vector(LDLEN-1 downto 0);
60
    Q1_o : out std_logic_vector(LDLEN-1 downto 0);
61
    Q2_o : out std_logic_vector(LDLEN-1 downto 0);
62
    Q3_o : out std_logic_vector(LDLEN-1 downto 0)
63
  );
64
end G729A_ASIP_REGFILE_16X16_2W;
65
 
66
architecture ARC of G729A_ASIP_REGFILE_16X16_2W is
67
 
68
  constant REGNUM : natural := 16;
69
  constant ZERO : std_logic_vector(SDLEN-1 downto 0) := (others => '0');
70
 
71
  subtype WORD_T is std_logic_vector(SDLEN-1 downto 0);
72
  type MEM_T is array (REGNUM/2-1 downto 0) of WORD_T;
73
 
74
  signal REG_EVEN,REG_ODD : MEM_T;
75
  signal WE0_EVEN,WE0_ODD : std_logic;
76
  signal WE1_EVEN,WE1_ODD : std_logic;
77
  signal IWA0,IWA1 : natural range 0 to REGNUM/2-1;
78
  signal WA0_LSB,WA1_LSB : std_logic;
79
  signal IRA0,IRA1,IRA2,IRA3 : natural range 0 to REGNUM/2-1;
80
  signal RA0_LSB,RA1_LSB,RA2_LSB,RA3_LSB : std_logic;
81
  signal D0_LO,D0_HI : std_logic_vector(SDLEN-1 downto 0);
82
  signal D0_EVEN,D0_ODD : std_logic_vector(SDLEN-1 downto 0);
83
  signal D1_LO,D1_HI : std_logic_vector(SDLEN-1 downto 0);
84
  signal D1_EVEN,D1_ODD : std_logic_vector(SDLEN-1 downto 0);
85
  signal Q0_EVEN,Q1_EVEN : std_logic_vector(SDLEN-1 downto 0);
86
  signal Q0_ODD,Q1_ODD : std_logic_vector(SDLEN-1 downto 0);
87
  signal Q2_EVEN,Q3_EVEN : std_logic_vector(SDLEN-1 downto 0);
88
  signal Q2_ODD,Q3_ODD : std_logic_vector(SDLEN-1 downto 0);
89
 
90
  function GET_LSB(N : natural range 0 to 16-1) return std_logic is
91
    variable U : unsigned(4-1 downto 0);
92
  begin
93
    U := to_unsigned(N,4);
94
    return(U(0));
95
  end function;
96
 
97
begin
98
 
99
  ---------------------------------------------
100
 
101
  D0_LO <= D0_i(SDLEN-1 downto 0);
102
  D0_HI <= D0_i(SDLEN*2-1 downto SDLEN);
103
 
104
  D0_EVEN <= D0_LO;
105
  D0_ODD <= D0_HI when (LW0_i = '1') else D0_LO;
106
 
107
  process(WA0_LSB,WE0_i,LW0_i)
108
  begin
109
    if(LW0_i = '0') then
110
      WE0_EVEN <= (WE0_i and not(WA0_LSB));
111
      WE0_ODD <= (WE0_i and WA0_LSB);
112
    else
113
      WE0_EVEN <= WE0_i;
114
      WE0_ODD <= WE0_i;
115
    end if;
116
  end process;
117
 
118
  ---------------------------------------------
119
 
120
  D1_LO <= D1_i(SDLEN-1 downto 0);
121
  D1_HI <= D1_i(SDLEN*2-1 downto SDLEN);
122
 
123
  D1_EVEN <= D1_LO;
124
  D1_ODD <= D1_HI when (LW1_i = '1') else D1_LO;
125
 
126
  process(WA1_LSB,WE1_i,LW1_i)
127
  begin
128
    if(LW1_i = '0') then
129
      WE1_EVEN <= (WE1_i and not(WA1_LSB));
130
      WE1_ODD <= (WE1_i and WA1_LSB);
131
    else
132
      WE1_EVEN <= WE1_i;
133
      WE1_ODD <= WE1_i;
134
    end if;
135
  end process;
136
 
137
  ---------------------------------------------
138
 
139
  IWA0 <= WA0_i/2;
140
  IWA1 <= WA1_i/2;
141
 
142
  WA0_LSB <= GET_LSB(WA0_i);
143
  WA1_LSB <= GET_LSB(WA1_i);
144
 
145
  process(CLK_i)
146
  begin
147
    if(CLK_i = '1' and CLK_i'event) then
148
      if(WE0_EVEN = '1') then
149
        REG_EVEN(IWA0) <= D0_EVEN;
150
      end if;
151
      if(WE1_EVEN = '1') then
152
        REG_EVEN(IWA1) <= D1_EVEN;
153
      end if;
154
    end if;
155
  end process;
156
 
157
  process(CLK_i)
158
  begin
159
    if(CLK_i = '1' and CLK_i'event) then
160
      if(WE0_ODD = '1') then
161
        REG_ODD(IWA0) <= D0_ODD;
162
      end if;
163
      if(WE1_ODD = '1') then
164
        REG_ODD(IWA1) <= D1_ODD;
165
      end if;
166
    end if;
167
  end process;
168
 
169
  ---------------------------------------------
170
 
171
  IRA0 <= RA0_i/2;
172
  IRA1 <= RA1_i/2;
173
  IRA2 <= RA2_i/2;
174
  IRA3 <= RA3_i/2;
175
 
176
  RA0_LSB <= GET_LSB(RA0_i);
177
  RA1_LSB <= GET_LSB(RA1_i);
178
  RA2_LSB <= GET_LSB(RA2_i);
179
  RA3_LSB <= GET_LSB(RA3_i);
180
 
181
  Q0_EVEN <= REG_EVEN(IRA0);
182
  Q1_EVEN <= REG_EVEN(IRA1);
183
  Q2_EVEN <= REG_EVEN(IRA2);
184
  Q3_EVEN <= REG_EVEN(IRA3);
185
 
186
  Q0_ODD <= REG_ODD(IRA0);
187
  Q1_ODD <= REG_ODD(IRA1);
188
  Q2_ODD <= REG_ODD(IRA2);
189
  Q3_ODD <= REG_ODD(IRA3);
190
 
191
  process(RA0_LSB,LR0_i,Q0_EVEN,Q0_ODD)
192
  begin
193
    if(LR0_i = '0' and RA0_LSB = '1') then
194
      Q0_o(SDLEN-1 downto 0) <= Q0_ODD;
195
    else
196
      Q0_o(SDLEN-1 downto 0) <= Q0_EVEN;
197
    end if;
198
    if(LR0_i = '0') then
199
      Q0_o(SDLEN*2-1 downto SDLEN) <= (others => '0');
200
    else
201
      Q0_o(SDLEN*2-1 downto SDLEN) <= Q0_ODD;
202
    end if;
203
  end process;
204
 
205
  process(RA1_LSB,LR1_i,Q1_EVEN,Q1_ODD)
206
  begin
207
    if(LR1_i = '0' and RA1_LSB = '1') then
208
      Q1_o(SDLEN-1 downto 0) <= Q1_ODD;
209
    else
210
      Q1_o(SDLEN-1 downto 0) <= Q1_EVEN;
211
    end if;
212
    if(LR1_i = '0') then
213
      Q1_o(SDLEN*2-1 downto SDLEN) <= (others => '0');
214
    else
215
      Q1_o(SDLEN*2-1 downto SDLEN) <= Q1_ODD;
216
    end if;
217
  end process;
218
 
219
  process(RA2_LSB,LR2_i,Q2_EVEN,Q2_ODD)
220
  begin
221
    if(LR2_i = '0' and RA2_LSB = '1') then
222
      Q2_o(SDLEN-1 downto 0) <= Q2_ODD;
223
    else
224
      Q2_o(SDLEN-1 downto 0) <= Q2_EVEN;
225
    end if;
226
    if(LR2_i = '0') then
227
      Q2_o(SDLEN*2-1 downto SDLEN) <= (others => '0');
228
    else
229
      Q2_o(SDLEN*2-1 downto SDLEN) <= Q2_ODD;
230
    end if;
231
  end process;
232
 
233
  process(RA3_LSB,LR3_i,Q3_EVEN,Q3_ODD)
234
  begin
235
    if(LR3_i = '0' and RA3_LSB = '1') then
236
      Q3_o(SDLEN-1 downto 0) <= Q3_ODD;
237
    else
238
      Q3_o(SDLEN-1 downto 0) <= Q3_EVEN;
239
    end if;
240
    if(LR3_i = '0') then
241
      Q3_o(SDLEN*2-1 downto SDLEN) <= (others => '0');
242
    else
243
      Q3_o(SDLEN*2-1 downto SDLEN) <= Q3_ODD;
244
    end if;
245
  end process;
246
 
247
end ARC;

powered by: WebSVN 2.1.0

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