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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [mem/] [cache/] [genwbfifo.vhd] - Blame information for rev 4

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

powered by: WebSVN 2.1.0

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