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

Subversion Repositories gecko4

[/] [gecko4/] [trunk/] [GECKO4com/] [spartan200_an/] [vhdl/] [fifos/] [fifo_4kb_16w_8r-behavior-xilinx.vhdl] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 ktt1
--------------------------------------------------------------------------------
2
--            _   _            __   ____                                      --
3
--           / / | |          / _| |  __|                                     --
4
--           | |_| |  _   _  / /   | |_                                       --
5
--           |  _  | | | | | | |   |  _|                                      --
6
--           | | | | | |_| | \ \_  | |__                                      --
7
--           |_| |_| \_____|  \__| |____| microLab                            --
8
--                                                                            --
9
--           Bern University of Applied Sciences (BFH)                        --
10
--           Quellgasse 21                                                    --
11
--           Room HG 4.33                                                     --
12
--           2501 Biel/Bienne                                                 --
13
--           Switzerland                                                      --
14
--                                                                            --
15
--           http://www.microlab.ch                                           --
16
--------------------------------------------------------------------------------
17
--   GECKO4com
18
--  
19
--   2010/2011 Dr. Theo Kluter
20
--  
21
--   This VHDL code is free code: you can redistribute it and/or modify
22
--   it under the terms of the GNU General Public License as published by
23
--   the Free Software Foundation, either version 3 of the License, or
24
--   (at your option) any later version.
25
--  
26
--   This VHDL code is distributed in the hope that it will be useful,
27
--   but WITHOUT ANY WARRANTY; without even the implied warranty of
28
--   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
--   GNU General Public License for more details. 
30
--   You should have received a copy of the GNU General Public License
31
--   along with these sources.  If not, see <http://www.gnu.org/licenses/>.
32
--
33
 
34
-- The unisim library is used for simulation of the xilinx specific components
35
-- For generic usage please use:
36
-- LIBRARY work;
37
-- USE work.xilinx_generic.all;
38
-- And use the xilinx generic package found in the xilinx generic module
39
LIBRARY unisim;
40
USE unisim.all;
41
 
42
ARCHITECTURE xilinx OF fifo_4kb_16w_8r IS
43
 
44
   COMPONENT RAMB16_S9_S9
45
      GENERIC ( WRITE_MODE_A : string := "READ_FIRST";
46
                WRITE_MODE_B : string := "READ_FIRST" );
47
      PORT (  DOA   : OUT std_logic_vector( 7 DOWNTO 0);
48
              ADDRA : IN  std_logic_vector(10 DOWNTO 0);
49
              DIA   : IN  std_logic_vector( 7 DOWNTO 0);
50
              ENA   : IN  std_ulogic;
51
              WEA   : IN  std_ulogic;
52
              DOPA  : OUT std_logic_vector( 0 DOWNTO 0);
53
              CLKA  : IN  std_ulogic;
54
              DIPA  : IN  std_logic_vector( 0 DOWNTO 0);
55
              SSRA  : IN  std_ulogic;
56
              DOPB  : OUT std_logic_vector( 0 DOWNTO 0);
57
              CLKB  : IN  std_ulogic;
58
              DIPB  : IN  std_logic_vector( 0 DOWNTO 0);
59
              SSRB  : IN  std_ulogic;
60
              DOB   : OUT std_logic_vector( 7 DOWNTO 0);
61
              ADDRB : IN  std_logic_vector(10 DOWNTO 0);
62
              DIB   : IN  std_logic_vector( 7 DOWNTO 0);
63
              ENB   : IN  std_ulogic;
64
              WEB   : IN  std_ulogic );
65
   END COMPONENT;
66
 
67
   CONSTANT c_threshold        : std_logic_vector(12 DOWNTO 0 ) := "0"&X"FFD";
68
 
69
   SIGNAL s_write_address_reg  : std_logic_vector(10 DOWNTO 0 );
70
   SIGNAL s_write_address_next : std_logic_vector(10 DOWNTO 0 );
71
   SIGNAL s_read_address_reg   : std_logic_vector(11 DOWNTO 0 );
72
   SIGNAL s_read_address_next  : std_logic_vector(11 DOWNTO 0 );
73
   SIGNAL s_nr_of_bytes_reg    : std_logic_vector(12 DOWNTO 0 );
74
   SIGNAL s_nr_of_bytes_next   : std_logic_vector(12 DOWNTO 0 );
75
   SIGNAL s_full               : std_logic;
76
   SIGNAL s_empty              : std_logic;
77
   SIGNAL s_execute_push       : std_logic;
78
   SIGNAL s_execute_pop        : std_logic;
79
   SIGNAL s_n_clock            : std_logic;
80
   SIGNAL s_pop_data_lo        : std_logic_vector( 7 DOWNTO 0 );
81
   SIGNAL s_pop_data_hi        : std_logic_vector( 7 DOWNTO 0 );
82
   SIGNAL s_pop_size_lo        : std_logic;
83
   SIGNAL s_pop_size_hi        : std_logic;
84
 
85
BEGIN
86
-- Assign outputs
87
   fifo_full   <= s_full;
88
   fifo_empty  <= s_empty;
89
   pop_data    <= s_pop_data_lo WHEN s_read_address_reg(0) = '0' ELSE s_pop_data_hi;
90
   pop_size    <= s_pop_size_lo WHEN s_read_address_reg(0) = '0' ELSE s_pop_size_hi;
91
   byte_cnt    <= s_nr_of_bytes_reg;
92
 
93
-- Assign control signals
94
   s_read_address_next  <= unsigned(s_read_address_reg) + 1;
95
   s_write_address_next <= unsigned(s_write_address_reg) + 1;
96
 
97
   s_execute_push       <= push AND NOT(s_nr_of_bytes_reg(12));
98
   s_execute_pop        <= pop  AND NOT(s_empty);
99
   s_n_clock            <= NOT(clock);
100
   s_full               <= s_nr_of_bytes_reg(12);
101
   s_empty              <= '1' WHEN s_nr_of_bytes_reg = "0000000000000" ELSE '0';
102
 
103
-- define processes
104
   make_nr_of_bytes_next : PROCESS( s_execute_push , s_execute_pop ,
105
                                    s_nr_of_bytes_reg )
106
      VARIABLE v_add : std_logic_vector(12 DOWNTO 0 );
107
      VARIABLE v_sel : std_logic_vector( 1 DOWNTO 0 );
108
   BEGIN
109
      v_sel := s_execute_push&s_execute_pop;
110
      CASE (v_sel) IS
111
         WHEN  "00"  => v_add := "0"&X"000";
112
         WHEN  "01"  => v_add := "1"&X"FFF";
113
         WHEN  "10"  => v_add := "0"&X"002";
114
         WHEN OTHERS => v_add := "0"&X"001";
115
      END CASE;
116
      s_nr_of_bytes_next <= unsigned(s_nr_of_bytes_reg)+
117
                            unsigned(v_add);
118
   END PROCESS make_nr_of_bytes_next;
119
 
120
   make_read_address_reg : PROCESS( clock , reset , s_execute_pop ,
121
                                    s_read_address_next )
122
   BEGIN
123
      IF (clock'event AND (clock = '1')) THEN
124
         IF (reset = '1') THEN s_read_address_reg <= (OTHERS => '0');
125
         ELSIF (s_execute_pop = '1') THEN
126
            s_read_address_reg <= s_read_address_next;
127
         END IF;
128
      END IF;
129
   END PROCESS make_read_address_reg;
130
 
131
   make_write_address_reg : PROCESS( clock , reset , s_execute_push ,
132
                                     s_write_address_next )
133
   BEGIN
134
      IF (clock'event AND (clock = '1')) THEN
135
         IF (reset = '1') THEN s_write_address_reg <= (OTHERS => '0');
136
         ELSIF (s_execute_push = '1') THEN
137
            s_write_address_reg <= s_write_address_next;
138
         END IF;
139
      END IF;
140
   END PROCESS make_write_address_reg;
141
 
142
   make_nr_of_bytes_reg : PROCESS( clock , reset , s_nr_of_bytes_next )
143
   BEGIN
144
      IF (clock'event AND (clock = '1')) THEN
145
         IF (reset = '1') THEN s_nr_of_bytes_reg <= (OTHERS => '0');
146
                          ELSE s_nr_of_bytes_reg <= s_nr_of_bytes_next;
147
         END IF;
148
      END IF;
149
   END PROCESS make_nr_of_bytes_reg;
150
 
151
-- map components
152
   ram1 : RAMB16_S9_S9
153
          GENERIC MAP ( WRITE_MODE_A => "READ_FIRST",
154
                        WRITE_MODE_B => "READ_FIRST" )
155
          PORT MAP (  DOA     => OPEN,
156
                      ADDRA   => s_write_address_reg,
157
                      DIA     => push_data( 7 DOWNTO 0 ),
158
                      ENA     => s_execute_push,
159
                      WEA     => s_execute_push,
160
                      DOPA    => OPEN,
161
                      CLKA    => clock,
162
                      DIPA(0) => push_size,
163
                      SSRA    => '0',
164
                      DOPB(0) => s_pop_size_lo,
165
                      CLKB    => s_n_clock,
166
                      DIPB    => "0",
167
                      SSRB    => '0',
168
                      DOB     => s_pop_data_lo,
169
                      ADDRB   => s_read_address_reg(11 DOWNTO 1),
170
                      DIB     => X"00",
171
                      ENB     => '1',
172
                      WEB     => '0' );
173
   ram2 : RAMB16_S9_S9
174
          GENERIC MAP ( WRITE_MODE_A => "READ_FIRST",
175
                        WRITE_MODE_B => "READ_FIRST" )
176
          PORT MAP (  DOA     => OPEN,
177
                      ADDRA   => s_write_address_reg,
178
                      DIA     => push_data(15 DOWNTO 8 ),
179
                      ENA     => s_execute_push,
180
                      WEA     => s_execute_push,
181
                      DOPA    => OPEN,
182
                      CLKA    => clock,
183
                      DIPA(0) => push_size,
184
                      SSRA    => '0',
185
                      DOPB(0) => s_pop_size_hi,
186
                      CLKB    => s_n_clock,
187
                      DIPB    => "0",
188
                      SSRB    => '0',
189
                      DOB     => s_pop_data_hi,
190
                      ADDRB   => s_read_address_reg(11 DOWNTO 1),
191
                      DIB     => X"00",
192
                      ENB     => '1',
193
                      WEB     => '0' );
194
END xilinx;

powered by: WebSVN 2.1.0

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