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

Subversion Repositories gecko4

[/] [gecko4/] [trunk/] [GECKO4com/] [spartan200_an/] [vhdl/] [fifos/] [fifo_4kb_8w_16r-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_8w_16r 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(11 DOWNTO 0 );
70
   SIGNAL s_write_address_next : std_logic_vector(11 DOWNTO 0 );
71
   SIGNAL s_read_address_reg   : std_logic_vector(10 DOWNTO 0 );
72
   SIGNAL s_read_address_next  : std_logic_vector(10 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_we_lo              : std_logic;
81
   SIGNAL s_we_hi              : std_logic;
82
 
83
BEGIN
84
-- Assign outputs
85
   fifo_full   <= s_full;
86
   fifo_empty  <= s_empty;
87
   byte_cnt    <= s_nr_of_bytes_reg;
88
 
89
-- Assign control signals
90
   s_read_address_next  <= unsigned(s_read_address_reg) + 1;
91
   s_write_address_next <= unsigned(s_write_address_reg) + 1;
92
 
93
   s_execute_push       <= push AND NOT(s_nr_of_bytes_reg(12));
94
   s_execute_pop        <= pop  AND NOT(s_empty);
95
   s_n_clock            <= NOT(clock);
96
   s_full               <= s_nr_of_bytes_reg(12);
97
   s_empty              <= '1' WHEN s_nr_of_bytes_reg(12 DOWNTO 1) = X"000" ELSE '0';
98
   s_we_lo              <= s_execute_push AND NOT(s_write_address_reg(0));
99
   s_we_hi              <= s_execute_push AND s_write_address_reg(0);
100
 
101
-- define processes
102
   make_nr_of_bytes_next : PROCESS( s_execute_push , s_execute_pop ,
103
                                    s_nr_of_bytes_reg )
104
      VARIABLE v_add : std_logic_vector(12 DOWNTO 0 );
105
      VARIABLE v_sel : std_logic_vector( 1 DOWNTO 0 );
106
   BEGIN
107
      v_sel := s_execute_push&s_execute_pop;
108
      CASE (v_sel) IS
109
         WHEN  "00"  => v_add := "0"&X"000";
110
         WHEN  "01"  => v_add := "1"&X"FFE";
111
         WHEN  "10"  => v_add := "0"&X"001";
112
         WHEN OTHERS => v_add := "1"&X"FFF";
113
      END CASE;
114
      s_nr_of_bytes_next <= unsigned(s_nr_of_bytes_reg)+
115
                            unsigned(v_add);
116
   END PROCESS make_nr_of_bytes_next;
117
 
118
   make_read_address_reg : PROCESS( clock , reset , s_execute_pop ,
119
                                    s_read_address_next )
120
   BEGIN
121
      IF (clock'event AND (clock = '1')) THEN
122
         IF (reset = '1') THEN s_read_address_reg <= (OTHERS => '0');
123
         ELSIF (s_execute_pop = '1') THEN
124
            s_read_address_reg <= s_read_address_next;
125
         END IF;
126
      END IF;
127
   END PROCESS make_read_address_reg;
128
 
129
   make_write_address_reg : PROCESS( clock , reset , s_execute_push ,
130
                                     s_write_address_next )
131
   BEGIN
132
      IF (clock'event AND (clock = '1')) THEN
133
         IF (reset = '1') THEN s_write_address_reg <= (OTHERS => '0');
134
         ELSIF (s_execute_push = '1') THEN
135
            s_write_address_reg <= s_write_address_next;
136
         END IF;
137
      END IF;
138
   END PROCESS make_write_address_reg;
139
 
140
   make_nr_of_bytes_reg : PROCESS( clock , reset , s_nr_of_bytes_next )
141
   BEGIN
142
      IF (clock'event AND (clock = '1')) THEN
143
         IF (reset = '1') THEN s_nr_of_bytes_reg <= (OTHERS => '0');
144
                          ELSE s_nr_of_bytes_reg <= s_nr_of_bytes_next;
145
         END IF;
146
      END IF;
147
   END PROCESS make_nr_of_bytes_reg;
148
 
149
-- map components
150
   ram1 : RAMB16_S9_S9
151
          GENERIC MAP ( WRITE_MODE_A => "READ_FIRST",
152
                        WRITE_MODE_B => "READ_FIRST" )
153
          PORT MAP (  DOA     => OPEN,
154
                      ADDRA   => s_write_address_reg(11 DOWNTO 1),
155
                      DIA     => push_data,
156
                      ENA     => s_we_lo,
157
                      WEA     => s_we_lo,
158
                      DOPA    => OPEN,
159
                      CLKA    => clock,
160
                      DIPA(0) => push_last,
161
                      SSRA    => '0',
162
                      DOPB(0) => pop_last(0),
163
                      CLKB    => s_n_clock,
164
                      DIPB    => "0",
165
                      SSRB    => '0',
166
                      DOB     => pop_data( 7 DOWNTO 0 ),
167
                      ADDRB   => s_read_address_reg,
168
                      DIB     => X"00",
169
                      ENB     => '1',
170
                      WEB     => '0' );
171
   ram2 : RAMB16_S9_S9
172
          GENERIC MAP ( WRITE_MODE_A => "READ_FIRST",
173
                        WRITE_MODE_B => "READ_FIRST" )
174
          PORT MAP (  DOA     => OPEN,
175
                      ADDRA   => s_write_address_reg(11 DOWNTO 1),
176
                      DIA     => push_data,
177
                      ENA     => s_we_hi,
178
                      WEA     => s_we_hi,
179
                      DOPA    => OPEN,
180
                      CLKA    => clock,
181
                      DIPA(0) => push_last,
182
                      SSRA    => '0',
183
                      DOPB(0) => pop_last(1),
184
                      CLKB    => s_n_clock,
185
                      DIPB    => "0",
186
                      SSRB    => '0',
187
                      DOB     => pop_data( 15 DOWNTO 8 ),
188
                      ADDRB   => s_read_address_reg,
189
                      DIB     => X"00",
190
                      ENB     => '1',
191
                      WEB     => '0' );
192
END xilinx;

powered by: WebSVN 2.1.0

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