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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [gaisler/] [pci/] [pcitb_arb.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
------------------------------------------------------------------------------
2
--  This file is a part of the GRLIB VHDL IP LIBRARY
3
--  Copyright (C) 2003, Gaisler Research
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  This program is distributed in the hope that it will be useful,
11
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
--  GNU General Public License for more details.
14
--
15
--  You should have received a copy of the GNU General Public License
16
--  along with this program; if not, write to the Free Software
17
--  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
18
-----------------------------------------------------------------------------
19
-- Entity:      pcitb_arb
20
-- File:        pcitb_arb.vhd
21
-- Author:      Alf Vaerneus, Gaisler Research
22
-- Description: PCI arbiter
23
------------------------------------------------------------------------------
24
 
25
-- pragma translate_off
26
 
27
library ieee;
28
use ieee.std_logic_1164.all;
29
 
30
library gaisler;
31
use gaisler.pcitb.all;
32
 
33
entity pcitb_arb is
34
  generic (
35
    slots : integer := 5;
36
    tval : time := 7 ns);
37
  port (
38
    systclk : in pci_syst_type;
39
    ifcin : in pci_ifc_type;
40
    arbin : in pci_arb_type;
41
    arbout : out pci_arb_type);
42
end pcitb_arb;
43
 
44
architecture tb of pcitb_arb is
45
 
46
type queue_type is array (0 to slots-1) of integer range 0 to slots;
47
 
48
signal queue : queue_type;
49
signal queue_nr : integer range 0 to slots;
50
signal wfbus : boolean;
51
 
52
begin
53
 
54
  arb : process(systclk)
55
  variable i, slotgnt : integer;
56
  variable set : boolean;
57
  variable bus_idle : boolean;
58
  variable vqueue_nr : integer range 0 to slots;
59
  variable gnt,req : std_logic_vector(slots-1 downto 0);
60
  begin
61
    set := false; vqueue_nr := queue_nr;
62
    if (ifcin.frame and ifcin.irdy) = '1' then bus_idle := true; else bus_idle := false; end if;
63
    gnt := to_x01(arbin.gnt(slots-1 downto 0));
64
    req := to_x01(arbin.req(slots-1 downto 0));
65
 
66
    if systclk.rst = '0' then
67
      gnt := (others => '1');
68
      wfbus <= false;
69
      for i in 0 to slots-1 loop
70
        queue(i) <= 0;
71
      end loop;
72
      queue_nr <= 0;
73
    elsif rising_edge(systclk.clk) then
74
      for i in 0 to slots-1 loop
75
        if (gnt(i) or req(i)) = '0' then
76
          if (bus_idle or wfbus) then
77
            set := true;
78
          end if;
79
        end if;
80
      end loop;
81
 
82
      for i in 0 to slots-1 loop
83
        if (gnt(i) and not req(i)) = '1' then
84
          if queue(i) = 0 then
85
            vqueue_nr := vqueue_nr+1;
86
            queue(i) <= vqueue_nr;
87
          elsif (queue(i) = 1 and set = false) then
88
            gnt := (others => '1'); gnt(i) := '0';
89
            queue(i) <= 0;
90
            if not bus_idle then wfbus <= true; end if;
91
            if vqueue_nr > 0 then vqueue_nr := vqueue_nr-1; end if;
92
          elsif queue(i) >= 2 then
93
            if (set = false or vqueue_nr <= 1) then
94
              queue(i) <= queue(i)-1;
95
--              if vqueue_nr > 0 then vqueue_nr := vqueue_nr-1; end if;
96
            end if;
97
          end if;
98
        elsif (req(i) and not gnt(i)) = '1' then
99
          queue(i) <= 0; gnt(i) := '1';
100
--          if vqueue_nr > 0 then vqueue_nr := vqueue_nr-1; end if;
101
        elsif (req(i) and gnt(i)) = '1' then
102
          if (queue(i) > 0 and set = false) then
103
            queue(i) <= queue(i)-1;
104
            if (vqueue_nr > 0 and queue(i) = 1) then vqueue_nr := vqueue_nr-1; end if;
105
          end if;
106
        end if;
107
      end loop;
108
    end if;
109
 
110
    if bus_idle then wfbus <= false; end if;
111
 
112
    queue_nr <= vqueue_nr;
113
    arbout.req <= (others => 'Z');
114
    arbout.gnt <= (others => 'Z');
115
    arbout.gnt(slots-1 downto 0) <= gnt;
116
  end process;
117
 
118
end;
119
 
120
-- pragma translate_on

powered by: WebSVN 2.1.0

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