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 |
|
|
-- In case of start of transmission:
|
43 |
|
|
-- data(15) => read_n_write
|
44 |
|
|
-- data(14 DOWNTO 6) => burst_size
|
45 |
|
|
-- data( 5 DOWNTO 0) => address
|
46 |
|
|
|
47 |
|
|
ARCHITECTURE xilinx OF bus_if IS
|
48 |
|
|
|
49 |
|
|
COMPONENT FD
|
50 |
|
|
GENERIC ( INIT : bit );
|
51 |
|
|
PORT ( Q : OUT std_logic;
|
52 |
|
|
C : IN std_logic;
|
53 |
|
|
D : IN std_logic );
|
54 |
|
|
END COMPONENT;
|
55 |
|
|
|
56 |
|
|
SIGNAL s_n_force_bus_reg : std_logic;
|
57 |
|
|
SIGNAL s_bus_reset : std_logic;
|
58 |
|
|
SIGNAL s_data_in : std_logic_vector( 15 DOWNTO 0 );
|
59 |
|
|
SIGNAL s_data_n_valid_in : std_logic_vector( 1 DOWNTO 0 );
|
60 |
|
|
SIGNAL s_n_start : std_logic;
|
61 |
|
|
SIGNAL s_n_end_in : std_logic;
|
62 |
|
|
SIGNAL s_n_error : std_logic;
|
63 |
|
|
SIGNAL s_n_start_send : std_logic;
|
64 |
|
|
SIGNAL s_n_end_out : std_logic;
|
65 |
|
|
SIGNAL s_bus_n_end_transmission : std_logic;
|
66 |
|
|
SIGNAL s_bus_n_end_tri : std_logic;
|
67 |
|
|
SIGNAL s_n_valid_out : std_logic_vector( 1 DOWNTO 0 );
|
68 |
|
|
SIGNAL s_bus_n_data_valid : std_logic_vector( 1 DOWNTO 0 );
|
69 |
|
|
SIGNAL s_bus_n_data_tri : std_logic_vector( 1 DOWNTO 0 );
|
70 |
|
|
SIGNAL s_bus_data_addr_cntrl : std_logic_vector(15 DOWNTO 0 );
|
71 |
|
|
SIGNAL s_bus_data_addr_tri : std_logic_vector(15 DOWNTO 0 );
|
72 |
|
|
|
73 |
|
|
BEGIN
|
74 |
|
|
|
75 |
|
|
--------------------------------------------------------------------------------
|
76 |
|
|
--- Here the outputs are defined ---
|
77 |
|
|
--------------------------------------------------------------------------------
|
78 |
|
|
b_n_reset <= NOT(s_bus_reset);
|
79 |
|
|
bus_n_end_transmission <= s_bus_n_end_transmission
|
80 |
|
|
WHEN s_bus_n_end_tri = '0' ELSE 'Z';
|
81 |
|
|
|
82 |
|
|
make_n_start_reg : PROCESS( clock , s_n_start , s_bus_reset , reset )
|
83 |
|
|
BEGIN
|
84 |
|
|
IF (clock'event AND (clock = '1')) THEN
|
85 |
|
|
IF (s_bus_reset = '1' OR
|
86 |
|
|
reset = '1') THEN b_n_start_transmission <= '1';
|
87 |
|
|
ELSE b_n_start_transmission <= s_n_start;
|
88 |
|
|
END IF;
|
89 |
|
|
END IF;
|
90 |
|
|
END PROCESS make_n_start_reg;
|
91 |
|
|
|
92 |
|
|
make_control_regs : PROCESS( clock , s_n_start , s_bus_reset , reset ,
|
93 |
|
|
s_data_in )
|
94 |
|
|
BEGIN
|
95 |
|
|
IF (clock'event AND (clock = '1')) THEN
|
96 |
|
|
IF (s_bus_reset = '1' OR
|
97 |
|
|
reset = '1') THEN read_n_write <= '1';
|
98 |
|
|
burst_size <= (OTHERS => '0');
|
99 |
|
|
address <= (OTHERS => '0');
|
100 |
|
|
ELSIF (s_n_start = '0') THEN read_n_write <= s_data_in(15);
|
101 |
|
|
burst_size <= s_data_in(14 DOWNTO 6);
|
102 |
|
|
address <= s_data_in( 5 DOWNTO 0);
|
103 |
|
|
END IF;
|
104 |
|
|
END IF;
|
105 |
|
|
END PROCESS make_control_regs;
|
106 |
|
|
|
107 |
|
|
make_data_regs : PROCESS( clock , s_bus_reset , reset , s_data_n_valid_in ,
|
108 |
|
|
s_data_in )
|
109 |
|
|
BEGIN
|
110 |
|
|
IF (clock'event AND (clock = '1')) THEN
|
111 |
|
|
IF (s_bus_reset = '1' OR
|
112 |
|
|
reset = '1') THEN data_out <= (OTHERS => '0');
|
113 |
|
|
b_n_data_valid_out <= "11";
|
114 |
|
|
b_n_end_transmission_out <= '1';
|
115 |
|
|
ELSE
|
116 |
|
|
b_n_data_valid_out <= s_data_n_valid_in;
|
117 |
|
|
b_n_end_transmission_out <= s_n_end_in;
|
118 |
|
|
IF (s_data_n_valid_in /= "11") THEN
|
119 |
|
|
data_out <= s_data_in;
|
120 |
|
|
END IF;
|
121 |
|
|
END IF;
|
122 |
|
|
END IF;
|
123 |
|
|
END PROCESS make_data_regs;
|
124 |
|
|
|
125 |
|
|
--------------------------------------------------------------------------------
|
126 |
|
|
--- Here the control signals are defined ---
|
127 |
|
|
--------------------------------------------------------------------------------
|
128 |
|
|
s_n_error <= '0' WHEN s_bus_reset = '0' AND
|
129 |
|
|
reset = '0' AND
|
130 |
|
|
(n_bus_error = '0' OR
|
131 |
|
|
(s_n_start = '0' AND
|
132 |
|
|
s_data_in(4) = '1')) -- Only vga and fifo for the moment
|
133 |
|
|
ELSE '1';
|
134 |
|
|
s_n_start_send <= '0' WHEN s_bus_reset = '0' AND
|
135 |
|
|
reset = '0' AND
|
136 |
|
|
n_start_send = '0' ELSE '1';
|
137 |
|
|
s_n_end_out <= '0' WHEN s_bus_reset = '0' AND
|
138 |
|
|
reset = '0' AND
|
139 |
|
|
b_n_end_transmission_in = '0' ELSE '1';
|
140 |
|
|
s_n_valid_out <= "11" WHEN s_bus_reset = '1' OR
|
141 |
|
|
reset = '1' ELSE b_n_data_valid_in;
|
142 |
|
|
|
143 |
|
|
--------------------------------------------------------------------------------
|
144 |
|
|
--- Here the three state control is defined ---
|
145 |
|
|
--------------------------------------------------------------------------------
|
146 |
|
|
make_n_force_bus_reg : PROCESS( clock , reset , s_bus_reset ,
|
147 |
|
|
s_n_start , s_data_in )
|
148 |
|
|
BEGIN
|
149 |
|
|
IF (clock'event AND (clock = '1')) THEN
|
150 |
|
|
IF (reset = '1' OR
|
151 |
|
|
s_n_error = '0' OR
|
152 |
|
|
s_n_end_out = '0' OR
|
153 |
|
|
s_bus_reset = '1') THEN s_n_force_bus_reg <= '1';
|
154 |
|
|
ELSIF (s_n_start = '0' AND
|
155 |
|
|
s_data_in(15) = '1') THEN s_n_force_bus_reg <= '0';
|
156 |
|
|
END IF;
|
157 |
|
|
END IF;
|
158 |
|
|
END PROCESS make_n_force_bus_reg;
|
159 |
|
|
|
160 |
|
|
--------------------------------------------------------------------------------
|
161 |
|
|
--- Here the IOB ffs are defined ---
|
162 |
|
|
--------------------------------------------------------------------------------
|
163 |
|
|
reset_ff : FD
|
164 |
|
|
GENERIC MAP ( INIT => '1' )
|
165 |
|
|
PORT MAP ( Q => s_bus_reset,
|
166 |
|
|
C => clock,
|
167 |
|
|
D => bus_reset );
|
168 |
|
|
make_data_ffs : FOR n IN 15 DOWNTO 0 GENERATE
|
169 |
|
|
bus_data_addr_cntrl(n) <= s_bus_data_addr_cntrl(n)
|
170 |
|
|
WHEN s_bus_data_addr_tri(n) = '0' ELSE
|
171 |
|
|
'Z';
|
172 |
|
|
din_ff : FD
|
173 |
|
|
GENERIC MAP ( INIT => '1' )
|
174 |
|
|
PORT MAP ( Q => s_data_in(n),
|
175 |
|
|
C => clock,
|
176 |
|
|
D => bus_data_addr_cntrl(n));
|
177 |
|
|
dout_ff : FD
|
178 |
|
|
GENERIC MAP ( INIT => '1' )
|
179 |
|
|
PORT MAP ( Q => s_bus_data_addr_cntrl(n),
|
180 |
|
|
C => clock,
|
181 |
|
|
D => data_in(n) );
|
182 |
|
|
tri_ff : FD
|
183 |
|
|
GENERIC MAP ( INIT => '1' )
|
184 |
|
|
PORT MAP ( Q => s_bus_data_addr_tri(n),
|
185 |
|
|
C => clock,
|
186 |
|
|
D => s_n_force_bus_reg );
|
187 |
|
|
END GENERATE make_data_ffs;
|
188 |
|
|
|
189 |
|
|
make_data_valid_ffs : FOR n IN 1 DOWNTO 0 GENERATE
|
190 |
|
|
bus_n_data_valid(n) <= s_bus_n_data_valid(n)
|
191 |
|
|
WHEN s_bus_n_data_tri(n) = '0' ELSE
|
192 |
|
|
'Z';
|
193 |
|
|
in_ff : FD
|
194 |
|
|
GENERIC MAP ( INIT => '1' )
|
195 |
|
|
PORT MAP ( Q => s_data_n_valid_in(n),
|
196 |
|
|
C => clock,
|
197 |
|
|
D => bus_n_data_valid(n) );
|
198 |
|
|
out_ff : FD
|
199 |
|
|
GENERIC MAP ( INIT => '1' )
|
200 |
|
|
PORT MAP ( Q => s_bus_n_data_valid(n),
|
201 |
|
|
C => clock,
|
202 |
|
|
D => s_n_valid_out(n) );
|
203 |
|
|
tri_ff : FD
|
204 |
|
|
GENERIC MAP ( INIT => '1' )
|
205 |
|
|
PORT MAP ( Q => s_bus_n_data_tri(n),
|
206 |
|
|
C => clock,
|
207 |
|
|
D => s_n_force_bus_reg );
|
208 |
|
|
END GENERATE make_data_valid_ffs;
|
209 |
|
|
|
210 |
|
|
end_in_ff : FD
|
211 |
|
|
GENERIC MAP ( INIT => '1' )
|
212 |
|
|
PORT MAP ( Q => s_n_end_in,
|
213 |
|
|
C => clock,
|
214 |
|
|
D => bus_n_end_transmission );
|
215 |
|
|
end_out_ff : FD
|
216 |
|
|
GENERIC MAP ( INIT => '1' )
|
217 |
|
|
PORT MAP ( Q => s_bus_n_end_transmission,
|
218 |
|
|
C => clock,
|
219 |
|
|
D => s_n_end_out );
|
220 |
|
|
end_tri_ff : FD
|
221 |
|
|
GENERIC MAP ( INIT => '1' )
|
222 |
|
|
PORT MAP ( Q => s_bus_n_end_tri,
|
223 |
|
|
C => clock,
|
224 |
|
|
D => s_n_force_bus_reg );
|
225 |
|
|
|
226 |
|
|
start_trans_ff : FD
|
227 |
|
|
GENERIC MAP ( INIT => '1' )
|
228 |
|
|
PORT MAP ( Q => s_n_start,
|
229 |
|
|
C => clock,
|
230 |
|
|
D => bus_n_start_transmission );
|
231 |
|
|
n_error_ff : FD
|
232 |
|
|
GENERIC MAP ( INIT => '1' )
|
233 |
|
|
PORT MAP ( Q => bus_n_error,
|
234 |
|
|
C => clock,
|
235 |
|
|
D => s_n_error );
|
236 |
|
|
n_send_ff : FD
|
237 |
|
|
GENERIC MAP ( INIT => '1' )
|
238 |
|
|
PORT MAP ( Q => bus_n_start_send,
|
239 |
|
|
C => clock,
|
240 |
|
|
D => s_n_start_send );
|
241 |
|
|
|
242 |
|
|
END xilinx;
|