OpenCores
URL https://opencores.org/ocsvn/rv01_riscv_core/rv01_riscv_core/trunk

Subversion Repositories rv01_riscv_core

[/] [rv01_riscv_core/] [trunk/] [VHDL/] [RV01_dimslog.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 madsilicon
-----------------------------------------------------------------
2
--                                                             --
3
-----------------------------------------------------------------
4
--                                                             --
5
-- Copyright (C) 2017 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 Data/Instruction Memory Selection 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_CFG_PKG.all;
40
 
41
entity RV01_DIMSLOG is
42
  generic(
43
    IMEM_LOWM : std_logic := '1';
44
    IMEM_SIZE : natural := 1024*32;
45
    DMEM_SIZE : natural := 1024*16
46
  );
47
  port(
48
    IX1_OPA0_i : in SDWORD_T;
49
    IX1_OPA1_i : in SDWORD_T;
50
    IX1_IMM0_i : in SDWORD_T;
51
    IX1_IMM1_i : in SDWORD_T;
52
    IX1_DADR0_i : in ADR_T;
53
    IX1_DADR1_i : in ADR_T;
54
    IX3_DADR0_i : in ADR_T;
55
 
56
    IX1_DIMS_o : out std_logic_vector(2-1 downto 0);
57
    IX3_DIMS_o : out std_logic
58
  );
59
end RV01_DIMSLOG;
60
 
61
architecture ARC of RV01_DIMSLOG is
62
 
63
  component RV01_COMP32 is
64
    port(
65
      A_i : in std_logic_vector(3-1 downto 0);
66
 
67
      S_o : out std_logic;
68
      C_o : out std_logic
69
    );
70
  end component;
71
 
72
  component RV01_ADDER_F is
73
    generic(
74
      LEN1 : integer := 16;
75
      LEN2 : integer := 16
76
    );
77
    port(
78
      OPA_i : in signed(LEN1+LEN2-1 downto 0);
79
      OPB_i : in signed(LEN1+LEN2-1 downto 0);
80
      CI_i : in std_logic;
81
 
82
      SUM_o : out signed(LEN1+LEN2-1 downto 0)
83
    );
84
  end component;
85
 
86
  subtype B3_T is std_logic_vector(3-1 downto 0);
87
  type D2A_T is array(SDLEN-1 downto 0) of B3_T;
88
 
89
  signal A0,A1 : D2A_T;
90
  signal ZERO : std_logic := '0';
91
  signal MEMSIZE,TMP0,TMP1 : SDWORD_T;
92
  signal S0,C0,S1,C1 : signed(SDLEN downto 0);
93
 
94
begin
95
 
96
  ---------------------------------------------------
97
 
98
  -- Data/Instructions memory selection flags logic
99
  -- (select type of memory referenced by data physical
100
  -- addresses).
101
  --
102
  -- Three flags are generated: two for instructions in
103
  -- stage IX1 (they are needed to process loads) and 
104
  -- one for slot #0 instruction in IX3 stage (this is
105
  -- needed to process stores from the store buffer).
106
 
107
  -- In order to speed-up IX1 selection flags value 
108
  -- generation, instead of subtracting IMEM_SIZE (or
109
  -- DMEM_SIZE) from immediate address (something 
110
  -- requiring two cascaded adders), IMEM_SIZE (or
111
  -- DMEM_SIZE), IX1_OPA*_i and IX1_IMM*_i are summed
112
  -- up using a 3:2 compressing stage followed by a
113
  -- regular adder.
114
 
115
  ---------------------------------------------------
116
 
117
  G1: if IMEM_LOWM = '1' generate
118
 
119
  -- Instruction memory is located in lower portion
120
  -- of address space
121
 
122
  MEMSIZE <= to_signed(-IMEM_SIZE*4,SDLEN);
123
 
124
  -- This is the original code...
125
  --IX1_DIMS_o(0) <= '1' when IX1_DADR0_i/4 >= IMEM_SIZE else '0';
126
 
127
  -- 3:2 compressing stage
128
 
129
  GC0 : for k in 0 to SDLEN-1 generate
130
  A0(k)(0) <= IX1_OPA0_i(k);
131
  A0(k)(1) <= IX1_IMM0_i(k);
132
  A0(k)(2) <= MEMSIZE(k);
133
  U_COMP : RV01_COMP32
134
    port map(
135
      A_i => A0(k),
136
 
137
      S_o => S0(k),
138
      C_o => C0(k+1)
139
    );
140
  end generate;
141
 
142
  S0(SDLEN) <= '0';
143
  C0(0) <= '0';
144
 
145
  -- regular adder 
146
 
147
  TMP0 <= S0(SDLEN-1 downto 0) + C0(SDLEN-1 downto 0);
148
 
149
  IX1_DIMS_o(0) <= not(TMP0(SDLEN-1));
150
 
151
  -- This is the original code...
152
  --IX1_DIMS_o(1) <= '1' when IX1_DADR1_i/4 >= IMEM_SIZE else '0';
153
 
154
  -- 3:2 compressing stage
155
 
156
  GC1 : for k in 0 to SDLEN-1 generate
157
  A1(k)(0) <= IX1_OPA1_i(k);
158
  A1(k)(1) <= IX1_IMM1_i(k);
159
  A1(k)(2) <= MEMSIZE(k);
160
  U_COMP : RV01_COMP32
161
    port map(
162
      A_i => A1(k),
163
 
164
      S_o => S1(k),
165
      C_o => C1(k+1)
166
    );
167
  end generate;
168
 
169
  S1(SDLEN) <= '0';
170
  C1(0) <= '0';
171
 
172
  -- regular adder 
173
 
174
  TMP1 <= S1(SDLEN-1 downto 0) + C1(SDLEN-1 downto 0);
175
 
176
  IX1_DIMS_o(1) <= not(TMP1(SDLEN-1));
177
 
178
  IX3_DIMS_o <= '1' when IX3_DADR0_i/4 >= IMEM_SIZE else '0';
179
 
180
  end generate;
181
 
182
  ---------------------------------------------------
183
 
184
  G0: if IMEM_LOWM = '0' generate
185
 
186
  -- Instruction memory is located in upper portion
187
  -- of address space
188
 
189
  MEMSIZE <= to_signed(-DMEM_SIZE*4,SDLEN);
190
 
191
  -- This is the original code...
192
  --IX1_DIMS_o(0) <= '1' when IX1_DADR0_i/4 < DMEM_SIZE else '0';
193
 
194
  -- 3:2 compressing stage
195
 
196
  GC0 : for k in 0 to SDLEN-1 generate
197
  A0(k)(0) <= IX1_OPA0_i(k);
198
  A0(k)(1) <= IX1_IMM0_i(k);
199
  A0(k)(2) <= MEMSIZE(k);
200
  U_COMP : RV01_COMP32
201
    port map(
202
      A_i => A0(k),
203
 
204
      S_o => S0(k),
205
      C_o => C0(k+1)
206
    );
207
  end generate;
208
 
209
  S0(SDLEN) <= '0';
210
  C0(0) <= '0';
211
 
212
  -- regular adder 
213
 
214
  TMP0 <= S0(SDLEN-1 downto 0) + C0(SDLEN-1 downto 0);
215
 
216
  IX1_DIMS_o(0) <= TMP0(SDLEN-1);
217
 
218
  -- This is the original code...
219
  --IX1_DIMS_o(1) <= '1' when IX1_DADR1_i/4 < DMEM_SIZE else '0';
220
 
221
  -- 3:2 compressing stage
222
 
223
  GC1 : for k in 0 to SDLEN-1 generate
224
  A1(k)(0) <= IX1_OPA1_i(k);
225
  A1(k)(1) <= IX1_IMM1_i(k);
226
  A1(k)(2) <= MEMSIZE(k);
227
  U_COMP : RV01_COMP32
228
    port map(
229
      A_i => A1(k),
230
 
231
      S_o => S1(k),
232
      C_o => C1(k+1)
233
    );
234
  end generate;
235
 
236
  S1(SDLEN) <= '0';
237
  C1(0) <= '0';
238
 
239
  -- regular adder 
240
 
241
  TMP1 <= S1(SDLEN-1 downto 0) + C1(SDLEN-1 downto 0);
242
 
243
  IX1_DIMS_o(1) <= TMP1(SDLEN-1);
244
 
245
  IX3_DIMS_o <= '1' when IX3_DADR0_i/4 < DMEM_SIZE else '0';
246
 
247
  end generate;
248
 
249
  ---------------------------------------------------
250
 
251
end ARC;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.