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 133

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

powered by: WebSVN 2.1.0

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