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 131

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

powered by: WebSVN 2.1.0

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