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

Subversion Repositories esoc

[/] [esoc/] [trunk/] [Sources/] [altera/] [esoc_port_mac/] [testbench/] [model/] [loopback_adapter_fifo.vhd] - Blame information for rev 56

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

Line No. Rev Author Line
1 42 lmaarsen
-- -------------------------------------------------------------------------
2
-- -------------------------------------------------------------------------
3
--
4
-- Revision Control Information
5
--
6
-- $RCSfile: altera_tse_timing_adapter_fifo8.v,v $
7
-- $Source: /ipbu/cvs/sio/projects/TriSpeedEthernet/src/RTL/MAC/mac/timing_adapter/altera_tse_timing_adapter_fifo8.v,v $
8
--
9
-- $Revision: #1 $
10
-- $Date: 2008/08/09 $
11
-- Check in by : $Author: sc-build $
12
-- Author      : SKNg
13
--
14
-- Project     : Triple Speed Ethernet - 10/100/1000 MAC
15
--
16
-- Description : SIMULATION ONLY
17
--
18
-- simple atlantic fifo FOR 8BIT IMPLEMENTATION
19
 
20
-- 
21
-- ALTERA Confidential and Proprietary
22
-- Copyright 2006 (c) Altera Corporation
23
-- All rights reserved
24
--
25
-- -------------------------------------------------------------------------
26
-- -------------------------------------------------------------------------
27
 
28
 
29
 
30
library ieee ;
31
use ieee.std_logic_1164.all ;
32
use ieee.std_logic_arith.all ;
33
use ieee.std_logic_unsigned.all ;
34
 
35
 
36
 
37
 
38
 
39
 ENTITY  loopback_adapter_fifo is
40
 
41
     generic (
42
       DEPTH      : integer := 2048;
43
       DATA_WIDTH : integer := 11;
44
       ADDR_WIDTH : integer := 11
45
     );
46
         PORT
47
         (
48
                 clk            :       IN  STD_LOGIC;
49
                 reset          :       IN  STD_LOGIC;
50
                 in_valid   :   in  std_logic;
51
                 in_data    :   in  std_logic_vector(10 downto 0);
52
                 out_ready      :       IN  STD_LOGIC;
53
 
54
                 in_ready       :       out  STD_LOGIC;
55
                 out_valid  :   out  std_logic;
56
                 out_data   :   out  std_logic_vector(10 downto 0);
57
                 fill_level :   out  std_logic_vector(11 downto 0)
58
         );
59
   end loopback_adapter_fifo;
60
 
61
 
62
 
63
 
64
  architecture behav of loopback_adapter_fifo is
65
 
66
 
67
   -- use array to define the bunch of internal temparary signals
68
 
69
   type ram_type is array (0 to DEPTH-1) of
70
        std_logic_vector(DATA_WIDTH-1 downto 0);
71
   signal mem: ram_type;
72
 
73
   -- ---------------------------------------------------------------------
74
   --| Signals
75
   -- ---------------------------------------------------------------------
76
   signal wr_addr                       : std_logic_vector (ADDR_WIDTH-1 downto 0);
77
   signal rd_addr                       : std_logic_vector (ADDR_WIDTH-1 downto 0);
78
   signal next_wr_addr          : std_logic_vector (ADDR_WIDTH-1 downto 0);
79
   signal next_rd_addr          : std_logic_vector (ADDR_WIDTH-1 downto 0);
80
   signal mem_rd_addr           : std_logic_vector (ADDR_WIDTH-1 downto 0);
81
   signal empty                 : std_logic;
82
   signal full                  : std_logic;
83
   signal out_ready_vector      : std_logic;
84
   signal j                             : integer;
85
   signal enable_reading        : std_logic;
86
   signal out_valid_r   : std_logic;
87
   signal in_ready_r   : std_logic;
88
 
89
 
90
   begin
91
 
92
   -- ---------------------------------------------------------------------
93
   --| FIFO Status
94
   -- ---------------------------------------------------------------------
95
 
96
   process (out_ready,wr_addr,rd_addr,full)
97
   begin
98
      out_ready_vector                                  <= out_ready;
99
      in_ready_r                                        <= not (full);
100
      next_wr_addr                                      <= wr_addr + 1;
101
      next_rd_addr                                      <= rd_addr + 1;
102
      fill_level(ADDR_WIDTH-1 downto 0) <= wr_addr - rd_addr;
103
      fill_level(ADDR_WIDTH)                    <= '0';
104
 
105
      if (full = '1') then
106
           fill_level <= conv_std_logic_vector(DEPTH, 12);
107
          end if;
108
   end process;
109
 
110
  -- ---------------------------------------------------------------------
111
  --| Manage Pointers
112
  -- ---------------------------------------------------------------------
113
  process (reset,clk)
114
   begin
115
     if (reset = '1') then
116
            enable_reading <= '0';
117
     elsif (rising_edge(clk)) then
118
                 if (empty = '1') then
119
                        enable_reading <= '0';
120
             else
121
                  if (in_data(1) = '1' and in_valid = '1') then
122
                   enable_reading <= '1';
123
                  end if;
124
             end if;
125
         end if;
126
   end process;
127
 
128
 
129
 
130
   process (reset,clk)
131
   begin
132
    if (reset = '1') then
133
          wr_addr  <= (others => '0');
134
          rd_addr  <= (others => '0');
135
          empty    <= '1';
136
          rd_addr  <= (others => '0');
137
          full     <= '0';
138
          out_valid_r <= '0';
139
 
140
     elsif (rising_edge(clk)) then
141
 
142
          out_valid_r <= enable_reading;
143
 
144
          if (in_ready_r = '1' and in_valid = '1') then
145
             wr_addr <= next_wr_addr;
146
             empty   <= '0';
147
          end if;
148
 
149
          if (next_wr_addr = rd_addr) then
150
             full <= '1';
151
          end if;
152
 
153
          if (out_ready_vector ='1' and  out_valid_r = '1') then
154
            rd_addr <= next_rd_addr;
155
            full    <= '0';
156
                if (next_rd_addr = wr_addr) then
157
                  empty     <= '1';
158
                  out_valid_r <= '0';
159
                 end if;
160
           end if;
161
 
162
 
163
         if (out_ready_vector = '1' and out_valid_r = '1' and in_ready_r = '1' and in_valid = '1') then
164
           full  <= full;
165
           empty <= empty;
166
          end if;
167
 
168
      end if;
169
   end process;
170
 
171
 
172
   process (rd_addr,out_ready,out_valid_r,next_rd_addr)
173
   begin
174
      mem_rd_addr <= rd_addr;
175
      if (out_ready = '1' and out_valid_r = '1') then
176
        mem_rd_addr <= next_rd_addr;
177
      end if;
178
   end process;
179
 
180
 
181
   --assign output 
182
   out_valid <= out_valid_r;
183
   in_ready <= in_ready_r;
184
 
185
   -- ---------------------------------------------------------------------
186
   --| Infer Memory
187
   -- ---------------------------------------------------------------------
188
   process (reset,clk)
189
   begin
190
      if (reset = '1') then
191
             for i in 0 to (DEPTH-1) loop
192
              mem(conv_integer(i)) <= (others => '0');
193
                 end loop;
194
      elsif (rising_edge(clk)) then
195
 
196
         if (in_ready_r = '1' and in_valid = '1')       then
197
           mem(conv_integer(wr_addr)) <= in_data;
198
                 end if;
199
 
200
         out_data <= mem(conv_integer(mem_rd_addr));
201
      end if;
202
 
203
   end process;
204
 
205
 
206
   end behav;

powered by: WebSVN 2.1.0

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