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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [common/] [opencores.org/] [cde/] [ip/] [jtag/] [rtl/] [verilog/] [jtag_tap] - Blame information for rev 135

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 131 jt_eaton
/**********************************************************************/
2
/*                                                                    */
3
/*                                                                    */
4
/*   Copyright (c) 2012 Ouabache Design Works                         */
5
/*                                                                    */
6
/*          All Rights Reserved Worldwide                             */
7
/*                                                                    */
8
/*   Licensed under the Apache License,Version2.0 (the'License');     */
9
/*   you may not use this file except in compliance with the License. */
10
/*   You may obtain a copy of the License at                          */
11
/*                                                                    */
12
/*       http://www.apache.org/licenses/LICENSE-2.0                   */
13
/*                                                                    */
14
/*   Unless required by applicable law or agreed to in                */
15
/*   writing, software distributed under the License is               */
16
/*   distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES              */
17
/*   OR CONDITIONS OF ANY KIND, either express or implied.            */
18
/*   See the License for the specific language governing              */
19
/*   permissions and limitations under the License.                   */
20
/**********************************************************************/
21
 
22
 
23
 module
24
 
25
  cde_jtag_tap
26
    #( parameter
27 134 jt_eaton
      BYPASS=4'b1111,
28
      CHIP_ID_ACCESS=4'b0011,
29
      CHIP_ID_VAL=32'h12345678,
30
      CLAMP=4'b1000,
31
      EXTEST=4'b0000,
32
      HIGHZ_MODE=4'b0010,
33 131 jt_eaton
      INST_LENGTH=4,
34 134 jt_eaton
      INST_RESET=4'b1111,
35 131 jt_eaton
      INST_RETURN=4'b1101,
36
      NUM_USER=2,
37 134 jt_eaton
      RPC_ADD=4'b1001,
38
      RPC_DATA=4'b1010,
39 131 jt_eaton
      SAMPLE=4'b0001,
40 134 jt_eaton
      USER=8'b1010_1001)
41 131 jt_eaton
 
42
     (
43 134 jt_eaton
 input   wire                  aux_tdo_i,
44
 input   wire                  bsr_tdo_i,
45 131 jt_eaton
 input   wire                  tclk_pad_in,
46
 input   wire                  tdi_pad_in,
47 134 jt_eaton
 input   wire                  tdo_i,
48 131 jt_eaton
 input   wire                  tms_pad_in,
49
 input   wire                  trst_n_pad_in,
50
 
51
 
52 134 jt_eaton
 output   reg                  bsr_output_mode,
53 131 jt_eaton
 output   reg                  capture_dr_o,
54
 output   reg                  shift_dr_o,
55 134 jt_eaton
 output   reg                  tap_highz_mode,
56
 output   reg                  test_logic_reset_o,
57 131 jt_eaton
 output   reg                  update_dr_o,
58
 
59
 
60 134 jt_eaton
 
61 133 jt_eaton
 output   wire                 aux_capture_dr_o,
62 134 jt_eaton
 output   wire                 aux_select_o,
63 133 jt_eaton
 output   wire                 aux_shift_dr_o,
64 134 jt_eaton
 output   wire                 aux_shiftcapture_dr_clk_o,
65
 output   wire                 aux_tdi_o,
66
 output   wire                 aux_test_logic_reset_o,
67
 output   wire                 aux_update_dr_clk_o,
68
 
69
 output   wire                 tdi_o,
70 133 jt_eaton
 output   wire                 select_o,
71 134 jt_eaton
 output  wire                  tdo_pad_oe,
72
 output  wire                  tdo_pad_out,
73
 output   wire                 jtag_clk,
74
 output   wire                 update_dr_clk_o,
75
 output   wire                 shiftcapture_dr_clk_o,
76
 output   wire                 bsr_select_o
77 131 jt_eaton
);
78
 
79
 
80
 
81
 
82
 
83
reg                        bypass_tdo;
84
reg                        capture_ir;
85
reg                        next_tdo;
86
reg                        shift_ir;
87
reg                        update_ir;
88
reg     [ 3 :  0]              next_tap_state;
89
reg     [ 3 :  0]              tap_state;
90
wire                        bypass_select;
91
wire                        chip_id_select;
92
wire                        chip_id_tdo;
93
wire                        clamp;
94
wire                        extest;
95
wire                        sample;
96
wire                        tclk;
97
wire                        tclk_n;
98
wire                        trst_pad_in;
99
wire                        jtag_shift_clk;
100 134 jt_eaton
wire                        aux_update_dr_o;
101
wire                        aux_jtag_clk;
102 131 jt_eaton
 
103 133 jt_eaton
 
104
 
105 131 jt_eaton
////////////////////////////////////////////////////////////////
106
cde_clock_gater
107
clk_gater_jtag_shift_clk
108
   (
109
   .atg_clk_mode    (1'b0),
110
   .clk_in          (tclk),
111
   .clk_out         (jtag_shift_clk),
112 134 jt_eaton
   .enable          (shiftcapture_dr));
113 131 jt_eaton
 
114
cde_clock_gater
115
clk_gater_jtag_update_clk
116
   (
117
   .atg_clk_mode    (1'b0),
118
   .clk_in          (tclk),
119
   .clk_out         (update_dr_clk_o),
120
   .enable          (update_dr_o));
121
 
122
cde_clock_gater
123
clk_gater_jtag_clk
124
   (
125
   .atg_clk_mode    (1'b0),
126
   .clk_in          (tclk),
127
   .clk_out         (jtag_clk),
128
   .enable          (1'b1));
129
 
130
 
131
 
132
 
133
 
134
 
135
cde_jtag_rpc_in_reg
136
#( .BITS (32),
137
   .RESET_VALUE (CHIP_ID_VAL))
138
chip_id_reg
139
   (
140
   .capture_dr       (capture_dr_o),
141
   .capture_value    (CHIP_ID_VAL),
142
   .clk              (jtag_clk),
143
   .reset            (trst_pad_in),
144
   .select           (chip_id_select),
145
   .shift_dr         (shift_dr_o),
146
   .tdi              (tdi_pad_in),
147
   .tdo              (chip_id_tdo));
148
 
149 134 jt_eaton
 
150
 
151
 
152
 
153
 
154
 
155
 
156 131 jt_eaton
//********************************************************************
157 134 jt_eaton
//*** assignments for 2nd channel
158
//********************************************************************
159
 
160
 
161
 assign      aux_jtag_clk               = jtag_clk;
162
 assign      aux_update_dr_clk_o        = update_dr_clk_o;
163
 assign      aux_shiftcapture_dr_clk_o  = shiftcapture_dr_clk_o;
164
 assign      aux_test_logic_reset_o     = test_logic_reset_o;
165
 assign      aux_tdi_o                  = tdi_o;
166
 assign      aux_capture_dr_o           = capture_dr_o;
167
 assign      aux_shift_dr_o             = shift_dr_o;
168
 assign      aux_update_dr_o            = update_dr_o;
169
 
170
 
171
 
172
//********************************************************************
173 131 jt_eaton
//*** TAP Controller State Machine
174
//********************************************************************
175
 
176
 
177
// TAP state parameters
178
localparam TEST_LOGIC_RESET = 4'b1111,
179
           RUN_TEST_IDLE    = 4'b1100,
180
           SELECT_DR_SCAN   = 4'b0111,
181
           CAPTURE_DR       = 4'b0110,
182
           SHIFT_DR         = 4'b0010,
183
           EXIT1_DR         = 4'b0001,
184
           PAUSE_DR         = 4'b0011,
185
           EXIT2_DR         = 4'b0000,
186
           UPDATE_DR        = 4'b0101,
187
           SELECT_IR_SCAN   = 4'b0100,
188
           CAPTURE_IR       = 4'b1110,
189
           SHIFT_IR         = 4'b1010,
190
           EXIT1_IR         = 4'b1001,
191
           PAUSE_IR         = 4'b1011,
192
           EXIT2_IR         = 4'b1000,
193
           UPDATE_IR        = 4'b1101;
194
 
195
 
196
 
197
// next state decode for tap controller
198
always @(*)
199
    case (tap_state)    // synopsys parallel_case
200
      TEST_LOGIC_RESET: next_tap_state = tms_pad_in ? TEST_LOGIC_RESET : RUN_TEST_IDLE;
201
      RUN_TEST_IDLE:    next_tap_state = tms_pad_in ? SELECT_DR_SCAN   : RUN_TEST_IDLE;
202
      SELECT_DR_SCAN:   next_tap_state = tms_pad_in ? SELECT_IR_SCAN   : CAPTURE_DR;
203
      CAPTURE_DR:       next_tap_state = tms_pad_in ? EXIT1_DR         : SHIFT_DR;
204
      SHIFT_DR:         next_tap_state = tms_pad_in ? EXIT1_DR         : SHIFT_DR;
205
      EXIT1_DR:         next_tap_state = tms_pad_in ? UPDATE_DR        : PAUSE_DR;
206
      PAUSE_DR:         next_tap_state = tms_pad_in ? EXIT2_DR         : PAUSE_DR;
207
      EXIT2_DR:         next_tap_state = tms_pad_in ? UPDATE_DR        : SHIFT_DR;
208
      UPDATE_DR:        next_tap_state = tms_pad_in ? SELECT_DR_SCAN   : RUN_TEST_IDLE;
209
      SELECT_IR_SCAN:   next_tap_state = tms_pad_in ? TEST_LOGIC_RESET : CAPTURE_IR;
210
      CAPTURE_IR:       next_tap_state = tms_pad_in ? EXIT1_IR         : SHIFT_IR;
211
      SHIFT_IR:         next_tap_state = tms_pad_in ? EXIT1_IR         : SHIFT_IR;
212
      EXIT1_IR:         next_tap_state = tms_pad_in ? UPDATE_IR        : PAUSE_IR;
213
      PAUSE_IR:         next_tap_state = tms_pad_in ? EXIT2_IR         : PAUSE_IR;
214
      EXIT2_IR:         next_tap_state = tms_pad_in ? UPDATE_IR        : SHIFT_IR;
215
      UPDATE_IR:        next_tap_state = tms_pad_in ? SELECT_DR_SCAN   : RUN_TEST_IDLE;
216
    endcase
217
 
218
 
219
//********************************************************************
220
//*** TAP Controller State Machine Register
221
//********************************************************************
222
 
223
 
224
always @(posedge jtag_clk or negedge trst_n_pad_in)
225
  if (!trst_n_pad_in)     tap_state <= TEST_LOGIC_RESET;
226
  else             tap_state <= next_tap_state;
227
 
228
 
229
// Decode tap_state to get Shift, Update, and Capture signals
230
 
231
 
232
 
233
 always @(*)
234
   begin
235
   shift_ir     = (tap_state == SHIFT_IR);
236
   shift_dr_o   = (tap_state == SHIFT_DR);
237
   update_ir    = (tap_state == UPDATE_IR);
238
   update_dr_o  = (tap_state == UPDATE_DR);
239
   capture_dr_o = (tap_state == CAPTURE_DR);
240
   capture_ir   = (tap_state == CAPTURE_IR);
241
  end
242
 
243
 
244
// Decode tap_state to get test_logic_reset  signal
245
 
246
always @(posedge jtag_clk  or negedge trst_n_pad_in)
247
if (!trst_n_pad_in)                               test_logic_reset_o <= 1'b1;
248
else
249
if (next_tap_state == TEST_LOGIC_RESET)    test_logic_reset_o <= 1'b1;
250
else                                       test_logic_reset_o <= 1'b0;
251
 
252
 
253
//******************************************************
254
//*** Instruction Register
255
//******************************************************
256
 
257
reg     [INST_LENGTH-1:0]      instruction_buffer;
258
reg     [INST_LENGTH-1:0]      instruction;
259
 
260
// buffer the instruction register while shifting
261
 
262
always @(posedge jtag_clk or negedge trst_n_pad_in)
263
  if (!trst_n_pad_in)          instruction_buffer <= INST_RESET;
264
  else
265
  if (capture_ir)              instruction_buffer <= INST_RETURN;
266
  else
267
  if (shift_ir)                instruction_buffer <= {tdi_pad_in,instruction_buffer[INST_LENGTH-1:1]};
268
 
269
always @(posedge jtag_clk  or negedge trst_n_pad_in)
270
  if (!trst_n_pad_in)                   instruction <= INST_RESET;
271
  else
272
  if (tap_state == TEST_LOGIC_RESET)    instruction <= INST_RESET;
273
  else
274
  if (update_ir)                        instruction <= instruction_buffer;
275
 
276
 
277
 
278
 
279
 
280
 
281
assign tclk              =  tclk_pad_in;
282
assign tclk_n            = !tclk_pad_in;
283 134 jt_eaton
assign shiftcapture_dr   =  shift_dr_o || capture_dr_o;
284 131 jt_eaton
assign tdi_o             =  tdi_pad_in;
285
assign trst_pad_in       = !trst_n_pad_in;
286
 
287
// Instruction Decoder
288
assign  extest          = ( instruction == EXTEST );
289
assign  sample          = ( instruction == SAMPLE );
290
assign  clamp           = ( instruction == CLAMP );
291
assign  chip_id_select  = ( instruction == CHIP_ID_ACCESS );
292
 
293
 
294
// bypass anytime we are not doing a defined instructions, or if in clamp or bypass mode
295
 
296
assign   bypass_select  = ( instruction == CLAMP ) || ( instruction == BYPASS );
297
 
298
assign  shiftcapture_dr_clk_o     =  jtag_shift_clk;
299 133 jt_eaton
assign  select_o                  = ( instruction == RPC_ADD );
300
assign  aux_select_o              = ( instruction == RPC_DATA );
301 131 jt_eaton
assign  bsr_select_o              = ( instruction == EXTEST ) || ( instruction == SAMPLE )       ;
302
 
303
 
304
 
305
 
306
//**********************************************************
307
//** Boundary scan control signals
308
//**********************************************************
309
 
310
 
311
 
312
always @(posedge jtag_clk  or negedge trst_n_pad_in)
313
  if (!trst_n_pad_in)                             bsr_output_mode <= 1'b0;
314
  else
315
  if (tap_state == TEST_LOGIC_RESET)       bsr_output_mode <= 1'b0;
316
  else
317
  if (update_ir)                           bsr_output_mode <=    (instruction_buffer  == EXTEST)
318
                                                              || (instruction_buffer  == CLAMP);
319
 
320
 
321
// Control chip pads when we are in highz_mode
322
 
323
always @(posedge jtag_clk  or negedge trst_n_pad_in)
324
  if (!trst_n_pad_in)                                 tap_highz_mode <= 1'b0;
325
  else if (tap_state == TEST_LOGIC_RESET)      tap_highz_mode <= 1'b0;
326
  else if (update_ir)                          tap_highz_mode <= (instruction_buffer  == HIGHZ_MODE);
327
 
328
 
329
 
330
 
331
 
332
 
333
//**********************************************************
334
//*** Bypass register
335
//**********************************************************
336
 
337
always @(posedge jtag_clk or negedge trst_n_pad_in)
338
  if (!trst_n_pad_in)         bypass_tdo <= 1'b0;
339
  else
340
  if (capture_dr_o)           bypass_tdo <= 1'b0;
341
  else
342
  if (shift_dr_o)             bypass_tdo <= tdi_pad_in;
343
  else                        bypass_tdo <= bypass_tdo;
344
 
345
 
346
//****************************************************************
347
//*** Choose what goes out on the TDO pin
348
//****************************************************************
349
 
350
 
351
// output the instruction register when tap_state[3] is 1, else
352
//   put out the appropriate data register.
353
 
354
 
355
 
356
always@(*)
357
  begin
358
     if( tap_state[3] )    next_tdo =  instruction_buffer[0];
359
     else
360
     if(bypass_select)     next_tdo =  bypass_tdo;
361
     else
362
     if(chip_id_select)    next_tdo =  chip_id_tdo;
363
     else
364 133 jt_eaton
     if(select_o)         next_tdo =  tdo_i;
365 131 jt_eaton
     else
366 133 jt_eaton
     if(aux_select_o)         next_tdo =  aux_tdo_i;
367 131 jt_eaton
     else                  next_tdo =  1'b0;
368
  end
369
 
370
 
371
reg tdo_pad_out_reg;
372
reg tdo_pad_oe_reg;
373
 
374
always @(posedge tclk_n or negedge trst_n_pad_in)
375
        if (!trst_n_pad_in)         tdo_pad_out_reg <= 1'b0;
376
        else                        tdo_pad_out_reg <= next_tdo;
377
 
378
 
379
 
380
// output enable for TDO pad
381
 
382
always @(posedge tclk_n or negedge trst_n_pad_in)
383
        if ( !trst_n_pad_in )    tdo_pad_oe_reg   <= 1'b0;
384
        else                     tdo_pad_oe_reg   <= ( (tap_state == SHIFT_DR) || (tap_state == SHIFT_IR) );
385
 
386
 
387
 
388
assign tdo_pad_out = tdo_pad_out_reg;
389
assign tdo_pad_oe  = tdo_pad_oe_reg;
390
 
391 135 jt_eaton
`ifndef SYNTHESIS
392 131 jt_eaton
 
393
reg [8*16-1:0] tap_string;
394
 
395
always @(tap_state) begin
396
   case (tap_state)
397
      TEST_LOGIC_RESET: tap_string = "TEST_LOGIC_RESET";
398
      RUN_TEST_IDLE:    tap_string = "RUN_TEST_IDLE";
399
      SELECT_DR_SCAN:   tap_string = "SELECT_DR_SCAN";
400
      CAPTURE_DR:       tap_string = "CAPTURE_DR";
401
      SHIFT_DR:         tap_string = "SHIFT_DR";
402
      EXIT1_DR:         tap_string = "EXIT1_DR";
403
      PAUSE_DR:         tap_string = "PAUSE_DR";
404
      EXIT2_DR:         tap_string = "EXIT2_DR";
405
      UPDATE_DR:        tap_string = "UPDATE_DR";
406
      SELECT_IR_SCAN:   tap_string = "SELECT_IR_SCAN";
407
      CAPTURE_IR:       tap_string = "CAPTURE_IR";
408
      SHIFT_IR:         tap_string = "SHIFT_IR";
409
      EXIT1_IR:         tap_string = "EXIT1_IR";
410
      PAUSE_IR:         tap_string = "PAUSE_IR";
411
      EXIT2_IR:         tap_string = "EXIT2_IR";
412
      UPDATE_IR:        tap_string = "UPDATE_IR";
413
      default:          tap_string = "-XXXXXX-";
414
   endcase
415
 
416
   $display("%t  %m   Tap State   = %s",$realtime, tap_string);
417
end
418
 
419
 
420
 
421
 
422
reg [8*16-1:0] inst_string;
423
 
424
always @(instruction) begin
425
   case (instruction)
426
      EXTEST: inst_string = "EXTEST";
427
      SAMPLE: inst_string = "SAMPLE";
428
      HIGHZ_MODE: inst_string = "HIGHZ_MODE";
429
      CHIP_ID_ACCESS: inst_string = "CHIP_ID_ACCESS";
430
      CLAMP: inst_string = "CLAMP";
431
      RPC_DATA: inst_string = "RPC_DATA";
432
      RPC_ADD: inst_string = "RPC_ADD";
433
      BYPASS: inst_string = "BYPASS";
434
      default:          inst_string = "-XXXXXX-";
435
   endcase
436
 
437
   $display("%t  %m   Instruction = %s",$realtime, inst_string);
438
end
439
 
440
`endif
441
 
442
 
443
 
444
 
445
 
446
 
447
 
448
 
449
 
450
 
451
 
452
 
453
 
454
  endmodule
455
 

powered by: WebSVN 2.1.0

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