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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [mem/] [cache/] [genic.vhd] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tarookumic
-- $(lic)
2
-- $(help_generic)
3
-- $(help_local)
4
 
5
library ieee;
6
use ieee.std_logic_1164.all;
7
use IEEE.std_logic_unsigned.conv_integer;
8
use IEEE.std_logic_arith.conv_unsigned;
9
use work.config.all;
10
use work.int.all;
11
use work.memdef.all;
12
use work.corelib.all;
13
use work.cache_comp.all;
14
use work.cache_config.all;
15
use work.genic_lib.all;
16
use work.gencmem_lib.all;
17
use work.bus_comp.all;
18
 
19
entity genic is
20
  port (
21
    rst     : in  std_logic;
22
    clk     : in  std_logic;
23
    hold : in cli_hold;
24
    i    : in  genic_type_in;
25
    o    : out genic_type_out;
26
    ctrl : in gicl_ctrl;
27
    icmo : in gencmem_type_ic_out;
28
    icmi : out gencmem_type_ic_in;
29
    mcio : in ahbmst_mp_out;
30
    mcii : out ahbmst_mp_in
31
    );
32
end genic;
33
 
34
architecture rtl of genic is
35
 
36
  type genic_datasrc is (genic_mem,genic_cmem);
37
  type genic_tmp_type is record
38
    hit ,valid  : std_logic;
39
    set  : integer;
40
    pos  : integer;
41
    setrep : integer;
42
    sethit  : std_logic_vector(CFG_IC_SETS-1 downto 0);
43
    setvalid   : std_logic_vector(CFG_IC_SETS-1 downto 0);
44
    icmi      : gencmem_type_ic_in;
45
    o  : genic_type_out;
46
    datasrc  : genic_datasrc;
47
    ehold, reqinsn, branch : std_logic;
48
    twrite, dwrite : std_logic;
49
    newvalid : std_logic_vector(CFG_IC_TLINE_SZ-1 downto 0);
50
    mcii  : ahbmst_mp_in;
51
  end record;
52
  type genic_state is (genic_hit,genic_pempty,genic_stream,genic_pfull,genic_waitwrite);
53
  type genic_reg_type is record
54
    setrep : std_logic_vector(lin_log2x(CFG_IC_SETS)-1 downto 0);
55
    state : genic_state;
56
    hold : std_logic;
57
    hit : std_logic;
58
    mcii  : ahbmst_mp_in;
59
    faddr : std_logic_vector(GCML_IC_TADDR_BSZ-1 downto 0);
60
    ready_addr  : std_logic_vector(31 downto 0);
61
    --flush, fluship : std_logic;
62
  end record;
63
  type genic_dbg_type is record
64
     dummy : std_logic;
65
     -- pragma translate_off
66
     dbg : genic_tmp_type;
67
     -- pragma translate_on
68
  end record;
69
  signal r, c       : genic_reg_type;
70
  signal rdbg, cdbg : genic_dbg_type;
71
 
72
begin
73
 
74
  p0: process (clk, rst, r, hold, i, icmo, mcio, ctrl )
75
    variable v    : genic_reg_type;
76
    variable t    : genic_tmp_type;
77
    variable vdbg : genic_dbg_type;
78
  begin
79
 
80
    -- $(init(t:genic_tmp_type))
81
 
82
    v := r;
83
 
84
    -- todo: use part of with mcii.address
85
    -- lin_incdec(t.ahbo.haddr(4 downto 2),t.ahbo.haddr(4 downto 2),'1','1');
86
    t.icmi.addr := r.ready_addr;
87
 
88
    t.datasrc := genic_mem;
89
    t.ehold :=  hold.dhold;
90
    t.reqinsn := not (t.ehold or i.annul);
91
    t.branch := i.bra_v;
92
    t.twrite := '0';
93
    t.dwrite := '0';
94
 
95
    t.o.mstrobe := '0';
96
 
97
    -- cmp
98
    t.hit := '0';
99
    t.set := 0;
100
    for j in CFG_IC_SETS-1 downto 0 loop
101
      if gicl_is_taghit(i.pc_r,icmo.tag_line(j)) then
102
        t.hit := '1';
103
        t.sethit(j) := '1';
104
        t.set := j;
105
      end if;
106
    end loop;
107
 
108
    t.valid := '0';
109
    if gicl_is_linevalid(i.pc_r,icmo.tag_line(t.set)) then
110
      t.valid := '1';
111
    end if;
112
 
113
    -- next addr
114
    if mcio.ready = '1' then
115
      v.ready_addr := r.mcii.address;
116
    end if;
117
 
118
    -- state
119
    case r.state is
120
      when genic_hit =>
121
 
122
        t.icmi.addr := i.pc_v;
123
        t.datasrc := genic_cmem;
124
        v.hold := '0';
125
 
126
        -- remove: 
127
        v.mcii.burst := ctrl.burst;
128
        if gicl_is_onetogo(i.pc_r) then
129
          v.mcii.burst := '0';
130
        end if;
131
        v.hit := t.hit;
132
 
133
        if t.reqinsn = '1' then
134
          if (not (t.hit and t.valid)) = '1' then
135
            v.hold := '1';
136
            v.state := genic_pempty;
137
            v.mcii.req := '1';
138
          end if;
139
          v.mcii.address := i.pc_r;
140
          -- todo: use part of with mcii.address
141
          v.ready_addr := i.pc_r;
142
        end if;
143
 
144
        v.setrep := std_logic_vector(conv_unsigned(t.set, lin_log2x(CFG_IC_SETS)));
145
 
146
      when genic_pempty =>
147
 
148
        if mcio.ready = '1' then
149
          t.o.mstrobe := '1';
150
          if i.bra_r = '1' then
151
            v.state := genic_pfull;
152
          else
153
            v.state := genic_stream;
154
            v.hold := '0';
155
          end if;
156
        end if;
157
 
158
        t.branch := i.bra_r;
159
 
160
      when genic_stream =>
161
 
162
        if t.reqinsn = '1' then
163
          if mcio.ready = '0' then
164
            v.hold := '1';
165
            v.state := genic_pempty;
166
          else
167
            if i.bra_v = '1' then
168
              v.hold := '1';
169
              v.state := genic_pfull;
170
            end if;
171
          end if;
172
        else
173
          if mcio.ready = '1' then
174
            v.hold := '1';
175
            v.state := genic_pfull;
176
          end if;
177
        end if;
178
 
179
      when genic_pfull =>
180
 
181
      when genic_waitwrite =>
182
 
183
        v.state := genic_hit;
184
        t.icmi.addr := i.pc_r;
185
        v.hold := '0';
186
 
187
      when others =>
188
    end case;
189
 
190
    -- next req
191
    if mcio.grant = '1' then
192
      v.mcii.burst := ctrl.burst;
193
      v.mcii.req := r.mcii.burst;
194
      lin_incdec(r.mcii.address(31 downto 2), v.mcii.address(31 downto 2),'1','1');
195
      if gicl_is_onetogo(r.mcii.address) then
196
        v.mcii.burst := '0';
197
        if mcio.ready = '1' then
198
          v.mcii.req := '0';
199
        end if;
200
      end if;
201
      if (t.branch   = '1') then
202
        v.mcii.burst := '0';
203
        v.mcii.req := '0';
204
      end if;
205
    end if;
206
 
207
    -- finish
208
    if (mcio.ready = '1') and (r.mcii.req = '0') then
209
      --v.flush := r.fluship;
210
      v.state := genic_waitwrite;
211
      v.hold := '1';
212
    end if;
213
 
214
    -- memdata returned
215
    if mcio.ready = '1' then
216
      t.twrite := '1';
217
      t.dwrite := '1';
218
    end if;
219
 
220
    -- retry
221
    if mcio.retry = '1' then
222
      v.mcii.req := '1';
223
      v.mcii.address := r.ready_addr;
224
    end if;
225
 
226
    -- mexc
227
    if (mcio.mexc or not mcio.cache) = '1' then
228
      t.twrite := '0';
229
      t.dwrite := '0';
230
    else
231
      t.dwrite := t.twrite;
232
    end if;
233
 
234
    -- return data
235
    t.o.dat_line_v := icmo.dat_line(t.set);
236
    if CFG_IC_DLINE_SZ = 1 then
237
      t.pos := 0;
238
    else
239
      t.pos := lin_convint(r.ready_addr(GICL_TLINE_U downto GICL_TLINE_D));
240
    end if;
241
    case t.datasrc is
242
      when genic_mem    => t.o.dat_line_v.data(t.pos) := mcio.data;
243
      when genic_cmem   => t.o.dat_line_v := icmo.dat_line(t.set);
244
      when others =>
245
    end case;
246
 
247
    -- assemble input tag line
248
    t.setrep := lin_convint(r.setrep);
249
    t.icmi.tag_line := icmo.tag_line(t.setrep);
250
    t.newvalid := lin_decode(r.ready_addr(GICL_TLINE_U downto GICL_TLINE_D));
251
    if r.hit = '1' then
252
      t.icmi.tag_line.valid := t.icmi.tag_line.valid or t.newvalid;
253
    else
254
      t.icmi.tag_line.valid := t.newvalid;
255
    end if;
256
    t.icmi.tag_line.tag := r.ready_addr(GICL_TTAG_U downto GICL_TTAG_D);
257
    t.icmi.tag_write(t.setrep) := t.twrite;
258
 
259
    -- assemble input data line
260
    t.icmi.dat_line := icmo.dat_line(t.setrep);
261
    t.icmi.dat_line.data(t.pos) := mcio.data;
262
    t.icmi.dat_write(t.setrep) := t.dwrite;
263
 
264
    -- flush
265
    --if r.fluship = '1' then
266
    --  t.icmi.tag_write := (others => '1');
267
    --  t.icmi.addr(GICL_TADDR_U downto GICL_TADDR_D) := r.faddr;
268
    --  t.icmi.tag_line.tag := (others => '0');
269
    --  t.icmi.tag_line.valid := (others => '0');
270
    --  lin_incdec(r.faddr, v.faddr,'1','1');
271
    --  if (r.faddr(GICL_TADDR_U) and not v.faddr(GICL_TADDR_U)) = '1' then
272
    --  v.fluship := '0';
273
    --  end if;
274
    --end if;
275
 
276
    -- reset
277
    if ( rst = '0' ) then
278
      v.state := genic_hit;
279
      v.hold := '0';
280
      v.mcii.req := '0';
281
      --v.flush := '0';
282
      --v.fluship := '0';
283
    end if;
284
 
285
    t.o.hold := r.hold;
286
    t.mcii := r.mcii;
287
    t.mcii.read := '1';
288
    t.mcii.lock := '0';
289
    v.mcii.size := lmd_word;
290
    t.mcii.data := (others => '0');
291
 
292
    c <= v;
293
 
294
    icmi <= t.icmi;
295
    o  <= t.o;
296
    mcii <= t.mcii;
297
 
298
    -- pragma translate_off
299
    vdbg := rdbg;
300
    vdbg.dbg := t;
301
    cdbg <= vdbg;
302
    -- pragma translate_on  end process p0;
303
 
304
  end process p0;
305
 
306
  pregs : process (clk, c)
307
  begin
308
    if rising_edge(clk) then
309
      r <= c;
310
      -- pragma translate_off
311
      rdbg <= cdbg;
312
      -- pragma translate_on
313
    end if;
314
  end process;
315
 
316
end rtl;
317
 

powered by: WebSVN 2.1.0

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