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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [vhdl/] [src/] [wrapper/] [RegsGpibFasade.vhd] - Blame information for rev 6

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

Line No. Rev Author Line
1 3 Andrewski
--------------------------------------------------------------------------------
2
-- Entity: RegsGpibFasade
3
-- Date:2011-11-17  
4
-- Author: apaluch
5
--
6
-- Description ${cursor}
7
--------------------------------------------------------------------------------
8
library ieee;
9
use ieee.std_logic_1164.all;
10
use ieee.std_logic_unsigned.all;
11
 
12
use work.gpibComponents.all;
13
use work.helperComponents.all;
14
use work.wrapperComponents.all;
15
 
16
 
17
entity RegsGpibFasade is
18
        port (
19
                reset : std_logic;
20
                clk : in std_logic;
21
                -----------------------------------------------------------------------
22
                ------------ GPIB interface signals -----------------------------------
23
                -----------------------------------------------------------------------
24
                DI : in std_logic_vector (7 downto 0);
25
                DO : out std_logic_vector (7 downto 0);
26
                output_valid : out std_logic;
27
                -- attention
28
                ATN_in : in std_logic;
29
                ATN_out : out std_logic;
30
                -- data valid
31
                DAV_in : in std_logic;
32
                DAV_out : out std_logic;
33
                -- not ready for data
34
                NRFD_in : in std_logic;
35
                NRFD_out : out std_logic;
36
                -- no data accepted
37
                NDAC_in : in std_logic;
38
                NDAC_out : out std_logic;
39
                -- end or identify
40
                EOI_in : in std_logic;
41
                EOI_out : out std_logic;
42
                -- service request
43
                SRQ_in : in std_logic;
44
                SRQ_out : out std_logic;
45
                -- interface clear
46
                IFC_in : in std_logic;
47
                IFC_out : out std_logic;
48
                -- remote enable
49
                REN_in : in std_logic;
50
                REN_out : out std_logic;
51
                -----------------------------------------------------------------------
52
                ---------------- registers access -------------------------------------
53
                -----------------------------------------------------------------------
54
                data_in : in std_logic_vector(15 downto 0);
55
                data_out : out std_logic_vector(15 downto 0);
56
                reg_addr : in std_logic_vector(14 downto 0);
57
                strobe_read : in std_logic;
58
                strobe_write : in std_logic;
59
                -----------------------------------------------------------------------
60
                ---------------- additional lines -------------------------------------
61
                -----------------------------------------------------------------------
62
                interrupt_line : out std_logic
63
                ;debug1 : out std_logic
64
                ;debug2 : out std_logic
65
        );
66
end RegsGpibFasade;
67
 
68
architecture arch of RegsGpibFasade is
69
 
70
        constant MEM_NATIVE_DATA_WIDTH : integer := 16;
71
 
72
        -- gpib
73
        signal g_isLE, g_isTE : std_logic;
74
        signal g_lpeUsed : std_logic;
75
        signal g_fixedPpLine : std_logic_vector (2 downto 0);
76
        signal g_eosUsed : std_logic;
77
        signal g_eosMark : std_logic_vector (7 downto 0);
78
        signal g_myListAddr, g_myTalkAddr : std_logic_vector (4 downto 0);
79
        signal g_secAddrMask : std_logic_vector (31 downto 0);
80
        signal g_data : std_logic_vector (7 downto 0);
81
        signal g_status_byte : std_logic_vector (7 downto 0);
82
        signal g_T1 : std_logic_vector (7 downto 0);
83
        signal g_rdy, g_nba, g_ltn, g_lun, g_lon, g_ton, g_endOf, g_gts, g_rpp,
84
                g_tcs, g_tca, g_sic, g_rsc, g_sre, g_rtl, g_rsv, g_ist, g_lpe, g_dvd,
85
                g_wnc, g_tac, g_lac, g_cwrc, g_cwrd, g_clr, g_trg, g_atl, g_att, g_mla,
86
                g_lsb, g_spa, g_ppr, g_sreq, g_isLocal : std_logic;
87
        signal g_currentSecAddr : std_logic_vector (4 downto 0);
88
        signal g_output_valid : std_logic;
89
        signal g_ATN_out : std_logic;
90
 
91
        -- reader
92
        signal r_isLE : std_logic;
93
        signal r_dataSecAddr : std_logic_vector (4 downto 0);
94
        signal r_buf_interrupt : std_logic;
95
        signal r_data_available : std_logic;
96
        signal r_end_of_stream : std_logic;
97
        signal r_reset_buffer : std_logic;
98
        signal r_strobe : std_logic;
99
        signal r_fifo_full : std_logic;
100
        signal r_fifo_ready_to_write : std_logic;
101
        signal r_at_least_one_byte_in_fifo : std_logic;
102
 
103
        -- writer
104
        signal w_isTE : std_logic;
105
        signal w_dataSecAddr : std_logic_vector (4 downto 0);
106
        signal w_end_of_stream : std_logic;
107
        signal w_data_available : std_logic;
108
        signal w_buf_interrupt : std_logic;
109
        signal w_reset_buffer : std_logic;
110
 
111
        -- serial poll coordinator
112
        signal s_rec_stb : std_logic;
113
        signal s_stb_received : std_logic;
114
 
115
        -- reader fifo
116
        signal rm_reset : std_logic;
117
        signal rm_byte_in : std_logic_vector(7 downto 0);
118
        signal rm_byte_out : std_logic_vector(15 downto 0);
119
        -------------- fifo --------------------
120
        signal rm_availableBytesCount : std_logic_vector(10 downto 0);
121
        signal rm_strobe_read : std_logic;
122
 
123
        -- writer fifo
124
        signal wm_reset : std_logic;
125
        signal wm_write_strobe : std_logic;
126
        signal wm_data_in : std_logic_vector(15 downto 0);
127
        signal wm_byte_in : std_logic_vector(7 downto 0);
128
        signal wm_ready_to_read : std_logic;
129
        signal wm_bytesAvailable : std_logic;
130
        signal wm_availableBytesCount : std_logic_vector(10 downto 0);
131
        signal wm_bufferFull : std_logic;
132
        signal wm_ready_to_write : std_logic;
133
        signal wm_strobe_read : std_logic;
134
 
135
        -- settings reg
136
        signal set0_strobe : std_logic;
137
        signal set0_data_in, set0_data_out :
138
                std_logic_vector((MEM_NATIVE_DATA_WIDTH-1) downto 0);
139
        signal set1_strobe : std_logic;
140
        signal set1_data_in, set1_data_out :
141
                std_logic_vector((MEM_NATIVE_DATA_WIDTH-1) downto 0);
142
        signal set0_isLE_TE : std_logic;
143
        signal set1_myAddr : std_logic_vector(4 downto 0);
144
 
145
        -- sec addr mask reg
146
        signal sec0_strobe : std_logic;
147
        signal sec0_data_in, sec0_data_out :
148
                std_logic_vector((MEM_NATIVE_DATA_WIDTH-1) downto 0);
149
        signal sec0_secAddrMask :
150
                std_logic_vector ((MEM_NATIVE_DATA_WIDTH-1) downto 0);
151
        signal sec1_strobe : std_logic;
152
        signal sec1_data_in, sec1_data_out :
153
                std_logic_vector((MEM_NATIVE_DATA_WIDTH-1) downto 0);
154
        signal sec1_secAddrMask :
155
                std_logic_vector ((MEM_NATIVE_DATA_WIDTH-1) downto 0);
156
 
157
        -- gpib bus reg
158
        signal gbs_data_out : std_logic_vector ((MEM_NATIVE_DATA_WIDTH-1) downto 0);
159
 
160
        -- event reg
161
        signal ev_strobe : std_logic;
162
        signal ev_data_in, ev_data_out :
163
                std_logic_vector((MEM_NATIVE_DATA_WIDTH-1) downto 0);
164
 
165
        -- gpib status
166
        signal gs_data_out : std_logic_vector ((MEM_NATIVE_DATA_WIDTH-1) downto 0);
167
 
168
        -- gpib control reg
169
        signal gc_strobe : std_logic;
170
        signal gc_data_in, gc_data_out :
171
                std_logic_vector((MEM_NATIVE_DATA_WIDTH-1) downto 0);
172
 
173
        -- reader control reg
174
        signal rc0_strobe : std_logic;
175
        signal rc0_data_in, rc0_data_out :
176
                std_logic_vector((MEM_NATIVE_DATA_WIDTH-1) downto 0);
177
        signal rc1_data_out :
178
                std_logic_vector((MEM_NATIVE_DATA_WIDTH-1) downto 0);
179
 
180
        -- writer control reg
181
        signal wc0_strobe : std_logic;
182
        signal wc0_data_in, wc0_data_out :
183
                std_logic_vector((MEM_NATIVE_DATA_WIDTH-1) downto 0);
184
        signal wc0_status_byte : std_logic_vector (6 downto 0);
185
        signal wc1_strobe : std_logic;
186
        signal wc1_data_in, wc1_data_out :
187
                std_logic_vector((MEM_NATIVE_DATA_WIDTH-1) downto 0);
188
 
189
begin
190
 
191
        debug1 <= g_nba;
192
        debug2 <= g_wnc;
193
 
194
        -- settings reg
195
        g_isLE <= set0_isLE_TE;
196
        g_isTE <= set0_isLE_TE;
197
        r_isLE <= set0_isLE_TE;
198
        w_isTE <= set0_isLE_TE;
199
        g_myListAddr <= set1_myAddr;
200
        g_myTalkAddr <= set1_myAddr;
201
        -- sec addr reg
202
        g_secAddrMask (15 downto 0) <= sec0_secAddrMask;
203
        g_secAddrMask (31 downto 16) <= sec1_secAddrMask;
204
 
205
        g_status_byte(7) <= wc0_status_byte(6);
206
        g_status_byte(6) <= '0';
207
        g_status_byte(5 downto 0) <= wc0_status_byte(5 downto 0);
208
 
209
        -- writer fifo
210
        wm_reset <= w_reset_buffer;
211
        -- reader fifo
212
        rm_reset <= r_reset_buffer;
213
 
214
        gpib: gpibInterface port map (
215
                clk => clk, reset => reset,
216
                -- application interface
217
                isLE => g_isLE, isTE => g_isTE, lpeUsed => g_lpeUsed,
218
                fixedPpLine => g_fixedPpLine, eosUsed => g_eosUsed,
219
                eosMark => g_eosMark, myListAddr => g_myListAddr,
220
                myTalkAddr => g_myTalkAddr, secAddrMask => g_secAddrMask,
221
                data => g_data, status_byte => g_status_byte, T1 => g_T1,
222
                rdy => g_rdy, nba => g_nba, ltn => g_ltn, lun => g_lun, lon => g_lon,
223
                ton => g_ton, endOf => g_endOf, gts => g_gts, rpp => g_rpp,
224
                tcs => g_tcs, tca => g_tca, sic => g_sic, rsc => g_rsc, sre => g_sre,
225
                rtl => g_rtl, rsv => g_rsv, ist => g_ist, lpe => g_lpe,
226
                dvd => g_dvd, wnc => g_wnc, tac => g_tac, lac => g_lac, cwrc => g_cwrc,
227
                cwrd => g_cwrd, clr => g_clr, trg => g_trg, atl => g_atl, att => g_att,
228
                mla => g_mla, lsb => g_lsb, spa => g_spa, ppr => g_ppr, sreq => g_sreq,
229
                isLocal => g_isLocal, currentSecAddr => g_currentSecAddr,
230
                DI => DI, DO => DO, output_valid => g_output_valid,
231
                ATN_in => ATN_in, ATN_out => g_ATN_out, DAV_in => DAV_in,
232
                DAV_out => DAV_out, NRFD_in => NRFD_in, NRFD_out => NRFD_out,
233
                NDAC_in => NDAC_in, NDAC_out => NDAC_out, EOI_in => EOI_in,
234
                EOI_out => EOI_out, SRQ_in => SRQ_in, SRQ_out => SRQ_out,
235
                IFC_in => IFC_in, IFC_out => IFC_out, REN_in => REN_in,
236
                REN_out => REN_out, debug1 => open
237
        );
238
 
239
        reader: gpibReader port map (
240
                clk => clk, reset => reset,
241
                ------------------------------------------------------------------------
242
                ------ GPIB interface --------------------------------------------------
243
                ------------------------------------------------------------------------
244
                data_in => DI, dvd => g_dvd, lac => g_lac, lsb => g_lsb,
245
                rdy => g_rdy,
246
                ------------------------------------------------------------------------
247
                ------ external interface ----------------------------------------------
248
                ------------------------------------------------------------------------
249
                isLE => r_isLE, secAddr => g_currentSecAddr,
250
                dataSecAddr => r_dataSecAddr, buf_interrupt => r_buf_interrupt,
251
                end_of_stream => r_end_of_stream,
252
                reset_reader => r_reset_buffer,
253
                ------------------ fifo --------------------------------------
254
                fifo_full => r_fifo_full, fifo_ready_to_write => r_fifo_ready_to_write,
255
                at_least_one_byte_in_fifo => r_at_least_one_byte_in_fifo,
256
                data_out => rm_byte_in, fifo_strobe => r_strobe
257
        );
258
 
259
        writer: gpibWriter port map (
260
                clk => clk, reset => reset,
261
                ------------------------------------------------------------------------
262
                ------ GPIB interface --------------------------------------------------
263
                ------------------------------------------------------------------------
264
                data_out => g_data, wnc => g_wnc, spa => g_spa, nba => g_nba,
265
                endOf => g_endOf, tac => g_tac, cwrc => g_cwrc,
266
                ------------------------------------------------------------------------
267
                ------ external interface ----------------------------------------------
268
                ------------------------------------------------------------------------
269
                isTE => w_isTE,
270
                secAddr => g_currentSecAddr, dataSecAddr => w_dataSecAddr,
271
                buf_interrupt => w_buf_interrupt, end_of_stream => w_end_of_stream,
272
                reset_writer => w_reset_buffer,
273
                writer_enable => w_data_available,
274
                ---------------- fifo ---------------------------
275
                availableFifoBytesCount => wm_availableBytesCount,
276
                fifo_read_strobe => wm_strobe_read,
277
                fifo_ready_to_read => wm_ready_to_read,
278
                fifo_data_in => wm_byte_in
279
        );
280
 
281
        spc: SerialPollCoordinator port map (
282
                clk => clk, reset => reset,
283
                DAC => NDAC_in, rec_stb => s_rec_stb, ATN_in => g_ATN_out,
284
                ATN_out => ATN_out, output_valid_in => g_output_valid,
285
                output_valid_out => output_valid, stb_received => s_stb_received
286
        );
287
 
288
        readerFifo: Fifo8b port map (
289
                reset => reset, clk => clk,
290
                -------------- fifo --------------------
291
                bytesAvailable => r_at_least_one_byte_in_fifo,
292
                availableBytesCount => rm_availableBytesCount,
293
                bufferFull => r_fifo_full,
294
                resetFifo => rm_reset,
295
                ----------------------------------------
296
                data_in => rm_byte_in, ready_to_write => r_fifo_ready_to_write,
297
                strobe_write => r_strobe,
298
                ----------------------------------------
299
                data_out => rm_byte_out(7 downto 0), ready_to_read => r_data_available,
300
                strobe_read => rm_strobe_read
301
        );
302
 
303
        writerFifo: Fifo8b port map (
304
                reset => reset, clk => clk,
305
                -------------- fifo --------------------
306
                bytesAvailable => wm_bytesAvailable,
307
                availableBytesCount => wm_availableBytesCount,
308
                bufferFull => wm_bufferFull,
309
                resetFifo => wm_reset,
310
                ----------------------------------------
311
                data_in => wm_data_in(7 downto 0),
312
                ready_to_write => wm_ready_to_write,
313
                strobe_write => wm_write_strobe,
314
                ----------------------------------------
315
                data_out => wm_byte_in,
316
                ready_to_read => wm_ready_to_read,
317
                strobe_read => wm_strobe_read
318
        );
319
 
320
        --Clk2x_0: Clk2x port map (
321
        --      reset => reset,
322
        --      clk => clk,
323
        --      clk2x => clk2x
324
        --);
325
 
326
        set0: SettingsReg0 port map (
327
                reset => reset,
328
                strobe => set0_strobe, data_in => set0_data_in,
329
                data_out => set0_data_out,
330
                ------------- gpib -----------------------------
331
                isLE_TE => set0_isLE_TE, lpeUsed => g_lpeUsed,
332
                fixedPpLine => g_fixedPpLine, eosUsed => g_eosUsed,
333
                eosMark => g_eosMark, lon => g_lon, ton => g_ton
334
        );
335
 
336
        set1: SettingsReg1 port map (
337
                reset => reset,
338
                strobe => set1_strobe, data_in => set1_data_in,
339
                data_out => set1_data_out,
340
                -- gpib
341
                myAddr => set1_myAddr, T1 => g_T1
342
        );
343
 
344
        sec0: SecAddrReg port map (
345
                reset => reset,
346
                strobe => sec0_strobe, data_in => sec0_data_in,
347
                data_out => sec0_data_out,
348
                -- gpib
349
                secAddrMask => sec0_secAddrMask
350
        );
351
 
352
        sec1: SecAddrReg port map (
353
                reset => reset,
354
                strobe => sec1_strobe, data_in => sec1_data_in,
355
                data_out => sec1_data_out,
356
                -- gpib
357
                secAddrMask => sec1_secAddrMask
358
        );
359
 
360
        gbs: gpibBusReg port map (
361
                data_out => gbs_data_out,
362
                ----------- gpib ---------------------------------
363
                DIO => DI, ATN => ATN_in, DAV => DAV_in, NRFD => NRFD_in,
364
                NDAC => NDAC_in, EOI => EOI_in, SRQ => SRQ_in, IFC => IFC_in,
365
                REN => REN_in
366
        );
367
 
368
        ev: EventReg port map (
369
                reset => reset, clk => clk,
370
                strobe => ev_strobe, data_in => ev_data_in, data_out => ev_data_out,
371
                -------------------- gpib device ---------------------
372
                isLocal => g_isLocal, in_buf_ready => r_buf_interrupt,
373
                out_buf_ready => w_buf_interrupt, clr => g_clr, trg => g_trg,
374
                att => g_att, atl => g_atl, spa => g_spa,
375
                -------------------- gpib controller ---------------------
376
                cwrc => g_cwrc, cwrd => g_cwrd, srq => g_sreq, ppr => g_ppr,
377
                -- stb received
378
                stb_received => s_stb_received,
379
                REN => REN_in, ATN => ATN_in, IFC => IFC_in
380
        );
381
 
382
        gs: GpibStatusReg port map (
383
                data_out => gs_data_out,
384
                --------------------- gpib ---------------------
385
                currentSecAddr => g_currentSecAddr,
386
                att => g_att, tac => g_tac, atl => g_atl, lac => g_lac,
387
                cwrc => g_cwrc, cwrd => g_cwrd, spa => g_spa,
388
                isLocal => g_isLocal
389
        );
390
 
391
        gc: gpibControlReg port map (
392
                        reset => reset,
393
                        strobe => gc_strobe, data_in => gc_data_in,
394
                        data_out => gc_data_out,
395
                        ------------------ gpib ------------------------
396
                        ltn => g_ltn, lun => g_lun, rtl => g_rtl, rsv => g_rsv,
397
                        ist => g_ist, lpe => g_lpe,
398
                        ------------------------------------------------
399
                        rsc => g_rsc, sic => g_sic, sre => g_sre, gts => g_gts,
400
                        tcs => g_tcs, tca => g_tca, rpp => g_rpp, rec_stb => s_rec_stb
401
                );
402
 
403
        rc0: ReaderControlReg0 port map (
404
                clk => clk, reset => reset,
405
                strobe => rc0_strobe, data_in => rc0_data_in, data_out => rc0_data_out,
406
                ------------------- gpib -------------------------
407
                buf_interrupt => r_buf_interrupt, data_available => r_data_available,
408
                end_of_stream => r_end_of_stream, reset_buffer => r_reset_buffer,
409
                dataSecAddr => r_dataSecAddr
410
        );
411
 
412
        rc1: ReaderControlReg1 port map (
413
                data_out => rc1_data_out,
414
                ------------------ gpib --------------------
415
                bytes_available_in_fifo => rm_availableBytesCount
416
        );
417
 
418
        wc0: WriterControlReg0 port map (
419
                clk => clk, reset => reset,
420
                strobe => wc0_strobe, data_in => wc0_data_in, data_out => wc0_data_out,
421
                ------------------- gpib -------------------------
422
                buf_interrupt => w_buf_interrupt, data_available => w_data_available,
423
                end_of_stream => w_end_of_stream, reset_buffer => w_reset_buffer,
424
                dataSecAddr => w_dataSecAddr, status_byte => wc0_status_byte
425
        );
426
 
427
        wc1: WriterControlReg1 port map (
428
                reset => reset,
429
                strobe => wc1_strobe, data_in => wc1_data_in,
430
                data_out => wc1_data_out,
431
                ------------------ gpib --------------------
432
                bytes_available_in_fifo => wm_availableBytesCount
433
        );
434
 
435
        ig: InterruptGenerator port map (
436
                reset => reset, clk => clk, interrupt => interrupt_line,
437
                -------------------- gpib device ---------------------
438
                isLocal => g_isLocal, in_buf_ready => r_buf_interrupt,
439
                out_buf_ready => w_buf_interrupt, clr => g_clr, trg => g_trg,
440
                att => g_att, atl => g_atl, spa => g_spa, cwrc => g_cwrc,
441
                cwrd => g_cwrd, srq => g_sreq, ppr => g_ppr,
442
                stb_received => s_stb_received, REN => REN_in, ATN => ATN_in,
443
                IFC => IFC_in
444
        );
445
 
446
        rml: RegMultiplexer generic map (ADDR_WIDTH => 15) port map (
447
                        strobe_read => strobe_read, strobe_write => strobe_write,
448
                        data_in => data_in, data_out => data_out,
449
                        --------------------------------------------------------
450
                        reg_addr => reg_addr,
451
                        --------------------------------------------------------
452
                        reg_strobe_0 => set0_strobe,
453
                        reg_in_0 => set0_data_in, reg_out_0 => set0_data_out,
454
 
455
                        reg_strobe_1 => set1_strobe,
456
                        reg_in_1 => set1_data_in, reg_out_1 => set1_data_out,
457
 
458
                        reg_strobe_2 => sec0_strobe,
459
                        reg_in_2 => sec0_data_in, reg_out_2 => sec0_data_out,
460
 
461
                        reg_strobe_3 => sec1_strobe,
462
                        reg_in_3 => sec1_data_in, reg_out_3 => sec1_data_out,
463
 
464
                        --reg_strobe_4 => 
465
                        --reg_in_4 => 
466
                        reg_out_4 => gbs_data_out,
467
 
468
                        reg_strobe_5 => ev_strobe,
469
                        reg_in_5 => ev_data_in, reg_out_5 => ev_data_out,
470
 
471
                        --reg_strobe_6 => 
472
                        --reg_in_6 => 
473
                        reg_out_6 => gs_data_out,
474
 
475
                        reg_strobe_7 => gc_strobe,
476
                        reg_in_7 => gc_data_in, reg_out_7 => gc_data_out,
477
 
478
                        reg_strobe_8 => rc0_strobe,
479
                        reg_in_8 => rc0_data_in, reg_out_8 => rc0_data_out,
480
 
481
                        --reg_strobe_9 => rc1_strobe,
482
                        --reg_in_9 => rc1_data_in,
483
                        reg_out_9 => rc1_data_out,
484
 
485
                        reg_strobe_10 => wc0_strobe,
486
                        reg_in_10 => wc0_data_in, reg_out_10 => wc0_data_out,
487
 
488
                        reg_strobe_11 => wc1_strobe,
489
                        reg_in_11 => wc1_data_in, reg_out_11 => wc1_data_out,
490
 
491
                        reg_strobe_other0 => rm_strobe_read,
492
                        --reg_in_other0 => ,
493
                        reg_out_other0 => rm_byte_out,
494
 
495
                        reg_strobe_other1 => wm_write_strobe,
496
                        reg_in_other1 => wm_data_in,
497
                        reg_out_other1 => "0000000000000000"
498
                );
499
 
500
end arch;
501
 

powered by: WebSVN 2.1.0

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