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

Subversion Repositories pcie_sg_dma

[/] [pcie_sg_dma/] [branches/] [Virtex6/] [ML605_ISE12.3/] [Tx_Output_Arbitor.vhd] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 barabba
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer   :    wgao, LI5, Univ. Mannheim
4
-- 
5
-- Create Date:    07.12.2006 
6
-- Design Name: 
7
-- Module Name:    Tx_Output_Arbitor - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies:
14
--
15
-- Revision 2.00 - Dimension elastized by GENERATE.  10.07.2007
16
-- 
17
-- Revision 1.30 - abbPackage used.  26.06.2007
18
-- 
19
-- Revision 1.20 - Timing better.  29.01.2007
20
-- 
21
-- Revision 1.10 - Current States drive.  12.01.2007
22
-- 
23
-- Revision 1.00 - first release. 14.12.2006
24
-- 
25
-- Additional Comments:
26
--                      Dimension can be easily expanded.
27
-- 
28
----------------------------------------------------------------------------------
29
 
30
LIBRARY IEEE;
31
USE IEEE.STD_LOGIC_1164.ALL;
32
USE IEEE.STD_LOGIC_ARITH.ALL;
33
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
34
 
35
library work;
36
use work.abb64Package.all;
37
 
38
 
39
-----------  Top entity   ---------------
40
entity Tx_Output_Arbitor is
41
        port (
42
              rst_n     : IN  std_logic;
43
              clk       : IN  std_logic;
44
 
45
              arbtake   : IN  std_logic;                                       -- take a valid arbitration by the user
46
              Req       : IN  std_logic_vector(C_ARBITRATE_WIDTH-1 downto 0);  -- similar to FIFO not-empty
47
 
48
              bufread   : OUT std_logic_vector(C_ARBITRATE_WIDTH-1 downto 0);  -- Read FIFO
49
              Ack       : OUT std_logic_vector(C_ARBITRATE_WIDTH-1 downto 0)   -- tells who is the winner
50
        );
51
end Tx_Output_Arbitor;
52
 
53
 
54
architecture Behavioral of Tx_Output_Arbitor is
55
 
56
  TYPE ArbStates is         (
57
                               aSt_Reset
58
                             , aSt_Idle
59
                             , aSt_ReadOne
60
                             , aSt_Ready
61
                             );
62
 
63
  signal Arb_FSM             : ArbStates;
64
  signal Arb_FSM_NS          : ArbStates;
65
 
66
 
67
  TYPE PriorMatrix is ARRAY (C_ARBITRATE_WIDTH-1 downto 0)
68
                               of std_logic_vector (C_ARBITRATE_WIDTH-1 downto 0);
69
 
70
  signal ChPriority          : PriorMatrix;
71
 
72
  signal Prior_Init_Value    : PriorMatrix;
73
 
74
  signal Wide_Req            : PriorMatrix;
75
 
76
  signal Wide_Req_turned     : PriorMatrix;
77
 
78
 
79
  signal  take_i             :  std_logic;
80
  signal  Req_i              :  std_logic_vector(C_ARBITRATE_WIDTH-1 downto 0);
81
 
82
  signal  Req_r1             :  std_logic_vector(C_ARBITRATE_WIDTH-1 downto 0);
83
 
84
  signal  read_prep          :  std_logic_vector(C_ARBITRATE_WIDTH-1 downto 0);
85
  signal  read_i             :  std_logic_vector(C_ARBITRATE_WIDTH-1 downto 0);
86
  signal  Indice_prep        :  std_logic_vector(C_ARBITRATE_WIDTH-1 downto 0);
87
  signal  Indice_i           :  std_logic_vector(C_ARBITRATE_WIDTH-1 downto 0);
88
 
89
  signal  Champion_Vector    :  std_logic_vector (C_ARBITRATE_WIDTH-1 downto 0);
90
 
91
 
92
begin
93
 
94
   bufread   <= read_i;
95
   Ack       <= Indice_i;
96
 
97
   take_i    <= arbtake;
98
   Req_i     <= Req;
99
 
100
  -- ------------------------------------------------------------
101
  Prior_Init_Value(0) <= C_LOWEST_PRIORITY;
102
  Gen_Prior_Init_Values:
103
    FOR i IN 1 TO C_ARBITRATE_WIDTH-1 generate
104
      Prior_Init_Value(i) <= Prior_Init_Value(i-1)(C_ARBITRATE_WIDTH-2 downto 0) & '1';
105
    end generate;
106
 
107
 
108
  -- ------------------------------------------------------------
109
  --  Mask the requests
110
  -- 
111
  Gen_Wide_Requests:
112
    FOR i IN 0 TO C_ARBITRATE_WIDTH-1 generate
113
      Wide_Req(i) <= ChPriority(i) when Req_i(i)='1'
114
                     else C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0);
115
    end generate;
116
 
117
 
118
-- ------------------------------------
119
-- Synchronous Delay: Req
120
--
121
   Synch_Delay_Req:
122
   process(clk)
123
   begin
124
     if clk'event and clk = '1' then
125
       Req_r1  <= Req_i;
126
     end if;
127
   end process;
128
 
129
 
130
-- ------------------------------------
131
-- Synchronous: States
132
--
133
   Seq_FSM_NextState:
134
   process(clk, rst_n)
135
   begin
136
     if (rst_n = '0') then
137
       Arb_FSM <= aSt_Reset;
138
     elsif clk'event and clk = '1' then
139
       Arb_FSM <= Arb_FSM_NS;
140
     end if;
141
   end process;
142
 
143
 
144
-- ------------------------------------
145
-- Combinatorial: Next States
146
--
147
   Comb_FSM_NextState:
148
   process (
149
             Arb_FSM
150
           , take_i
151
           , Req_r1
152
           )
153
   begin
154
     case Arb_FSM  is
155
 
156
       when aSt_Reset  =>
157
          Arb_FSM_NS <= aSt_Idle;
158
 
159
       when aSt_Idle  =>
160
          if Req_r1 = C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0) then
161
             Arb_FSM_NS <= aSt_Idle;
162
          else
163
             Arb_FSM_NS <= aSt_ReadOne;
164
          end if;
165
 
166
       when aSt_ReadOne  =>
167
          if Req_r1 = C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0) then  -- Ghost Request !!!
168
             Arb_FSM_NS <= aSt_Idle;
169
          else
170
             Arb_FSM_NS <= aSt_Ready;
171
          end if;
172
 
173
       when aSt_Ready  =>
174
          if take_i = '0' then
175
             Arb_FSM_NS <= aSt_Ready;
176
          elsif Req_r1 = C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0) then
177
             Arb_FSM_NS <= aSt_Idle;
178
          else
179
             Arb_FSM_NS <= aSt_ReadOne;
180
          end if;
181
 
182
       when Others  =>
183
          Arb_FSM_NS <= aSt_Reset;
184
 
185
     end case;
186
 
187
   end process;
188
 
189
 
190
-- --------------------------------------------------
191
-- Turn the Request-Array Around
192
--
193
   Turn_the_Request_Array_Around:
194
       FOR i IN 0 TO C_ARBITRATE_WIDTH-1 generate
195
         Dimension_2nd:
196
         FOR j IN 0 TO C_ARBITRATE_WIDTH-1 generate
197
            Wide_Req_turned(i)(j) <= Wide_Req(j)(i);
198
         END generate;
199
       END generate;
200
 
201
 
202
-- --------------------------------------------------
203
-- Synchronous Calculation: Champion_Vector
204
--
205
   Sync_Champion_Vector:
206
   process(clk)
207
   begin
208
     if clk'event and clk = '1' then
209
 
210
       FOR i IN 0 TO C_ARBITRATE_WIDTH-1 LOOP
211
         if Wide_Req_turned(i)=C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0) then
212
            Champion_Vector(i) <= '0';
213
         else
214
            Champion_Vector(i) <= '1';
215
         end if;
216
       END LOOP;
217
 
218
     end if;
219
   end process;
220
 
221
 
222
-- --------------------------------------------------
223
--  Prepare the buffer read signal: read_i
224
-- 
225
   Gen_Read_Signals:
226
     FOR i IN 0 TO C_ARBITRATE_WIDTH-1 generate
227
       read_prep(i) <= '1' when Champion_Vector=ChPriority(i) else '0';
228
     end generate;
229
 
230
 
231
-- --------------------------------------------------
232
-- FSM Output :  Buffer read_i and Indice_i
233
--
234
   FSM_Output_read_Indice:
235
   process (clk, rst_n)
236
   begin
237
     if (rst_n = '0') then
238
       read_i      <= C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0);
239
       Indice_prep <= C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0);
240
       Indice_i    <= C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0);
241
     elsif clk'event and clk = '1' then
242
 
243
       case Arb_FSM is
244
 
245
         when aSt_ReadOne =>
246
           read_i      <= read_prep;
247
           Indice_prep <= read_prep;
248
           Indice_i    <= C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0);
249
 
250
         when aSt_Ready =>
251
           read_i      <= C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0);
252
           Indice_prep <= Indice_prep;
253
           if take_i ='1' then
254
            Indice_i    <= C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0);
255
           else
256
            Indice_i    <= Indice_prep;
257
           end if;
258
 
259
         when Others =>
260
           read_i      <= C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0);
261
           Indice_prep <= Indice_prep;
262
           Indice_i    <= C_ALL_ZEROS(C_ARBITRATE_WIDTH-1 downto 0);
263
 
264
       end case;
265
 
266
     end if;
267
   end process;
268
 
269
 
270
-- --------------------------------------------------
271
--
272
 Gen_Modify_Priorities:
273
 
274
   FOR i IN 0 TO C_ARBITRATE_WIDTH-1 generate
275
 
276
      Proc_Priority_Cycling:
277
      process (clk, rst_n)
278
      begin
279
        if (rst_n = '0') then
280
          ChPriority(i) <= Prior_Init_Value(i);
281
        elsif clk'event and clk = '1' then
282
 
283
          case Arb_FSM is
284
 
285
            when aSt_ReadOne =>
286
              if ChPriority(i) = Champion_Vector then
287
                 ChPriority(i) <= C_LOWEST_PRIORITY;
288
              elsif (ChPriority(i) and Champion_Vector) = Champion_Vector then
289
                 ChPriority(i) <= ChPriority(i);
290
              else
291
                 ChPriority(i) <= ChPriority(i)(C_ARBITRATE_WIDTH-2 downto 0) & '1';
292
              end if;
293
 
294
            when Others =>
295
                 ChPriority(i) <= ChPriority(i);
296
 
297
          end case;
298
 
299
        end if;
300
      end process;
301
 
302
  end generate;
303
 
304
 
305
end architecture Behavioral;

powered by: WebSVN 2.1.0

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