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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [rtl/] [vlib/] [memlib/] [fifo_1c_dram_raw.vhd] - Blame information for rev 13

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

Line No. Rev Author Line
1 13 wfjm
-- $Id: fifo_1c_dram_raw.vhd 421 2011-11-07 21:23:50Z mueller $
2 2 wfjm
--
3 13 wfjm
-- Copyright 2007-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 2 wfjm
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
--
14
------------------------------------------------------------------------------
15
-- Module Name:    fifo_1c_dram_raw - syn
16
-- Description:    FIFO, single clock domain, distributed RAM based, 'raw'
17
--                 interface exposing dram signals.
18
--
19
-- Dependencies:   ram_1swar_1ar_gen
20
--
21
-- Test bench:     tb/tb_fifo_1c_dram
22
-- Target Devices: generic Spartan, Virtex
23 13 wfjm
-- Tool versions:  xst 8.2, 9.1, 9.2, 13.1; ghdl 0.18-0.29
24 2 wfjm
-- Revision History: 
25
-- Date         Rev Version  Comment
26 13 wfjm
-- 2011-11-07   421   1.0.2  now numeric_std clean
27 2 wfjm
-- 2007-10-12    88   1.0.1  avoid ieee.std_logic_unsigned, use cast to unsigned
28
-- 2007-06-03    47   1.0    Initial version 
29
------------------------------------------------------------------------------
30
 
31
library ieee;
32
use ieee.std_logic_1164.all;
33 13 wfjm
use ieee.numeric_std.all;
34 2 wfjm
 
35
use work.slvtypes.all;
36
use work.memlib.all;
37
 
38
entity fifo_1c_dram_raw is              -- fifo, 1 clock, dram based, raw
39
  generic (
40
    AWIDTH : positive :=  4;            -- address width (sets size)
41
    DWIDTH : positive := 16);           -- data width
42
  port (
43
    CLK : in slbit;                     -- clock
44
    RESET : in slbit;                   -- reset
45
    WE : in slbit;                      -- write enable
46
    RE : in slbit;                      -- read enable
47
    DI : in slv(DWIDTH-1 downto 0);     -- input data
48
    DO : out slv(DWIDTH-1 downto 0);    -- output data
49
    SIZE : out slv(AWIDTH-1 downto 0);  -- number of used slots
50
    EMPTY : out slbit;                  -- empty flag
51
    FULL : out slbit                    -- full flag
52
  );
53
end fifo_1c_dram_raw;
54
 
55
 
56
architecture syn of fifo_1c_dram_raw is
57
 
58
  type regs_type is record
59
    waddr : slv(AWIDTH-1 downto 0);     -- write address
60
    raddr : slv(AWIDTH-1 downto 0);     -- read address
61
    empty : slbit;                      -- empty flag
62
    full  : slbit;                      -- full flag
63
  end record regs_type;
64
 
65
  constant memsize : positive := 2**AWIDTH;
66
  constant regs_init : regs_type := (
67 13 wfjm
    slv(to_unsigned(0,AWIDTH)),         -- waddr
68
    slv(to_unsigned(0,AWIDTH)),         -- raddr
69
    '1','0'                             -- empty,full
70 2 wfjm
  );
71
 
72
  signal R_REGS : regs_type := regs_init;  -- state registers
73
  signal N_REGS : regs_type := regs_init;  -- next value state regs
74
 
75
  signal RAM_WE : slbit := '0';
76
 
77
begin
78
 
79
  RAM : ram_1swar_1ar_gen
80
    generic map (
81
      AWIDTH => AWIDTH,
82
      DWIDTH => DWIDTH)
83
    port map (
84
      CLK   => CLK,
85
      WE    => RAM_WE,
86
      ADDRA => R_REGS.waddr,
87
      ADDRB => R_REGS.raddr,
88
      DI    => DI,
89
      DOA   => open,
90
      DOB   => DO
91
    );
92
 
93
  proc_regs: process (CLK)
94
  begin
95
 
96 13 wfjm
    if rising_edge(CLK) then
97 2 wfjm
      R_REGS <= N_REGS;
98
    end if;
99
 
100
  end process proc_regs;
101
 
102
  proc_next: process (R_REGS, RESET, WE, RE)
103
 
104
    variable r : regs_type := regs_init;
105
    variable n : regs_type := regs_init;
106
 
107
    variable isize : slv(AWIDTH-1 downto 0) := (others=>'0');
108
 
109
    variable we_val : slbit := '0';
110
    variable re_val : slbit := '0';
111
    variable iram_we : slbit := '0';
112
 
113
  begin
114
 
115
    r := R_REGS;
116
    n := R_REGS;
117
 
118
    re_val := RE and not r.empty;
119
    we_val := WE and ((not r.full) or RE);
120 13 wfjm
    isize := slv(unsigned(r.waddr) - unsigned(r.raddr));
121 2 wfjm
    iram_we := '0';
122
 
123
    if RESET = '1' then
124
      n := regs_init;
125
 
126
    else
127
 
128
      if we_val = '1' then
129 13 wfjm
        n.waddr := slv(unsigned(r.waddr) + 1);
130 2 wfjm
        iram_we := '1';
131
        if re_val = '0' then
132
          n.empty := '0';
133
          if unsigned(isize) = memsize-1 then
134
            n.full := '1';
135
          end if;
136
        end if;
137
      end if;
138
 
139
      if re_val = '1' then
140 13 wfjm
        n.raddr := slv(unsigned(r.raddr) + 1);
141 2 wfjm
        if we_val = '0' then
142
          n.full := '0';
143
          if unsigned(isize) = 1 then
144
            n.empty := '1';
145
          end if;
146
        end if;
147
      end if;
148
 
149
    end if;
150
 
151
    N_REGS <= n;
152
 
153
    RAM_WE <= iram_we;
154
 
155
    SIZE  <= isize;
156
    EMPTY <= r.empty;
157
    FULL  <= r.full;
158
 
159
  end process proc_next;
160
 
161
end syn;

powered by: WebSVN 2.1.0

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