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 instruction issue 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_ARITH_PKG.all;
|
40 |
|
|
|
41 |
|
|
entity RV01_ISSLOG is
|
42 |
|
|
generic(
|
43 |
|
|
NW : natural := 2
|
44 |
|
|
);
|
45 |
|
|
port(
|
46 |
|
|
V_i : in std_logic_vector(NW-1 downto 0);
|
47 |
|
|
BJX_i : in std_logic;
|
48 |
|
|
PC1_i : in ADR_T;
|
49 |
|
|
PS_i : in std_logic_vector(NW-1 downto 0);
|
50 |
|
|
SBF_i : in std_logic;
|
51 |
|
|
DIV_STRT_i : in std_logic;
|
52 |
|
|
DIV_BSY_i : in std_logic;
|
53 |
|
|
SEQX_i : in std_logic;
|
54 |
|
|
PXE_i : in std_logic;
|
55 |
|
|
PXE1_i : in std_logic;
|
56 |
|
|
STEP_i : in std_logic;
|
57 |
|
|
PSLP_i : in std_logic;
|
58 |
|
|
|
59 |
|
|
V_o : out std_logic_vector(NW-1 downto 0);
|
60 |
|
|
JLRA_o : out ADR_VEC_T(NW-1 downto 0);
|
61 |
|
|
ISSUE_o : out std_logic_vector(NW-1 downto 0)
|
62 |
|
|
);
|
63 |
|
|
end RV01_ISSLOG;
|
64 |
|
|
|
65 |
|
|
architecture ARC of RV01_ISSLOG is
|
66 |
|
|
|
67 |
|
|
signal ISSUE : std_logic_vector(NW-1 downto 0);
|
68 |
|
|
|
69 |
|
|
begin
|
70 |
|
|
|
71 |
|
|
-- Jump & link instructions return address
|
72 |
|
|
|
73 |
|
|
-- J&L instructions need pc(instr0)+4 (coincident
|
74 |
|
|
-- with pc(instr1)) and pc(instr1)+4.
|
75 |
|
|
|
76 |
|
|
JLRA_o(0) <= PC1_i;
|
77 |
|
|
JLRA_o(1) <= PC1_i + 4;
|
78 |
|
|
|
79 |
|
|
-- Instruction issue flags
|
80 |
|
|
|
81 |
|
|
-- Instr. #0 is issued if:
|
82 |
|
|
-- 1) there's no stall due to a data dependencies AND
|
83 |
|
|
-- 2) store buffer is not full AND
|
84 |
|
|
-- 3) no division (multi-cycle operation) is in progress.
|
85 |
|
|
|
86 |
|
|
ISSUE(0) <= '1' when (
|
87 |
|
|
(PS_i(0) = '0') and
|
88 |
|
|
(SBF_i = '0') and
|
89 |
|
|
(PSLP_i = '0') and
|
90 |
|
|
(DIV_STRT_i = '0' and DIV_BSY_i = '0')
|
91 |
|
|
) else '0';
|
92 |
|
|
|
93 |
|
|
-- Instr. #1 is issued if:
|
94 |
|
|
-- 1) there's no stall due to data dependencies AND
|
95 |
|
|
-- 2) isntr. #0 is issued too (in-order issue rule) AND
|
96 |
|
|
-- 3 isntr. #0 doesn't need to be executed sequentially AND
|
97 |
|
|
-- 4) instr #1 can execute in parallel with instr. #1 AND
|
98 |
|
|
-- 5) parallel instruction execution is enabled.
|
99 |
|
|
|
100 |
|
|
--ISSUE(1) <=
|
101 |
|
|
-- not(PS1_i) and
|
102 |
|
|
-- ISSUE(0) and
|
103 |
|
|
-- not(SEQX_i) and
|
104 |
|
|
-- PXE1_i and
|
105 |
|
|
-- PXE_i and
|
106 |
|
|
-- not(STEP_i)
|
107 |
|
|
|
108 |
|
|
-- ...same code of above, but restructured to improve timing.
|
109 |
|
|
|
110 |
|
|
ISSUE(1) <=
|
111 |
|
|
(PXE1_i and PXE_i and not(V_i(0) and SEQX_i) and not(STEP_i))
|
112 |
|
|
when (
|
113 |
|
|
(PS_i(1) = '0') and
|
114 |
|
|
(PSLP_i = '0') and
|
115 |
|
|
(ISSUE(0) = '1')
|
116 |
|
|
) else '0';
|
117 |
|
|
|
118 |
|
|
-- If there's a taken branch, or a jump, in IX1,
|
119 |
|
|
-- instructions in ID are nullified.
|
120 |
|
|
|
121 |
|
|
V_o(0) <= V_i(0) and not(BJX_i) and ISSUE(0);
|
122 |
|
|
V_o(1) <= V_i(1) and not(BJX_i) and ISSUE(1);
|
123 |
|
|
|
124 |
|
|
ISSUE_o <= ISSUE;
|
125 |
|
|
|
126 |
|
|
end ARC;
|