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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [mem/] [cache/] [kecs_wbfifo.vhd] - Blame information for rev 5

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 work.config.all;
8
use work.iface.all;
9
use work.target.all;
10
use work.kecs_config.all;
11
use work.kecs_libiface.all;
12
use work.kecs_libwb.all;
13
use work.kehl_libint.all;
14
use work.tech_map.all;
15
 
16
entity kecs_wbfifo is
17
  generic (
18
    WBBUF_SZ : integer := 2
19
  );
20
  port (
21
    rst : in  std_logic;
22
    clk : in  clk_type;
23
    wbfifoi : in  kcif_ketyp_wbfifo_in;
24
    wbfifoo : out kcif_ketyp_wbfifo_out
25
  );
26
end kecs_wbfifo;
27
 
28
architecture rtl of kecs_wbfifo is
29
 
30
  type kecswbfifo_tmp_type is record
31
     wbfifoo : kcif_ketyp_wbfifo_out;
32
     readint, writeint : std_logic;
33
 
34
  end record;
35
  type kecswbfifo_reg_type is record
36
     buf : kclw_ketyp_entry_a((WBBUF_SZ)-1 downto 0);
37
     cur, set : std_logic_vector((log2(WBBUF_SZ))-1 downto 0);
38
     empty : std_logic;
39
  end record;
40
  type kecswbfifo_dbg_type is record
41
     dummy : std_logic;
42
     -- pragma translate_off
43
     wbaddr : std_logic_vector(31 downto 0);
44
     dbg : kecswbfifo_tmp_type;
45
     -- pragma translate_on
46
  end record;
47
  signal r, c       : kecswbfifo_reg_type;
48
  signal rdbg, cdbg : kecswbfifo_dbg_type;
49
 
50
 
51
begin
52
 
53
  p0: process (clk, rst, r, wbfifoi )
54
    variable v    : kecswbfifo_reg_type;
55
    variable t    : kecswbfifo_tmp_type;
56
    variable vdbg : kecswbfifo_dbg_type;
57
  begin
58
 
59
    -- $(init(t:kecswb_tmp_type))
60
    v := r;
61
 
62
 
63
    --$(del)             wbfifoo.entry_r  
64
    --       +-------+ <-cur   /\
65
    --       | xxxxx |  -------+ 
66
    --       +-------+
67
    --       | xxxxx |
68
    --       +-------+ <-set
69
    --       |       |
70
    --       .       .
71
    --       .       .
72
    --       +-------+
73
    --       |       |
74
    --       +-------+
75
    --$(/del)
76
 
77
    t.wbfifoo.fifo_entry := r.buf(khin_convint(r.cur));
78
    t.wbfifoo.fifo_empty_r := r.empty;
79
 
80
    t.readint := wbfifoi.fifo_read;
81
    t.writeint := wbfifoi.fifo_write;
82
    t.wbfifoo.fifo_stored_v := wbfifoi.fifo_write;
83
 
84
    if t.writeint = '1' then
85
      if r.cur = r.set then
86
        if (r.empty = '0') then
87
          if (wbfifoi.fifo_read = '0') then
88
            t.writeint := '0';
89
            t.wbfifoo.fifo_stored_v := '0';
90
          end if;
91
        end if;
92
      end if;
93
      if t.writeint = '1' then
94
        v.buf(khin_convint(r.set)) := wbfifoi.fifo_entry;
95
        khin_incdec(r.set,v.set,'1','1');
96
        v.empty := '0';
97
      end if;
98
    end if;
99
 
100
    if t.readint = '1' then
101
      khin_incdec(r.cur,v.cur,'1','1');
102
      if v.cur = v.set then
103
        if t.wbfifoo.fifo_stored_v = '0' then
104
          v.empty := '1';
105
        end if;
106
      end if;
107
    end if;
108
 
109
 
110
    -- reset
111
    if ( rst = '0' ) then
112
      v.empty := '1';
113
      v.cur := (others => '0');
114
      v.set := (others => '0');
115
    end if;
116
 
117
    c <= v;
118
 
119
    wbfifoo <= t.wbfifoo;
120
 
121
    -- pragma translate_off
122
    vdbg := rdbg;
123
    vdbg.dbg := t;
124
    cdbg <= vdbg;
125
    -- pragma translate_on  end process p0;
126
 
127
  end process p0;
128
 
129
  pregs : process (clk, c)
130
  begin
131
    if rising_edge(clk) then
132
      r <= c;
133
      -- pragma translate_off
134
      rdbg <= cdbg;
135
      -- pragma translate_on
136
    end if;
137
  end process;
138
 
139
  -- pragma translate_off
140
  check0 : process (clk)
141
  begin
142
    if falling_edge(clk) then
143
      if wbfifoi.fifo_read = '1' then
144
        assert (r.empty = '0') report "Read on empty fifo" severity failure;
145
      end if;
146
    end if;
147
  end process;
148
  -- pragma translate_on  end process p0;
149
 
150
end rtl;
151
 

powered by: WebSVN 2.1.0

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