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

Subversion Repositories gecko4

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

powered by: WebSVN 2.1.0

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