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/Store 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_LSU 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 |
|
|
OPC_i : in SDWORD_T;
|
47 |
|
|
|
48 |
|
|
DRE_o : out std_logic;
|
49 |
|
|
DWE_o : out std_logic;
|
50 |
|
|
DADR_o : out unsigned(ALEN-1 downto 0);
|
51 |
|
|
DDAT_o : out std_logic_vector(SDLEN-1 downto 0)
|
52 |
|
|
);
|
53 |
|
|
end G729A_ASIP_LSU;
|
54 |
|
|
|
55 |
|
|
architecture ARC of G729A_ASIP_LSU is
|
56 |
|
|
|
57 |
|
|
function to_unsigned(S : signed) return unsigned is
|
58 |
|
|
variable U : unsigned(S'high downto S'low);
|
59 |
|
|
begin
|
60 |
|
|
for i in S'low to S'high loop
|
61 |
|
|
U(i) := S(i);
|
62 |
|
|
end loop;
|
63 |
|
|
return(U);
|
64 |
|
|
end function;
|
65 |
|
|
|
66 |
|
|
signal DRE,DWE : std_logic;
|
67 |
|
|
signal DADR : unsigned(ALEN-1 downto 0);
|
68 |
|
|
signal DDATO : std_logic_vector(SDLEN-1 downto 0);
|
69 |
|
|
|
70 |
|
|
begin
|
71 |
|
|
|
72 |
|
|
process(LS_OP_i,OPA_i,OPB_i,OPC_i)
|
73 |
|
|
variable OPA_LO,OPB_LO,OPC : unsigned(SDLEN-1 downto 0);
|
74 |
|
|
variable TMP : unsigned(SDLEN downto 0);
|
75 |
|
|
begin
|
76 |
|
|
-- WARNING: address is always an unsigned value
|
77 |
|
|
|
78 |
|
|
-- get ID_OPA_q lower half and convert it to unsigned
|
79 |
|
|
OPA_LO := to_unsigned(OPA_i(SDLEN-1 downto 0));
|
80 |
|
|
-- get ID_OPB_q lower half and convert it to unsigned
|
81 |
|
|
OPB_LO := to_unsigned(OPB_i(SDLEN-1 downto 0));
|
82 |
|
|
-- convert ID_OPC_q to unsigned
|
83 |
|
|
OPC := to_unsigned(OPC_i);
|
84 |
|
|
|
85 |
|
|
-- calculate effective address (extra bit prevents overflow)
|
86 |
|
|
if(LS_OP_i = LS_LD) then
|
87 |
|
|
TMP := ('0' & OPA_LO) + ('0' & OPB_LO);
|
88 |
|
|
else
|
89 |
|
|
TMP := ('0' & OPA_LO) + ('0' & OPC);
|
90 |
|
|
end if;
|
91 |
|
|
|
92 |
|
|
DADR <= TMP(ALEN-1 downto 0);
|
93 |
|
|
|
94 |
|
|
end process;
|
95 |
|
|
|
96 |
|
|
DADR_o <= DADR;
|
97 |
|
|
|
98 |
|
|
-- external memory write-enable flag
|
99 |
|
|
DWE <= IV_i when (LS_OP_i = LS_ST) else '0';
|
100 |
|
|
|
101 |
|
|
DWE_o <= DWE;
|
102 |
|
|
|
103 |
|
|
DRE <= IV_i when (LS_OP_i = LS_LD) else '0';
|
104 |
|
|
|
105 |
|
|
-- external memory read-enable flag (debug purpose only)
|
106 |
|
|
DRE_o <= DRE;
|
107 |
|
|
|
108 |
|
|
-- external memory write data
|
109 |
|
|
DDATO <= to_std_logic_vector(OPB_i(SDLEN-1 downto 0));
|
110 |
|
|
|
111 |
|
|
DDAT_o <= DDATO;
|
112 |
|
|
|
113 |
|
|
end ARC;
|