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

Subversion Repositories esoc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 42 lmaarsen
-- -------------------------------------------------------------------------
2
-- -------------------------------------------------------------------------
3
--
4
-- Revision Control Information
5
--
6
-- $RCSfile: timing_adapter_fifo_8.vhd,v $
7
-- $Source: /ipbu/cvs/sio/projects/TriSpeedEthernet/src/testbench/models/vhdl/ethernet_model/gen/timing_adapter_8_fifo.vhd,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
 
31
library ieee ;
32
use ieee.std_logic_1164.all ;
33
use ieee.std_logic_arith.all ;
34
use ieee.std_logic_unsigned.all ;
35
 
36
 
37
 
38
 
39
 
40
 ENTITY  timing_adapter_fifo_8 is
41
 
42
     generic (
43
       DEPTH      : integer := 64;
44
       DATA_WIDTH : integer := 11;
45
       ADDR_WIDTH : integer := 6
46
     );
47
         PORT
48
         (
49
                 clk            :       IN  STD_LOGIC;
50
                 reset          :       IN  STD_LOGIC;
51
                 in_valid   :   in  std_logic;
52
                 in_data    :   in  std_logic_vector(10 downto 0);
53
                 out_ready      :       IN  STD_LOGIC;
54
 
55
                 in_ready       :       out  STD_LOGIC;
56
                 out_valid  :   out  std_logic;
57
                 out_data   :   out  std_logic_vector(10 downto 0);
58
                 fill_level :   out  std_logic_vector(6 downto 0)
59
         );
60
   end timing_adapter_fifo_8;
61
 
62
 
63
 
64
 
65
  architecture behav of timing_adapter_fifo_8 is
66
 
67
 
68
   -- use array to define the bunch of internal temparary signals
69
 
70
   type ram_type is array (0 to DEPTH-1) of
71
        std_logic_vector(DATA_WIDTH-1 downto 0);
72
   signal mem: ram_type;
73
 
74
   -- ---------------------------------------------------------------------
75
   --| Signals
76
   -- ---------------------------------------------------------------------
77
   signal wr_addr                       : std_logic_vector (ADDR_WIDTH-1 downto 0);
78
   signal rd_addr                       : std_logic_vector (ADDR_WIDTH-1 downto 0);
79
   signal next_wr_addr          : std_logic_vector (ADDR_WIDTH-1 downto 0);
80
   signal next_rd_addr          : std_logic_vector (ADDR_WIDTH-1 downto 0);
81
   signal mem_rd_addr           : std_logic_vector (ADDR_WIDTH-1 downto 0);
82
   signal empty                 : std_logic;
83
   signal full                  : std_logic;
84
   signal out_ready_vector      : std_logic;
85
   signal out_valid_r   : std_logic;
86
   signal in_ready_r   : std_logic;
87
 
88
 
89
   begin
90
 
91
   -- ---------------------------------------------------------------------
92
   --| FIFO Status
93
   -- ---------------------------------------------------------------------
94
 
95
   process (out_ready,wr_addr,rd_addr,full)
96
   begin
97
      out_ready_vector                                  <= out_ready;
98
      in_ready_r                                        <= not (full);
99
      next_wr_addr                                      <= wr_addr + 1;
100
      next_rd_addr                                      <= rd_addr + 1;
101
      fill_level(ADDR_WIDTH-1 downto 0) <= wr_addr - rd_addr;
102
      fill_level(ADDR_WIDTH)                    <= '0';
103
 
104
      if (full = '1') then
105
           fill_level <= conv_std_logic_vector(DEPTH, 7);
106
          end if;
107
   end process;
108
 
109
  -- ---------------------------------------------------------------------
110
  --| Manage Pointers
111
  -- ---------------------------------------------------------------------
112
 
113
   process (reset,clk)
114
   begin
115
    if (reset = '1') then
116
          wr_addr  <= (others => '0');
117
          rd_addr  <= (others => '0');
118
          empty    <= '1';
119
          rd_addr  <= (others => '0');
120
          full     <= '0';
121
          out_valid_r <= '0';
122
 
123
     elsif (rising_edge(clk)) then
124
 
125
          out_valid_r <= not (empty);
126
 
127
          if (in_ready_r = '1' and in_valid = '1') then
128
             wr_addr <= next_wr_addr;
129
             empty   <= '0';
130
          end if;
131
 
132
          if (next_wr_addr = rd_addr) then
133
             full <= '1';
134
          end if;
135
 
136
          if (out_ready_vector ='1' and  out_valid_r = '1') then
137
            rd_addr <= next_rd_addr;
138
            full    <= '0';
139
                if (next_rd_addr = wr_addr) then
140
                  empty     <= '1';
141
                  out_valid_r <= '0';
142
                 end if;
143
           end if;
144
 
145
 
146
         if (out_ready_vector = '1' and out_valid_r = '1' and in_ready_r = '1' and in_valid = '1') then
147
           full  <= full;
148
           empty <= empty;
149
          end if;
150
 
151
      end if;
152
   end process;
153
 
154
 
155
   process (rd_addr,out_ready,out_valid_r,next_rd_addr)
156
   begin
157
      mem_rd_addr <= rd_addr;
158
      if (out_ready = '1' and out_valid_r = '1') then
159
        mem_rd_addr <= next_rd_addr;
160
      end if;
161
   end process;
162
 
163
 
164
   --assign output 
165
   out_valid <= out_valid_r;
166
   in_ready <= in_ready_r;
167
 
168
   -- ---------------------------------------------------------------------
169
   --| Infer Memory
170
   -- ---------------------------------------------------------------------
171
   process (reset,clk)
172
   begin
173
      if (reset = '1') then
174
             for i in 0 to (DEPTH-1) loop
175
              mem(conv_integer(i)) <= (others => '0');
176
                 end loop;
177
      elsif (rising_edge(clk)) then
178
 
179
         if (in_ready_r = '1' and in_valid = '1')       then
180
           mem(conv_integer(wr_addr)) <= in_data;
181
                 end if;
182
 
183
         out_data <= mem(conv_integer(mem_rd_addr));
184
      end if;
185
 
186
   end process;
187
 
188
 
189
   end behav;

powered by: WebSVN 2.1.0

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