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

Subversion Repositories gecko4

[/] [gecko4/] [trunk/] [GECKO4com/] [spartan200_an/] [vhdl/] [fifos/] [fifo_2kb-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_2kb 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(11 DOWNTO 0 ) := X"7FD";
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(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(11 DOWNTO 0 );
74
   SIGNAL s_nr_of_bytes_next   : std_logic_vector(11 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
 
81
BEGIN
82
-- Assign outputs
83
   fifo_full   <= s_full;
84
   fifo_empty  <= s_empty;
85
 
86
-- Assign control signals
87
   s_read_address_next  <= unsigned(s_read_address_reg) + 1;
88
   s_write_address_next <= unsigned(s_write_address_reg) + 1;
89
   s_nr_of_bytes_next   <= unsigned(s_nr_of_bytes_reg) - 1
90
                             WHEN s_execute_pop = '1' AND
91
                                  s_execute_push = '0' ELSE
92
                           unsigned(s_nr_of_bytes_reg) + 1
93
                             WHEN s_execute_pop = '0' AND
94
                                  s_execute_push = '1' ELSE
95
                           s_nr_of_bytes_reg;
96
 
97
   s_execute_push       <= push AND NOT(s_nr_of_bytes_reg(11));
98
   s_execute_pop        <= pop  AND NOT(s_empty);
99
   s_n_clock            <= NOT(clock);
100
   s_full               <= '1' WHEN unsigned(s_nr_of_bytes_reg) >
101
                                    unsigned(c_threshold) ELSE '0';
102
   s_empty              <= '1' WHEN s_nr_of_bytes_reg = "000000000000" ELSE '0';
103
 
104
-- define processes
105
   make_read_address_reg : PROCESS( clock , reset , s_execute_pop ,
106
                                    s_read_address_next )
107
   BEGIN
108
      IF (clock'event AND (clock = '1')) THEN
109
         IF (reset = '1') THEN s_read_address_reg <= (OTHERS => '0');
110
         ELSIF (s_execute_pop = '1') THEN
111
            s_read_address_reg <= s_read_address_next;
112
         END IF;
113
      END IF;
114
   END PROCESS make_read_address_reg;
115
 
116
   make_write_address_reg : PROCESS( clock , reset , s_execute_push ,
117
                                     s_write_address_next )
118
   BEGIN
119
      IF (clock'event AND (clock = '1')) THEN
120
         IF (reset = '1') THEN s_write_address_reg <= (OTHERS => '0');
121
         ELSIF (s_execute_push = '1') THEN
122
            s_write_address_reg <= s_write_address_next;
123
         END IF;
124
      END IF;
125
   END PROCESS make_write_address_reg;
126
 
127
   make_nr_of_bytes_reg : PROCESS( clock , reset , s_nr_of_bytes_next )
128
   BEGIN
129
      IF (clock'event AND (clock = '1')) THEN
130
         IF (reset = '1') THEN s_nr_of_bytes_reg <= (OTHERS => '0');
131
                          ELSE s_nr_of_bytes_reg <= s_nr_of_bytes_next;
132
         END IF;
133
      END IF;
134
   END PROCESS make_nr_of_bytes_reg;
135
 
136
-- map components
137
   ram1 : RAMB16_S9_S9
138
          GENERIC MAP ( WRITE_MODE_A => "READ_FIRST",
139
                        WRITE_MODE_B => "READ_FIRST" )
140
          PORT MAP (  DOA     => OPEN,
141
                      ADDRA   => s_write_address_reg,
142
                      DIA     => push_data,
143
                      ENA     => s_execute_push,
144
                      WEA     => s_execute_push,
145
                      DOPA    => OPEN,
146
                      CLKA    => clock,
147
                      DIPA(0) => push_size,
148
                      SSRA    => '0',
149
                      DOPB(0) => pop_size,
150
                      CLKB    => s_n_clock,
151
                      DIPB    => "0",
152
                      SSRB    => '0',
153
                      DOB     => pop_data,
154
                      ADDRB   => s_read_address_reg,
155
                      DIB     => X"00",
156
                      ENB     => '1',
157
                      WEB     => '0' );
158
END xilinx;

powered by: WebSVN 2.1.0

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