1 |
42 |
lmaarsen |
--------------------------------------------------------------------------------
|
2 |
53 |
lmaarsen |
--
|
3 |
|
|
-- This VHDL file was generated by EASE/HDL 7.4 Revision 4 from HDL Works B.V.
|
4 |
|
|
--
|
5 |
|
|
-- Ease library : work
|
6 |
|
|
-- HDL library : work
|
7 |
|
|
-- Host name : S212065
|
8 |
|
|
-- User name : df768
|
9 |
|
|
-- Time stamp : Tue Aug 19 08:05:18 2014
|
10 |
|
|
--
|
11 |
|
|
-- Designed by : L.Maarsen
|
12 |
|
|
-- Company : LogiXA
|
13 |
|
|
-- Project info : eSoC
|
14 |
|
|
--
|
15 |
42 |
lmaarsen |
--------------------------------------------------------------------------------
|
16 |
53 |
lmaarsen |
|
17 |
42 |
lmaarsen |
--------------------------------------------------------------------------------
|
18 |
|
|
-- Object : Entity work.esoc_bus_arbiter
|
19 |
|
|
-- Last modified : Mon Apr 14 12:48:27 2014.
|
20 |
|
|
--------------------------------------------------------------------------------
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
library ieee, std, work;
|
25 |
|
|
use ieee.std_logic_1164.all;
|
26 |
|
|
use std.textio.all;
|
27 |
|
|
use ieee.numeric_std.all;
|
28 |
|
|
use work.package_esoc_configuration.all;
|
29 |
|
|
|
30 |
|
|
entity esoc_bus_arbiter is
|
31 |
|
|
generic(
|
32 |
|
|
id : integer := 0);
|
33 |
|
|
port(
|
34 |
|
|
bus_eof : in std_logic;
|
35 |
|
|
bus_gnt_rd : out std_logic_vector(esoc_port_count-1 downto 0);
|
36 |
|
|
bus_gnt_wr : out std_logic_vector(esoc_port_count-1 downto 0);
|
37 |
|
|
bus_req : in std_logic_vector(esoc_port_count-1 downto 0);
|
38 |
|
|
bus_sof : in std_logic;
|
39 |
|
|
clk_bus : in std_logic;
|
40 |
|
|
clk_control : in std_logic;
|
41 |
|
|
ctrl_address : in std_logic_vector(15 downto 0);
|
42 |
|
|
ctrl_rd : in std_logic;
|
43 |
|
|
ctrl_rddata : out std_logic_vector(31 downto 0);
|
44 |
|
|
ctrl_wait : out std_logic;
|
45 |
|
|
ctrl_wr : in std_logic;
|
46 |
|
|
ctrl_wrdata : in std_logic_vector(31 downto 0);
|
47 |
|
|
reset : in std_logic);
|
48 |
|
|
end entity esoc_bus_arbiter;
|
49 |
|
|
|
50 |
|
|
--------------------------------------------------------------------------------
|
51 |
|
|
-- Object : Architecture work.esoc_bus_arbiter.esoc_bus_arbiter
|
52 |
|
|
-- Last modified : Mon Apr 14 12:48:27 2014.
|
53 |
|
|
--------------------------------------------------------------------------------
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
---------------------------------------------------------------------------------------------------------------
|
57 |
|
|
-- architecture and declarations
|
58 |
|
|
---------------------------------------------------------------------------------------------------------------
|
59 |
|
|
architecture esoc_bus_arbiter of esoc_bus_arbiter is
|
60 |
|
|
|
61 |
|
|
---------------------------------------------------------------------------------------------------------------
|
62 |
|
|
-- registers
|
63 |
|
|
---------------------------------------------------------------------------------------------------------------
|
64 |
|
|
constant reg_arb_port_disable_add: integer := 7;
|
65 |
|
|
signal reg_arb_port_disable_dat: std_logic_vector(31 downto 0);
|
66 |
|
|
constant reg_arb_port_disable_rst: std_logic_vector(31 downto 0) := X"00000000";
|
67 |
|
|
|
68 |
|
|
constant reg_arb_port_weight_add: integer := 0;
|
69 |
|
|
signal reg_arb_port_weight_dat: std_logic_vector(31 downto 0);
|
70 |
|
|
constant reg_arb_port_weight_rst: std_logic_vector(31 downto 0) := X"00000000";
|
71 |
|
|
---------------------------------------------------------------------------------------------------------------
|
72 |
|
|
-- signals
|
73 |
|
|
---------------------------------------------------------------------------------------------------------------
|
74 |
|
|
signal port_select: integer range esoc_port_count-1 downto 0;
|
75 |
|
|
signal port_request: std_logic;
|
76 |
|
|
signal port_request_weight: std_logic_vector(1 downto 0);
|
77 |
|
|
|
78 |
|
|
type states_data_bus is (idle, wait_sof, wait_eof);
|
79 |
|
|
signal state_data_bus: states_data_bus;
|
80 |
|
|
|
81 |
|
|
signal ctrl_rddata_i: std_logic_vector(ctrl_rddata'high downto 0);
|
82 |
|
|
signal ctrl_wait_i: std_logic;
|
83 |
|
|
signal ctrl_bus_enable: std_logic;
|
84 |
|
|
|
85 |
|
|
begin
|
86 |
|
|
|
87 |
|
|
--=============================================================================================================
|
88 |
|
|
-- Process : process data bus access request, use weight factor for each port and approve access
|
89 |
|
|
-- Description :
|
90 |
|
|
--=============================================================================================================
|
91 |
|
|
req_scan: process(clk_bus, reset)
|
92 |
|
|
begin
|
93 |
|
|
if reset = '1' then
|
94 |
|
|
port_select <= 0;
|
95 |
|
|
port_request <= '0';
|
96 |
|
|
port_request_weight <= (others => '0');
|
97 |
|
|
bus_gnt_wr <= (others => '0');
|
98 |
|
|
bus_gnt_rd <= (others => '0');
|
99 |
|
|
state_data_bus <= idle;
|
100 |
|
|
|
101 |
|
|
elsif clk_bus'event and clk_bus = '1' then
|
102 |
|
|
-- scan request outputs from all ESOC ports, if asserted wait for free data bus
|
103 |
|
|
if bus_req(port_select) = '1' and reg_arb_port_disable_dat(port_select) = '0' then
|
104 |
|
|
port_request <= '1';
|
105 |
|
|
|
106 |
|
|
-- request output deasserted, current weight factor zero? determine next port to check, use weight factor of current port
|
107 |
|
|
else
|
108 |
|
|
port_request <= '0';
|
109 |
|
|
|
110 |
|
|
-- check weight of processed port, scan port again or go to next port with appropriate weight?
|
111 |
|
|
if to_integer(unsigned(port_request_weight)) = 0 then
|
112 |
|
|
if port_select = esoc_port_count-1 then
|
113 |
|
|
port_select <= 0;
|
114 |
|
|
port_request_weight <= reg_arb_port_weight_dat(1) & reg_arb_port_weight_dat(0);
|
115 |
|
|
else
|
116 |
|
|
port_select <= port_select + 1;
|
117 |
|
|
port_request_weight <= reg_arb_port_weight_dat(2*(port_select+1)+1) & reg_arb_port_weight_dat(2*(port_select+1));
|
118 |
|
|
end if;
|
119 |
|
|
|
120 |
|
|
-- weight not 0, do not proceed with next port, but decrease weight of actual port
|
121 |
|
|
else
|
122 |
|
|
port_request_weight <= std_logic_vector(to_unsigned(to_integer(unsigned(port_request_weight))-1,2));
|
123 |
|
|
end if;
|
124 |
|
|
end if;
|
125 |
|
|
|
126 |
|
|
-- monitor the data bus state and control the scan process
|
127 |
|
|
case state_data_bus is
|
128 |
|
|
when idle => -- if there is a bus request, give a write grant to selected port, a read grant to all other ports and wait for SOF and EOF
|
129 |
|
|
if port_request = '1' then
|
130 |
|
|
bus_gnt_wr(port_select) <= '1';
|
131 |
|
|
bus_gnt_rd <= (others => '1');
|
132 |
|
|
state_data_bus <= wait_sof;
|
133 |
|
|
end if;
|
134 |
|
|
|
135 |
|
|
when wait_sof => -- wait for start of packet, no further actions required yet (future)
|
136 |
|
|
if bus_sof = '1' then
|
137 |
|
|
state_data_bus <= wait_eof;
|
138 |
|
|
end if;
|
139 |
|
|
|
140 |
|
|
when wait_eof => -- End of packet detect? Terminate and go back to idle.
|
141 |
|
|
if bus_eof = '1' then
|
142 |
|
|
bus_gnt_wr <= (others => '0');
|
143 |
|
|
bus_gnt_rd <= (others => '0');
|
144 |
|
|
state_data_bus <= idle;
|
145 |
|
|
end if;
|
146 |
|
|
|
147 |
|
|
when others => state_data_bus <= idle;
|
148 |
|
|
end case;
|
149 |
|
|
end if;
|
150 |
|
|
end process;
|
151 |
|
|
|
152 |
|
|
--=============================================================================================================
|
153 |
|
|
-- Process : access registers when addressed or provide data from other units to the readdata bus
|
154 |
|
|
-- Description :
|
155 |
|
|
--=============================================================================================================
|
156 |
|
|
registers: process(clk_control, reset)
|
157 |
|
|
begin
|
158 |
|
|
if reset = '1' then
|
159 |
|
|
-- all ports have weight 1 after reset
|
160 |
|
|
reg_arb_port_disable_dat <= reg_arb_port_disable_rst;
|
161 |
|
|
reg_arb_port_weight_dat <= reg_arb_port_weight_rst;
|
162 |
|
|
ctrl_rddata_i <= (others => '0');
|
163 |
|
|
ctrl_wait_i <= '1';
|
164 |
|
|
ctrl_bus_enable <= '0';
|
165 |
|
|
|
166 |
|
|
elsif clk_control'event and clk_control = '1' then
|
167 |
|
|
ctrl_wait_i <= '1';
|
168 |
|
|
ctrl_bus_enable <= '0';
|
169 |
|
|
|
170 |
|
|
-- continu if memory space of this entity is addressed
|
171 |
|
|
if to_integer(unsigned(ctrl_address)) >= (esoc_bus_arbiter_base + (id * esoc_bus_arbiter_size)) and to_integer(unsigned(ctrl_address)) < (esoc_bus_arbiter_base + (id * esoc_bus_arbiter_size) + esoc_bus_arbiter_size) then
|
172 |
|
|
ctrl_bus_enable <= '1';
|
173 |
|
|
|
174 |
|
|
--
|
175 |
|
|
-- READ CYCLE started, unit addressed?
|
176 |
|
|
--
|
177 |
|
|
if ctrl_rd = '1' then
|
178 |
|
|
-- Check register address and provide data when addressed
|
179 |
|
|
case to_integer(unsigned(ctrl_address))- esoc_bus_arbiter_base - (id * esoc_bus_arbiter_size) is
|
180 |
|
|
when reg_arb_port_disable_add => ctrl_rddata_i <= reg_arb_port_disable_dat;
|
181 |
|
|
ctrl_wait_i <= '0';
|
182 |
|
|
|
183 |
|
|
when reg_arb_port_weight_add => ctrl_rddata_i <= reg_arb_port_weight_dat;
|
184 |
|
|
ctrl_wait_i <= '0';
|
185 |
|
|
|
186 |
|
|
when others => NULL;
|
187 |
|
|
end case;
|
188 |
|
|
|
189 |
|
|
--
|
190 |
|
|
-- WRITE CYCLE started, unit addressed?
|
191 |
|
|
--
|
192 |
|
|
elsif ctrl_wr = '1' then
|
193 |
|
|
-- Check address and accept data when addressed
|
194 |
|
|
case to_integer(unsigned(ctrl_address))- esoc_bus_arbiter_base - (id * esoc_bus_arbiter_size) is
|
195 |
|
|
when reg_arb_port_disable_add => reg_arb_port_disable_dat <= ctrl_wrdata;
|
196 |
|
|
ctrl_wait_i <= '0';
|
197 |
|
|
|
198 |
|
|
when reg_arb_port_weight_add => reg_arb_port_weight_dat <= ctrl_wrdata;
|
199 |
|
|
ctrl_wait_i <= '0';
|
200 |
|
|
|
201 |
|
|
when others => NULL;
|
202 |
|
|
end case;
|
203 |
|
|
end if;
|
204 |
|
|
end if;
|
205 |
|
|
end if;
|
206 |
|
|
end process;
|
207 |
|
|
|
208 |
|
|
-- Create tristate outputs
|
209 |
|
|
ctrl_wait <= ctrl_wait_i when ctrl_bus_enable = '1' else 'Z';
|
210 |
|
|
ctrl_rddata <= ctrl_rddata_i when ctrl_bus_enable = '1' else (others => 'Z');
|
211 |
|
|
|
212 |
|
|
end architecture esoc_bus_arbiter ; -- of esoc_bus_arbiter
|