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

Subversion Repositories udp_ip_stack

[/] [udp_ip_stack/] [trunk/] [rtl/] [vhdl/] [tx_arbitrator.vhd] - Blame information for rev 27

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 pjf
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    08:03:30 06/04/2011 
6
-- Design Name: 
7
-- Module Name:    tx_arbitrator - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description:         arbitrate between two sources that want to transmit onto a bus
12
--                                              handles arbitration and multiplexing
13
--
14
-- Dependencies: 
15
--
16
-- Revision: 
17
-- Revision 0.01 - File Created
18
-- Revision 0.02 - Made sticky on port M1 to optimise access on this port and allow immediate grant
19 4 pjf
-- Revision 0.03 - Added first
20 2 pjf
-- Additional Comments: 
21
--
22
----------------------------------------------------------------------------------
23
library IEEE;
24
use IEEE.STD_LOGIC_1164.ALL;
25
 
26
 
27
entity tx_arbitrator is
28
    port (
29
                clk                             : in std_logic;
30
                reset                           : in std_logic;
31
 
32
                req_1                           : in  std_logic;
33
                grant_1                 : out std_logic;
34
      data_1         : in  std_logic_vector(7 downto 0); -- data byte to tx
35
      valid_1        : in  std_logic;                                                   -- tdata is valid
36 4 pjf
      first_1        : in  std_logic;                                                   -- indicates first byte of frame
37 2 pjf
      last_1         : in  std_logic;                                                   -- indicates last byte of frame
38
 
39
                req_2                           : in  std_logic;
40
                grant_2                 : out std_logic;
41
      data_2         : in  std_logic_vector(7 downto 0); -- data byte to tx
42
      valid_2        : in  std_logic;                                                   -- tdata is valid
43 4 pjf
      first_2        : in  std_logic;                                                   -- indicates first byte of frame
44 2 pjf
      last_2         : in  std_logic;                                                   -- indicates last byte of frame
45
 
46
      data              : out  std_logic_vector(7 downto 0);     -- data byte to tx
47
      valid             : out  std_logic;                                                       -- tdata is valid
48 4 pjf
      first             : out  std_logic;                                                       -- indicates first byte of frame
49 2 pjf
      last              : out  std_logic                                                        -- indicates last byte of frame
50
    );
51
end tx_arbitrator;
52
 
53
architecture Behavioral of tx_arbitrator is
54
 
55
        type grant_type is (M1,M2);
56
 
57
        signal grant :  grant_type;
58
 
59
begin
60
        combinatorial : process (
61
                grant,
62 4 pjf
                data_1, valid_1, first_1, last_1,
63
                data_2, valid_2, first_2, last_2
64 2 pjf
                )
65
        begin
66
                -- grant outputs
67
                case grant is
68
                        when M1 =>
69
                                grant_1 <= '1';
70
                                grant_2 <= '0';
71
                        when M2 =>
72
                                grant_1 <= '0';
73
                                grant_2 <= '1';
74
                end case;
75
 
76
                -- multiplexer
77
                if grant = M1 then
78
                        data <= data_1;
79
                        valid <= valid_1;
80 4 pjf
                        first <= first_1;
81 2 pjf
                        last <= last_1;
82
                else
83
                        data <= data_2;
84
                        valid <= valid_2;
85 4 pjf
                        first <= first_2;
86 2 pjf
                        last <= last_2;
87
                end if;
88
        end process;
89
 
90
        sequential : process (clk, reset, req_1, req_2, grant)
91
        begin
92
                if rising_edge(clk) then
93
                        if reset = '1' then
94
                                grant <= M1;
95
                        else
96
                                case grant is
97
                                        when M1 =>
98
                                                if req_1 = '1' then
99
                                                        grant <= M1;
100
                                                elsif req_2 = '1' then
101
                                                        grant <= M2;
102
                                                end if;
103
                                        when M2 =>
104
                                                if req_2 = '1' then
105
                                                        grant <= M2;
106
                                                else
107
                                                        grant <= M1;
108
                                                end if;
109
                                end case;
110
                        end if;
111
                end if;
112
        end process;
113
 
114
 
115
end Behavioral;
116
 

powered by: WebSVN 2.1.0

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