1 |
2 |
madsilicon |
-----------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-----------------------------------------------------------------
|
4 |
|
|
-- --
|
5 |
|
|
-- Copyright (C) 2015 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 |
|
|
-- RV01 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.RV01_CONSTS_PKG.all;
|
38 |
|
|
use WORK.RV01_TYPES_PKG.all;
|
39 |
|
|
use work.RV01_IDEC_PKG.all;
|
40 |
|
|
use work.RV01_OP_PKG.all;
|
41 |
|
|
|
42 |
|
|
entity RV01_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 RV01_PXLOG;
|
52 |
|
|
|
53 |
|
|
architecture ARC of RV01_PXLOG is
|
54 |
|
|
|
55 |
|
|
function dep_a(RMTCH,IDV,IXV : std_logic;IDI,IXI : DEC_INSTR_T)
|
56 |
|
|
return std_logic is
|
57 |
|
|
begin
|
58 |
|
|
if(
|
59 |
|
|
(RMTCH = '1') and (IDI.RRS1 = '1') and (IXI.WRD = '1')
|
60 |
|
|
) then
|
61 |
|
|
return(IDV and IXV);
|
62 |
|
|
else
|
63 |
|
|
return('0');
|
64 |
|
|
end if;
|
65 |
|
|
end function;
|
66 |
|
|
|
67 |
|
|
function dep_b(RMTCH,IDV,IXV : std_logic;IDI,IXI : DEC_INSTR_T)
|
68 |
|
|
return std_logic is
|
69 |
|
|
begin
|
70 |
|
|
if(
|
71 |
|
|
(RMTCH = '1') and (IDI.RRS2 = '1') and (IXI.WRD = '1')
|
72 |
|
|
) then
|
73 |
|
|
return(IDV and IXV);
|
74 |
|
|
else
|
75 |
|
|
return('0');
|
76 |
|
|
end if;
|
77 |
|
|
end function;
|
78 |
|
|
|
79 |
|
|
signal DATA_DEPA : std_logic;
|
80 |
|
|
signal DATA_DEPB : std_logic;
|
81 |
|
|
signal RMTCH_A_ID0 : std_logic;
|
82 |
|
|
signal RMTCH_B_ID0 : std_logic;
|
83 |
|
|
signal ST0 : std_logic;
|
84 |
|
|
signal ST1 : std_logic;
|
85 |
|
|
|
86 |
|
|
begin
|
87 |
|
|
|
88 |
|
|
----------------------------------------------------
|
89 |
|
|
-- General rules:
|
90 |
|
|
----------------------------------------------------
|
91 |
|
|
|
92 |
|
|
-- Instruction #1 is executed if:
|
93 |
|
|
-- 1) there's no data dependency from instruction #0 AND
|
94 |
|
|
-- 2) it can be executed by pipeline "B" AND
|
95 |
|
|
-- 3) instruction #0 is executed (in-order issue!).
|
96 |
|
|
|
97 |
|
|
-- Condition #3 is actually checked by pipe stall
|
98 |
|
|
-- logic.
|
99 |
|
|
|
100 |
|
|
----------------------------------------------------
|
101 |
|
|
|
102 |
|
|
-- Register match flags
|
103 |
|
|
|
104 |
|
|
-- ID instr. #0 vs. ID instr. #1 register match flags
|
105 |
|
|
-- (when a flag is asserted, there's a match between a
|
106 |
|
|
-- register read by ID instruction #1 and the register
|
107 |
|
|
-- written by ID instruction #0).
|
108 |
|
|
|
109 |
|
|
RMTCH_A_ID0 <= '1' when (ID_INSTR1_i.RS1 = ID_INSTR0_i.RD) else '0';
|
110 |
|
|
RMTCH_B_ID0 <= '1' when (ID_INSTR1_i.RS2 = ID_INSTR0_i.RD) else '0';
|
111 |
|
|
|
112 |
|
|
----------------------------------------------------
|
113 |
|
|
|
114 |
|
|
-- Data dependence flags
|
115 |
|
|
|
116 |
|
|
DATA_DEPA <=
|
117 |
|
|
dep_a(RMTCH_A_ID0,ID_V_i(1),ID_V_i(1),ID_INSTR1_i,ID_INSTR0_i);
|
118 |
|
|
|
119 |
|
|
DATA_DEPB <=
|
120 |
|
|
dep_b(RMTCH_B_ID0,ID_V_i(1),ID_V_i(1),ID_INSTR1_i,ID_INSTR0_i);
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
----------------------------------------------------
|
124 |
|
|
|
125 |
|
|
-- parallel execution (of instr. #1) flag
|
126 |
|
|
|
127 |
|
|
PXE1_o <=
|
128 |
|
|
not(DATA_DEPA or DATA_DEPB) and -- instr. #1 doesn't depend from #0
|
129 |
|
|
not(ID_INSTR1_i.P0_ONLY); -- instr. #1 can execute on pipe #1
|
130 |
|
|
|
131 |
|
|
end;
|
132 |
|
|
|