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 Load Unit
|
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_OP_PKG.all;
|
39 |
|
|
|
40 |
|
|
entity G729A_ASIP_LU is
|
41 |
|
|
port(
|
42 |
|
|
IV_i : in std_logic;
|
43 |
|
|
LS_OP_i : in LS_OP_T;
|
44 |
|
|
OPA_i : in LDWORD_T;
|
45 |
|
|
OPB_i : in LDWORD_T;
|
46 |
|
|
|
47 |
|
|
DRE_o : out std_logic;
|
48 |
|
|
DADR_o : out unsigned(ALEN-1 downto 0)
|
49 |
|
|
);
|
50 |
|
|
end G729A_ASIP_LU;
|
51 |
|
|
|
52 |
|
|
architecture ARC of G729A_ASIP_LU is
|
53 |
|
|
|
54 |
|
|
function to_unsigned(S : signed) return unsigned is
|
55 |
|
|
variable U : unsigned(S'high downto S'low);
|
56 |
|
|
begin
|
57 |
|
|
for i in S'low to S'high loop
|
58 |
|
|
U(i) := S(i);
|
59 |
|
|
end loop;
|
60 |
|
|
return(U);
|
61 |
|
|
end function;
|
62 |
|
|
|
63 |
|
|
signal DRE,DWE : std_logic;
|
64 |
|
|
signal DADR : unsigned(ALEN-1 downto 0);
|
65 |
|
|
signal DDATO : std_logic_vector(SDLEN-1 downto 0);
|
66 |
|
|
|
67 |
|
|
begin
|
68 |
|
|
|
69 |
|
|
process(OPA_i,OPB_i)
|
70 |
|
|
variable OPA_LO,OPB_LO : unsigned(SDLEN-1 downto 0);
|
71 |
|
|
variable TMP : unsigned(SDLEN downto 0);
|
72 |
|
|
begin
|
73 |
|
|
-- WARNING: address is always an unsigned value
|
74 |
|
|
|
75 |
|
|
-- get ID_OPA_q lower half and convert it to unsigned
|
76 |
|
|
OPA_LO := to_unsigned(OPA_i(SDLEN-1 downto 0));
|
77 |
|
|
-- get ID_OPB_q lower half and convert it to unsigned
|
78 |
|
|
OPB_LO := to_unsigned(OPB_i(SDLEN-1 downto 0));
|
79 |
|
|
|
80 |
|
|
-- calculate effective address (extra bit prevents overflow)
|
81 |
|
|
TMP := ('0' & OPA_LO) + ('0' & OPB_LO);
|
82 |
|
|
|
83 |
|
|
DADR <= TMP(ALEN-1 downto 0);
|
84 |
|
|
|
85 |
|
|
end process;
|
86 |
|
|
|
87 |
|
|
DADR_o <= DADR;
|
88 |
|
|
|
89 |
|
|
DRE <= IV_i when (LS_OP_i = LS_LD) else '0';
|
90 |
|
|
|
91 |
|
|
-- external memory read-enable flag (debug purpose only)
|
92 |
|
|
DRE_o <= DRE;
|
93 |
|
|
|
94 |
|
|
end ARC;
|