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 Pipeline eXecution logic
|
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 |
|
|
--use WORK.G729A_ASIP_ARITH_PKG.all;
|
40 |
|
|
use work.G729A_ASIP_IDEC_2W_PKG.all;
|
41 |
|
|
|
42 |
|
|
entity G729A_ASIP_PXLOG is
|
43 |
|
|
port(
|
44 |
|
|
ID_INSTR0_i : in DEC_INSTR_T;
|
45 |
|
|
ID_INSTR1_i : in DEC_INSTR_T;
|
46 |
|
|
ID_V_i : in std_logic_vector(2-1 downto 0);
|
47 |
|
|
ID_FWDE_i : in std_logic_vector(2-1 downto 0);
|
48 |
|
|
|
49 |
|
|
PXE1_o : out std_logic
|
50 |
|
|
);
|
51 |
|
|
end G729A_ASIP_PXLOG;
|
52 |
|
|
|
53 |
|
|
architecture ARC of G729A_ASIP_PXLOG is
|
54 |
|
|
|
55 |
|
|
function plus1(A : RID_T) return RID_T is
|
56 |
|
|
variable UA1,UA2 : unsigned(4-1 downto 0);
|
57 |
|
|
begin
|
58 |
|
|
UA1 := to_unsigned(A,4);
|
59 |
|
|
UA2 := UA1(4-1 downto 1) & '1';
|
60 |
|
|
return(to_integer(UA2));
|
61 |
|
|
end function;
|
62 |
|
|
|
63 |
|
|
function rmtch_a(IDI,IXI : DEC_INSTR_T; RAP1,RDP1 : RID_T) return std_logic is
|
64 |
|
|
begin
|
65 |
|
|
if(
|
66 |
|
|
(IDI.RA = IXI.RD) or
|
67 |
|
|
(IDI.LA = '1' and (RAP1 = IXI.RD)) or
|
68 |
|
|
(IXI.LD = '1' and (IDI.RA = RDP1))
|
69 |
|
|
) then
|
70 |
|
|
return('1');
|
71 |
|
|
else
|
72 |
|
|
return('0');
|
73 |
|
|
end if;
|
74 |
|
|
end function;
|
75 |
|
|
|
76 |
|
|
function rmtch_b(IDI,IXI : DEC_INSTR_T; RBP1,RDP1 : RID_T)
|
77 |
|
|
return std_logic is
|
78 |
|
|
begin
|
79 |
|
|
if(
|
80 |
|
|
(IDI.RB = IXI.RD) or
|
81 |
|
|
(IDI.LB = '1' and (RBP1 = IXI.RD)) or
|
82 |
|
|
(IXI.LD = '1' and (IDI.RB = RDP1))
|
83 |
|
|
) then
|
84 |
|
|
return('1');
|
85 |
|
|
else
|
86 |
|
|
return('0');
|
87 |
|
|
end if;
|
88 |
|
|
end function;
|
89 |
|
|
|
90 |
|
|
function dep_a(RMTCH,IDV,IXV : std_logic;IDI,IXI : DEC_INSTR_T)
|
91 |
|
|
return std_logic is
|
92 |
|
|
begin
|
93 |
|
|
if(
|
94 |
|
|
(RMTCH = '1') and (IDI.RRA = '1') and (IXI.WRD = '1')
|
95 |
|
|
) then
|
96 |
|
|
return(IDV and IXV);
|
97 |
|
|
else
|
98 |
|
|
return('0');
|
99 |
|
|
end if;
|
100 |
|
|
end function;
|
101 |
|
|
|
102 |
|
|
function dep_b(RMTCH,IDV,IXV : std_logic;IDI,IXI : DEC_INSTR_T)
|
103 |
|
|
return std_logic is
|
104 |
|
|
begin
|
105 |
|
|
if(
|
106 |
|
|
(RMTCH = '1') and (IDI.RRB = '1') and (IXI.WRD = '1')
|
107 |
|
|
) then
|
108 |
|
|
return(IDV and IXV);
|
109 |
|
|
else
|
110 |
|
|
return('0');
|
111 |
|
|
end if;
|
112 |
|
|
end function;
|
113 |
|
|
|
114 |
|
|
function stall_a(DEP,FWDE,IX_2C : std_logic;IDI,IXI : DEC_INSTR_T)
|
115 |
|
|
return std_logic is
|
116 |
|
|
begin
|
117 |
|
|
if(
|
118 |
|
|
(DEP = '1') and ((FWDE = '0') or (IX_2C = '1') or (IDI.LA /= IXI.LD))
|
119 |
|
|
) then
|
120 |
|
|
return('1');
|
121 |
|
|
else
|
122 |
|
|
return('0');
|
123 |
|
|
end if;
|
124 |
|
|
end function;
|
125 |
|
|
|
126 |
|
|
function stall_b(DEP,FWDE,IX_2C : std_logic;IDI,IXI : DEC_INSTR_T)
|
127 |
|
|
return std_logic is
|
128 |
|
|
begin
|
129 |
|
|
if(
|
130 |
|
|
(DEP = '1') and ((FWDE = '0') or (IX_2C = '1') or (IDI.LB /= IXI.LD))
|
131 |
|
|
) then
|
132 |
|
|
return('1');
|
133 |
|
|
else
|
134 |
|
|
return('0');
|
135 |
|
|
end if;
|
136 |
|
|
end function;
|
137 |
|
|
|
138 |
|
|
signal RAP1,RBP1 : RID_T;
|
139 |
|
|
signal RDP1 : RID_T;
|
140 |
|
|
signal DATA_DEPA : std_logic;
|
141 |
|
|
signal DATA_DEPB : std_logic;
|
142 |
|
|
signal RMTCH_A_ID0 : std_logic;
|
143 |
|
|
signal RMTCH_B_ID0 : std_logic;
|
144 |
|
|
signal MAC0,MAC1 : std_logic;
|
145 |
|
|
|
146 |
|
|
begin
|
147 |
|
|
|
148 |
|
|
----------------------------------------------------
|
149 |
|
|
-- General rules:
|
150 |
|
|
----------------------------------------------------
|
151 |
|
|
|
152 |
|
|
-- Instruction #0 is executed if:
|
153 |
|
|
-- 1) there's no data dependency from instructions
|
154 |
|
|
-- in IX1 and IX2 stages.
|
155 |
|
|
|
156 |
|
|
-- Instruction #1 is executed if:
|
157 |
|
|
-- 1) there's no data dependency from instructions
|
158 |
|
|
-- in IX1 and IX2 stages.
|
159 |
|
|
-- 2) it's doesn't need instruction #0 result, AND
|
160 |
|
|
-- 3) it can be executed by pipeline "A" (i.e. it's
|
161 |
|
|
-- a forward-enabled instruction) AND
|
162 |
|
|
-- 4) instruction #0 is executed (in-order issue!).
|
163 |
|
|
|
164 |
|
|
-- Condition 1) is checked by pipe stalling logic
|
165 |
|
|
-- and therefore this module assumes no stall occurs.
|
166 |
|
|
|
167 |
|
|
----------------------------------------------------
|
168 |
|
|
|
169 |
|
|
-- Note: when a long result is needed/generated,
|
170 |
|
|
-- register id. RX is always an even one, and therefore
|
171 |
|
|
-- RX+1 can be generated simply setting LSb to '1'.
|
172 |
|
|
|
173 |
|
|
-- ID instr. #1 RA+1
|
174 |
|
|
RAP1 <= plus1(ID_INSTR1_i.RA);
|
175 |
|
|
|
176 |
|
|
-- ID instr. #1 RB+1
|
177 |
|
|
RBP1 <= plus1(ID_INSTR1_i.RB);
|
178 |
|
|
|
179 |
|
|
-- IX1 instr. #0 RD+1
|
180 |
|
|
RDP1 <= plus1(ID_INSTR0_i.RD);
|
181 |
|
|
|
182 |
|
|
----------------------------------------------------
|
183 |
|
|
|
184 |
|
|
-- Register match flags
|
185 |
|
|
|
186 |
|
|
-- ID instr. #0 vs. ID instr. #1 register match flags
|
187 |
|
|
-- (when a flag is asserted, there's a match between a
|
188 |
|
|
-- register read by ID instruction #1 and the register
|
189 |
|
|
-- written by ID instruction #0).
|
190 |
|
|
-- Three possible cases must be checked:
|
191 |
|
|
-- 1) ID instruction #1 needs a short (long) result and
|
192 |
|
|
-- ID instruction #0 generates a short (long) one ->
|
193 |
|
|
-- comparing RA/B to RD is enough.
|
194 |
|
|
-- 2) ID instruction #1 needs a long result and ID
|
195 |
|
|
-- instruction #0 generates a short one -> RD must be
|
196 |
|
|
-- compared to RA/B and (RA/B)+1.
|
197 |
|
|
-- 3) ID instruction #1 needs a short result and ID
|
198 |
|
|
-- instruction #0 generates a long one -> RA/B must be
|
199 |
|
|
-- compared to RD and (RD)+1.
|
200 |
|
|
|
201 |
|
|
RMTCH_A_ID0 <= rmtch_a(ID_INSTR1_i,ID_INSTR0_i,RAP1,RDP1);
|
202 |
|
|
RMTCH_B_ID0 <= rmtch_b(ID_INSTR1_i,ID_INSTR0_i,RBP1,RDP1);
|
203 |
|
|
|
204 |
|
|
----------------------------------------------------
|
205 |
|
|
|
206 |
|
|
-- Data dependence flags
|
207 |
|
|
|
208 |
|
|
DATA_DEPA <=
|
209 |
|
|
dep_a(RMTCH_A_ID0,ID_V_i(1),ID_V_i(1),ID_INSTR1_i,ID_INSTR0_i);
|
210 |
|
|
|
211 |
|
|
DATA_DEPB <=
|
212 |
|
|
dep_b(RMTCH_B_ID0,ID_V_i(1),ID_V_i(1),ID_INSTR1_i,ID_INSTR0_i);
|
213 |
|
|
|
214 |
|
|
----------------------------------------------------
|
215 |
|
|
|
216 |
|
|
-- MAC instruction flags
|
217 |
|
|
|
218 |
|
|
MAC0 <= '1' when(
|
219 |
|
|
(ID_INSTR0_i.IMNMC = IM_LMAC) or
|
220 |
|
|
(ID_INSTR0_i.IMNMC = IM_LMACI) or
|
221 |
|
|
(ID_INSTR0_i.IMNMC = IM_LMSU) or
|
222 |
|
|
(ID_INSTR0_i.IMNMC = IM_LMSUI) or
|
223 |
|
|
(ID_INSTR0_i.IMNMC = IM_WACC)
|
224 |
|
|
) else '0';
|
225 |
|
|
|
226 |
|
|
MAC1 <= '1' when(
|
227 |
|
|
(ID_INSTR1_i.IMNMC = IM_LMAC) or
|
228 |
|
|
(ID_INSTR1_i.IMNMC = IM_LMACI) or
|
229 |
|
|
(ID_INSTR1_i.IMNMC = IM_LMSU) or
|
230 |
|
|
(ID_INSTR1_i.IMNMC = IM_LMSUI) or
|
231 |
|
|
(ID_INSTR0_i.IMNMC = IM_WACC)
|
232 |
|
|
) else '0';
|
233 |
|
|
|
234 |
|
|
----------------------------------------------------
|
235 |
|
|
|
236 |
|
|
-- parallel execution (of instr. #1) flag
|
237 |
|
|
|
238 |
|
|
PXE1_o <=
|
239 |
|
|
not(DATA_DEPA or DATA_DEPB) and -- instr. #1 doesn't depend from #0
|
240 |
|
|
ID_FWDE_i(1) and -- instr. #1 can execute on pipe #1
|
241 |
|
|
not(MAC0 and MAC1); -- instr. #0 and #1 are not both of MAC-type
|
242 |
|
|
|
243 |
|
|
end;
|
244 |
|
|
|