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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [techmap/] [maps/] [syncfifo.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
------------------------------------------------------------------------------
2
--  This file is a part of the GRLIB VHDL IP LIBRARY
3
--  Copyright (C) 2003, Gaisler Research
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  This program is distributed in the hope that it will be useful,
11
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
--  GNU General Public License for more details.
14
--
15
--  You should have received a copy of the GNU General Public License
16
--  along with this program; if not, write to the Free Software
17
--  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
18
-----------------------------------------------------------------------------
19
-- Entity:      syncfifo
20
-- File:        syncfifo.vhd
21
-- Author:      Jiri Gaisler - Gaisler Research
22
-- Description: syncronous fifo using syncram_2p
23
------------------------------------------------------------------------------
24
 
25
library ieee;
26
library techmap;
27
use ieee.std_logic_1164.all;
28
use techmap.gencomp.all;
29
library grlib;
30
use grlib.stdlib.all;
31
 
32
entity syncfifo is
33
  generic (tech : integer := 0; abits : integer := 6; dbits : integer := 8;
34
        sepclk : integer := 0; wrfst : integer := 0);
35
  port (
36
    rst      : in std_ulogic;
37
    rclk     : in std_ulogic;
38
    renable  : in std_ulogic;
39
    dataout  : out std_logic_vector((dbits -1) downto 0);
40
    wclk     : in std_ulogic;
41
    write    : in std_ulogic;
42
    datain   : in std_logic_vector((dbits -1) downto 0);
43
    full     : out std_ulogic;
44
    empty    : out std_ulogic
45
  );
46
end;
47
 
48
architecture rtl of syncfifo is
49
 
50
type reg_type is record
51
  raddr, waddr : std_logic_vector(abits downto 0);
52
  full, empty, notempty : std_ulogic;
53
end record;
54
 
55
signal r, rin : reg_type;
56
begin
57
 
58
  comb : process (rst, write, renable, r)
59
  variable v : reg_type;
60
  begin
61
 
62
    v := r;
63
 
64
    if renable = '1' then v.raddr := r.raddr + 1; end if;
65
    if write = '1' then v.waddr := r.waddr + 1; end if;
66
 
67
    if (v.raddr(abits-1) = v.waddr(abits-1)) then
68
      if (v.raddr(abits) = v.waddr(abits)) then
69
        v.full := '0'; v.empty := '1';
70
      else v.full := '1'; v.empty := '0'; end if;
71
    else v.full := '0'; v.empty := '0'; end if;
72
 
73
    if rst = '0' then
74
      v.raddr := (others => '0'); v.waddr := (others => '0');
75
      v.full := '0'; v.empty := '1';
76
    end if;
77
    rin <= v;
78
  end process;
79
 
80
  full <= r.full; empty <= r.empty;
81
 
82
  regs : process (rclk)
83
  begin
84
    if rising_edge(rclk) then
85
      r <= rin;
86
    end if;
87
  end process;
88
 
89
  x0 : syncram_2p generic map (tech, abits, dbits, sepclk)
90
       port map (rclk, renable, r.raddr(abits-1 downto 0), dataout,
91
                 wclk, write, r.waddr(abits-1 downto 0), datain);
92
 
93
end;
94
 

powered by: WebSVN 2.1.0

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