1 |
3 |
Andrewski |
--------------------------------------------------------------------------------
|
2 |
13 |
Andrewski |
--This file is part of fpga_gpib_controller.
|
3 |
|
|
--
|
4 |
|
|
-- Fpga_gpib_controller is free software: you can redistribute it and/or modify
|
5 |
|
|
-- it under the terms of the GNU General Public License as published by
|
6 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
7 |
|
|
-- (at your option) any later version.
|
8 |
|
|
--
|
9 |
|
|
-- Fpga_gpib_controller is distributed in the hope that it will be useful,
|
10 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
|
|
-- GNU General Public License for more details.
|
13 |
|
|
|
14 |
|
|
-- You should have received a copy of the GNU General Public License
|
15 |
|
|
-- along with Fpga_gpib_controller. If not, see <http://www.gnu.org/licenses/>.
|
16 |
|
|
--------------------------------------------------------------------------------
|
17 |
3 |
Andrewski |
-- Entity: gpibInterface
|
18 |
|
|
-- Date: 13:34 15/10/2011
|
19 |
13 |
Andrewski |
-- Author: Andrzej Paluch
|
20 |
3 |
Andrewski |
--------------------------------------------------------------------------------
|
21 |
|
|
library IEEE;
|
22 |
|
|
|
23 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
24 |
|
|
|
25 |
|
|
use work.gpibComponents.all;
|
26 |
|
|
|
27 |
|
|
entity gpibInterface is
|
28 |
|
|
port (
|
29 |
|
|
clk : in std_logic;
|
30 |
|
|
reset : std_logic;
|
31 |
|
|
-- application interface
|
32 |
|
|
isLE : in std_logic;
|
33 |
|
|
isTE : in std_logic;
|
34 |
|
|
lpeUsed : in std_logic;
|
35 |
|
|
fixedPpLine : in std_logic_vector (2 downto 0);
|
36 |
|
|
eosUsed : in std_logic;
|
37 |
|
|
eosMark : in std_logic_vector (7 downto 0);
|
38 |
|
|
myListAddr : in std_logic_vector (4 downto 0);
|
39 |
|
|
myTalkAddr : in std_logic_vector (4 downto 0);
|
40 |
|
|
secAddrMask : in std_logic_vector (31 downto 0);
|
41 |
|
|
data : in std_logic_vector (7 downto 0);
|
42 |
|
|
status_byte : in std_logic_vector (7 downto 0);
|
43 |
|
|
T1 : in std_logic_vector (7 downto 0);
|
44 |
|
|
-- local commands to interface
|
45 |
|
|
rdy : in std_logic; -- ready for next message (AH)
|
46 |
|
|
nba : in std_logic; -- new byte available (SH)
|
47 |
|
|
ltn : in std_logic; -- listen (L, LE)
|
48 |
|
|
lun : in std_logic; -- local unlisten (L, LE)
|
49 |
|
|
lon : in std_logic; -- listen only (L, LE)
|
50 |
|
|
ton : in std_logic; -- talk only (T, TE)
|
51 |
|
|
endOf : in std_logic; -- end of byte string (T, TE)
|
52 |
|
|
gts : in std_logic; -- go to standby (C)
|
53 |
|
|
rpp : in std_logic; -- request parallel poll (C)
|
54 |
|
|
tcs : in std_logic; -- take control synchronously (C, AH)
|
55 |
|
|
tca : in std_logic; -- take control asynchronously (C)
|
56 |
|
|
sic : in std_logic; -- send interface clear (C)
|
57 |
|
|
rsc : in std_logic; -- request system control (C)
|
58 |
|
|
sre : in std_logic; -- send remote enable (C)
|
59 |
|
|
rtl : in std_logic; -- return to local (RL)
|
60 |
|
|
rsv : in std_logic; -- request service (SR)
|
61 |
|
|
ist : in std_logic; -- individual status (PP)
|
62 |
|
|
lpe : in std_logic; -- local poll enable (PP)
|
63 |
|
|
|
64 |
|
|
-- local commands from interface
|
65 |
|
|
dvd : out std_logic; -- data valid (AH)
|
66 |
|
|
wnc : out std_logic; -- wait for new cycle (SH)
|
67 |
|
|
tac : out std_logic; -- talker active (T, TE)
|
68 |
|
|
lac : out std_logic; -- listener active (L, LE)
|
69 |
|
|
cwrc : out std_logic; -- controller write commands
|
70 |
|
|
cwrd : out std_logic; -- controller write data
|
71 |
|
|
clr : out std_logic; -- clear device (DC)
|
72 |
|
|
trg : out std_logic; -- trigger device (DT)
|
73 |
|
|
atl : out std_logic; -- addressed to listen (T or TE)
|
74 |
|
|
att : out std_logic; -- addressed to talk(L or LE)
|
75 |
|
|
mla : out std_logic; -- my listen addres decoded (L or LE)
|
76 |
|
|
lsb : out std_logic; -- last byte
|
77 |
|
|
spa : out std_logic; -- seriall poll active
|
78 |
|
|
ppr : out std_logic; -- parallel poll ready
|
79 |
|
|
sreq : out std_logic; -- service requested
|
80 |
|
|
isLocal : out std_logic; -- device is local controlled
|
81 |
|
|
currentSecAddr : out std_logic_vector (4 downto 0); -- current sec addr
|
82 |
|
|
-- interface signals
|
83 |
|
|
DI : in std_logic_vector (7 downto 0);
|
84 |
|
|
DO : out std_logic_vector (7 downto 0);
|
85 |
|
|
output_valid : out std_logic;
|
86 |
|
|
-- attention
|
87 |
|
|
ATN_in : in std_logic;
|
88 |
|
|
ATN_out : out std_logic;
|
89 |
|
|
-- data valid
|
90 |
|
|
DAV_in : in std_logic;
|
91 |
|
|
DAV_out : out std_logic;
|
92 |
|
|
-- not ready for data
|
93 |
|
|
NRFD_in : in std_logic;
|
94 |
|
|
NRFD_out : out std_logic;
|
95 |
|
|
-- no data accepted
|
96 |
|
|
NDAC_in : in std_logic;
|
97 |
|
|
NDAC_out : out std_logic;
|
98 |
|
|
-- end or identify
|
99 |
|
|
EOI_in : in std_logic;
|
100 |
|
|
EOI_out : out std_logic;
|
101 |
|
|
-- service request
|
102 |
|
|
SRQ_in : in std_logic;
|
103 |
|
|
SRQ_out : out std_logic;
|
104 |
|
|
-- interface clear
|
105 |
|
|
IFC_in : in std_logic;
|
106 |
|
|
IFC_out : out std_logic;
|
107 |
|
|
-- remote enable
|
108 |
|
|
REN_in : in std_logic;
|
109 |
|
|
REN_out : out std_logic
|
110 |
|
|
;debug1 : out std_logic
|
111 |
|
|
);
|
112 |
|
|
end gpibInterface;
|
113 |
|
|
|
114 |
|
|
architecture Behavioral of gpibInterface is
|
115 |
|
|
|
116 |
|
|
-- function states
|
117 |
|
|
signal LACS, LADS, SPAS, TACS, CACS, CSBS, CPPS, CTRS, CSRS, SACS, ACDS,
|
118 |
|
|
TPAS, APRS, LPAS, TADS, ANRS, STRS, SDYS, PPAS, LOCS, LWLS : std_logic;
|
119 |
|
|
|
120 |
|
|
-- decoded remote commands
|
121 |
|
|
signal ATN_dec, DAC_dec, DAV_dec, END_c_dec, IDY_dec, IFC_dec, REN_dec,
|
122 |
|
|
RFD_dec, SRQ_dec : std_logic;
|
123 |
|
|
signal ACG_dec, DAB_dec, DCL_dec, EOS_dec, GET_dec, GTL_dec, LAG_dec,
|
124 |
|
|
LLO_dec, MLA_dec, MTA_dec, MSA_dec, NUL_dec, OSA_dec, OTA_dec, PCG_dec,
|
125 |
|
|
PPC_dec, PPE_dec, PPD_dec, PPR_dec, PPU_dec, RQS_dec, SCG_dec, SDC_dec,
|
126 |
|
|
SPD_dec, SPE_dec, STB_dec, TAG_dec, TCT_dec, UCG_dec, UNL_dec,
|
127 |
|
|
UNT_dec : std_logic;
|
128 |
|
|
|
129 |
|
|
-- encoded remote commands
|
130 |
|
|
signal ATN_enc, DAC_enc, RFD_enc, DAV_enc, END_OF_enc, IFC_enc, IDY_enc,
|
131 |
|
|
REN_enc, RQS_enc, DAB_enc, EOS_enc, STB_enc, TCT_enc, SRQ_enc,
|
132 |
|
|
PPR_enc : std_logic;
|
133 |
|
|
|
134 |
|
|
-- PPR command data
|
135 |
|
|
signal ppBitValue : std_logic;
|
136 |
|
|
signal ppLineNumber : std_logic_vector (2 downto 0);
|
137 |
|
|
|
138 |
|
|
-- internal signals
|
139 |
|
|
signal secAddrDetected : std_logic;
|
140 |
|
|
|
141 |
|
|
begin
|
142 |
|
|
|
143 |
|
|
dvd <= ACDS;
|
144 |
|
|
cwrc <= CACS;
|
145 |
|
|
cwrd <= CSBS;
|
146 |
|
|
atl <= LADS or LACS;
|
147 |
|
|
lac <= LACS;
|
148 |
|
|
att <= TACS or TADS or SPAS;
|
149 |
|
|
mla <= MLA_dec;
|
150 |
|
|
lsb <= ((eosUsed and EOS_dec) or END_c_dec) and ACDS; -- dvd = ACDS
|
151 |
|
|
spa <= SPAS;
|
152 |
|
|
ppr <= CPPS;
|
153 |
|
|
sreq <= CSRS and SACS;
|
154 |
|
|
isLocal <= LOCS or LWLS;
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
-- acceptor handshake
|
158 |
|
|
AH: if_func_AH port map(
|
159 |
|
|
clk => clk,
|
160 |
|
|
-----------------------------------------------------------------------
|
161 |
|
|
pon => reset, rdy => rdy, tcs => tcs,
|
162 |
|
|
-----------------------------------------------------------------------
|
163 |
|
|
LACS => LACS, LADS => LADS,
|
164 |
|
|
-----------------------------------------------------------------------
|
165 |
|
|
ATN => ATN_dec, DAV => DAV_dec,
|
166 |
|
|
-----------------------------------------------------------------------
|
167 |
|
|
RFD => RFD_enc, DAC=> DAC_enc,
|
168 |
|
|
-----------------------------------------------------------------------
|
169 |
|
|
ANRS => ANRS, ACDS => ACDS
|
170 |
|
|
);
|
171 |
|
|
|
172 |
|
|
-- source handshake
|
173 |
|
|
SH: if_func_SH port map(
|
174 |
|
|
clk => clk,
|
175 |
|
|
-----------------------------------------------------------------------
|
176 |
|
|
T1 => T1,
|
177 |
|
|
-----------------------------------------------------------------------
|
178 |
|
|
pon => reset, nba => nba,
|
179 |
|
|
-----------------------------------------------------------------------
|
180 |
|
|
TACS => TACS, SPAS => SPAS, CACS => CACS, CTRS => CTRS,
|
181 |
|
|
-----------------------------------------------------------------------
|
182 |
|
|
ATN => ATN_dec, DAC => DAC_dec, RFD => RFD_dec,
|
183 |
|
|
-----------------------------------------------------------------------
|
184 |
|
|
DAV => DAV_enc,
|
185 |
|
|
-----------------------------------------------------------------------
|
186 |
|
|
wnc => wnc,
|
187 |
|
|
-----------------------------------------------------------------------
|
188 |
|
|
STRS => STRS, SDYS => SDYS
|
189 |
|
|
);
|
190 |
|
|
|
191 |
|
|
-- listener, extended listener
|
192 |
|
|
L_LE: if_func_L_LE port map(
|
193 |
|
|
clk => clk,
|
194 |
|
|
-----------------------------------------------------------------------
|
195 |
|
|
isLE => isLE,
|
196 |
|
|
-----------------------------------------------------------------------
|
197 |
|
|
pon => reset, ltn => ltn, lun => lun, lon => lon,
|
198 |
|
|
-----------------------------------------------------------------------
|
199 |
|
|
ACDS => ACDS, CACS => CACS, TPAS => TPAS,
|
200 |
|
|
-----------------------------------------------------------------------
|
201 |
|
|
ATN => ATN_dec, IFC => IFC_dec, MLA => MLA_dec, MTA => MTA_dec,
|
202 |
|
|
UNL => UNL_dec, PCG => PCG_dec, MSA => MSA_dec,
|
203 |
|
|
-----------------------------------------------------------------------
|
204 |
|
|
LACS => LACS, LADS => LADS, LPAS => LPAS, debug1 => debug1
|
205 |
|
|
);
|
206 |
|
|
|
207 |
|
|
-- talker, extended talker
|
208 |
|
|
T_TE: if_func_T_TE port map(
|
209 |
|
|
clk => clk,
|
210 |
|
|
-----------------------------------------------------------------------
|
211 |
|
|
isTE => isTE,
|
212 |
|
|
-----------------------------------------------------------------------
|
213 |
|
|
pon => reset, ton => ton, endOf => endOf,
|
214 |
|
|
-----------------------------------------------------------------------
|
215 |
|
|
ACDS => ACDS, APRS => APRS, LPAS => LPAS,
|
216 |
|
|
-----------------------------------------------------------------------
|
217 |
|
|
ATN => ATN_dec, IFC => IFC_dec, SPE => SPE_dec, SPD => SPD_dec,
|
218 |
|
|
MTA => MTA_dec, OTA => OTA_dec, MLA => MLA_dec, OSA => OSA_dec,
|
219 |
|
|
MSA => MSA_dec, PCG => PCG_dec,
|
220 |
|
|
-----------------------------------------------------------------------
|
221 |
|
|
END_OF => END_OF_enc, RQS => RQS_enc, DAB => DAB_enc, EOS => EOS_enc,
|
222 |
|
|
STB => STB_enc,
|
223 |
|
|
-----------------------------------------------------------------------
|
224 |
|
|
tac => tac,
|
225 |
|
|
-----------------------------------------------------------------------
|
226 |
|
|
SPAS => SPAS, TPAS => TPAS, TADS => TADS, TACS => TACS
|
227 |
|
|
);
|
228 |
|
|
|
229 |
|
|
-- controller
|
230 |
|
|
C: if_func_C port map(
|
231 |
|
|
clk => clk,
|
232 |
|
|
-----------------------------------------------------------------------
|
233 |
|
|
pon => reset, gts => gts, rpp => rpp, tcs => tcs, tca => tca,
|
234 |
|
|
sic => sic, rsc => rsc, sre => sre,
|
235 |
|
|
-----------------------------------------------------------------------
|
236 |
|
|
TADS => TADS, ACDS => ACDS, ANRS => ANRS, STRS => STRS, SDYS => SDYS,
|
237 |
|
|
-----------------------------------------------------------------------
|
238 |
|
|
ATN_in => ATN_dec, IFC_in => IFC_dec, TCT_in => TCT_dec,
|
239 |
|
|
SRQ_in => SRQ_dec,
|
240 |
|
|
-----------------------------------------------------------------------
|
241 |
|
|
ATN_out => ATN_enc, IFC_out => IFC_enc, TCT_out => TCT_enc,
|
242 |
|
|
IDY_out => IDY_enc, REN_out => REN_enc,
|
243 |
|
|
-----------------------------------------------------------------------
|
244 |
|
|
CACS => CACS, CTRS => CTRS, CSBS => CSBS, CPPS => CPPS, CSRS => CSRS,
|
245 |
|
|
SACS => SACS
|
246 |
|
|
);
|
247 |
|
|
|
248 |
|
|
-- device clear
|
249 |
|
|
DC: if_func_DC port map(
|
250 |
|
|
clk => clk,
|
251 |
|
|
-----------------------------------------------------------------------
|
252 |
|
|
LADS => LADS, ACDS => ACDS,
|
253 |
|
|
-----------------------------------------------------------------------
|
254 |
|
|
DCL => DCL_dec, SDC => SDC_dec,
|
255 |
|
|
-----------------------------------------------------------------------
|
256 |
|
|
clr => clr
|
257 |
|
|
);
|
258 |
|
|
|
259 |
|
|
-- device trigger
|
260 |
|
|
DT: if_func_DT port map(
|
261 |
|
|
clk => clk,
|
262 |
|
|
-----------------------------------------------------------------------
|
263 |
|
|
LADS => LADS, ACDS => ACDS,
|
264 |
|
|
-----------------------------------------------------------------------
|
265 |
|
|
GET => GET_dec,
|
266 |
|
|
-----------------------------------------------------------------------
|
267 |
|
|
trg => trg
|
268 |
|
|
);
|
269 |
|
|
|
270 |
|
|
PP: if_func_PP port map(
|
271 |
|
|
clk => clk,
|
272 |
|
|
-----------------------------------------------------------------------
|
273 |
|
|
lpeUsed => lpeUsed, fixedPpLine => fixedPpLine,
|
274 |
|
|
-----------------------------------------------------------------------
|
275 |
|
|
pon => reset, lpe => lpe, ist => ist,
|
276 |
|
|
-----------------------------------------------------------------------
|
277 |
|
|
ACDS => ACDS, LADS => LADS,
|
278 |
|
|
-----------------------------------------------------------------------
|
279 |
|
|
dio_data => DI(3 downto 0),
|
280 |
|
|
-----------------------------------------------------------------------
|
281 |
|
|
IDY => IDY_dec, PPE => PPE_dec, PPD => PPD_dec, PPC => PPC_dec,
|
282 |
|
|
PPU => PPU_dec, PCG => PCG_dec,
|
283 |
|
|
-----------------------------------------------------------------------
|
284 |
|
|
PPR => PPR_enc, ppBitValue => ppBitValue, ppLineNumber => ppLineNumber,
|
285 |
|
|
-----------------------------------------------------------------------
|
286 |
|
|
PPAS => PPAS
|
287 |
|
|
);
|
288 |
|
|
|
289 |
|
|
RL: if_func_RL port map(
|
290 |
|
|
clk => clk,
|
291 |
|
|
-----------------------------------------------------------------------
|
292 |
|
|
pon => reset, rtl => rtl,
|
293 |
|
|
-----------------------------------------------------------------------
|
294 |
|
|
ACDS => ACDS, LADS => LADS,
|
295 |
|
|
-----------------------------------------------------------------------
|
296 |
|
|
REN => REN_dec, LLO => LLO_dec, MLA => MLA_dec, GTL => GTL_dec,
|
297 |
|
|
-----------------------------------------------------------------------
|
298 |
|
|
LOCS => LOCS, LWLS => LWLS
|
299 |
|
|
);
|
300 |
|
|
|
301 |
|
|
SR: if_func_SR port map(
|
302 |
|
|
clk => clk,
|
303 |
|
|
-----------------------------------------------------------------------
|
304 |
|
|
pon => reset, rsv => rsv,
|
305 |
|
|
-----------------------------------------------------------------------
|
306 |
|
|
SPAS => SPAS,
|
307 |
|
|
-----------------------------------------------------------------------
|
308 |
|
|
SRQ => SRQ_enc,
|
309 |
|
|
-----------------------------------------------------------------------
|
310 |
|
|
APRS => APRS
|
311 |
|
|
);
|
312 |
|
|
|
313 |
|
|
COMM_ENC: commandEcoder port map (
|
314 |
|
|
data => data, status_byte => status_byte,
|
315 |
|
|
-------------------------------------------------------------------
|
316 |
|
|
ppBitValue => ppBitValue, ppLineNumber => ppLineNumber,
|
317 |
|
|
-------------------------------------------------------------------
|
318 |
|
|
APRS => APRS, CACS => CACS,
|
319 |
|
|
-------------------------------------------------------------------
|
320 |
|
|
ATN => ATN_enc, END_OF => END_OF_enc, IDY => IDY_enc,
|
321 |
|
|
DAC => DAC_enc, RFD => RFD_enc, DAV => DAV_enc, IFC => IFC_enc,
|
322 |
|
|
REN => REN_enc, SRQ => SRQ_enc, DAB => DAB_enc, EOS => EOS_enc,
|
323 |
|
|
RQS => RQS_enc, STB => STB_enc, TCT => TCT_enc, PPR => PPR_enc,
|
324 |
|
|
-------------------------------------------------------------------
|
325 |
|
|
DO => DO, output_valid => output_valid,
|
326 |
|
|
-------------------------------------------------------------------
|
327 |
|
|
DAV_line => DAV_out, NRFD_line => NRFD_out, NDAC_line => NDAC_out,
|
328 |
|
|
ATN_line => ATN_out, EOI_line => EOI_out, SRQ_line => SRQ_out,
|
329 |
|
|
IFC_line => IFC_out, REN_line => REN_out
|
330 |
|
|
);
|
331 |
|
|
|
332 |
|
|
-- command decoder
|
333 |
|
|
COMM_DEC: commandDecoder port map (
|
334 |
|
|
DI => DI, DAV_line => DAV_in, NRFD_line => NRFD_in,
|
335 |
|
|
NDAC_line => NDAC_in, ATN_line => ATN_in, EOI_line => EOI_in,
|
336 |
|
|
SRQ_line => SRQ_in, IFC_line => IFC_in, REN_line => REN_in,
|
337 |
|
|
-----------------------------------------------------------------------
|
338 |
|
|
eosMark => eosMark, eosUsed =>eosUsed, myListAddr => myListAddr,
|
339 |
|
|
myTalkAddr => myTalkAddr, secAddrDetected => secAddrDetected,
|
340 |
|
|
-----------------------------------------------------------------------
|
341 |
|
|
SPAS => SPAS,
|
342 |
|
|
-----------------------------------------------------------------------
|
343 |
|
|
ATN => ATN_dec, DAC => DAC_dec, DAV => DAV_dec, END_c => END_c_dec,
|
344 |
|
|
IDY => IDY_dec, IFC => IFC_dec, REN => REN_dec, RFD => RFD_dec,
|
345 |
|
|
SRQ => SRQ_dec,
|
346 |
|
|
-----------------------------------------------------------------------
|
347 |
|
|
ACG => ACG_dec, DAB => DAB_dec, DCL => DCL_dec, EOS => EOS_dec,
|
348 |
|
|
GET => GET_dec, GTL => GTL_dec, LAG => LAG_dec, LLO => LLO_dec,
|
349 |
|
|
MLA => MLA_dec, MTA => MTA_dec, MSA => MSA_dec, NUL => NUL_dec,
|
350 |
|
|
OSA => OSA_dec, OTA => OTA_dec, PCG => PCG_dec, PPC => PPC_dec,
|
351 |
|
|
PPE => PPE_dec, PPD => PPD_dec, PPR => PPR_dec, PPU => PPU_dec,
|
352 |
|
|
RQS => RQS_dec, SCG => SCG_dec, SDC => SDC_dec, SPD => SPD_dec,
|
353 |
|
|
SPE => SPE_dec, STB => STB_dec, TAG => TAG_dec, TCT => TCT_dec,
|
354 |
|
|
UCG => UCG_dec, UNL => UNL_dec, UNT => UNT_dec
|
355 |
|
|
);
|
356 |
|
|
|
357 |
|
|
SECAD: SecondaryAddressDecoder port map (
|
358 |
|
|
secAddrMask => secAddrMask, DI => DI(4 downto 0),
|
359 |
|
|
secAddrDetected => secAddrDetected
|
360 |
|
|
);
|
361 |
|
|
|
362 |
|
|
SECADS: SecAddrSaver port map (
|
363 |
|
|
reset => reset,
|
364 |
|
|
TADS => TADS, TPAS => TPAS, LADS => LADS, LPAS => LPAS,
|
365 |
|
|
MSA_Dec => MSA_Dec, DI => DI(4 downto 0),
|
366 |
|
|
currentSecAddr => currentSecAddr
|
367 |
|
|
);
|
368 |
|
|
|
369 |
|
|
end Behavioral;
|
370 |
|
|
|