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

Subversion Repositories socgen

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 135 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_sm
26
    #( parameter
27
      NUM_USER=2,
28
      INST_LENGTH=4,
29
      INST_RESET=4'b1111,
30
      INST_RETURN=4'b1101,
31
      BYPASS=4'b1111,
32
      CHIP_ID_ACCESS=4'b0011,
33
      CLAMP=4'b1000,
34
      EXTEST=4'b0000,
35
      HIGHZ_MODE=4'b0010,
36
      RPC_ADD=4'b1001,
37
      RPC_DATA=4'b1010,
38
      SAMPLE=4'b0001
39
      )
40
 
41
     (
42
 input wire               clk,
43
 input wire               clk_n,
44
 input wire               reset_n,
45
 
46
 input wire [NUM_USR-1:0] tdo_i,
47
 input wire               bsr_tdo_i,
48
 input wire               tdi_pad_in,
49
 input wire               tms_pad_in,
50
 
51
 
52
 
53
 output reg               bsr_output_mode,
54
 output reg               capture_dr_o,
55
 output reg               shift_dr_o,
56
 output reg               tap_highz_mode,
57
 output reg               test_logic_reset_o,
58
 output reg                update_dr_o,
59
 
60
 output wire               tdi_o,
61
 output wire [NUM_USR-1:0] select_o,
62
 output wire tdo_pad_oe,
63
 output wire tdo_pad_out,
64
 output wire jtag_clk,
65
 output wire update_dr_clk_o,
66
 output wire shiftcapture_dr_clk_o,
67
 output wire bsr_select_o
68
);
69
 
70
assign jtag_clk = clk;
71
 
72
//********************************************************************
73
//*** TAP Controller State Machine
74
//********************************************************************
75
 
76
 
77
// TAP state parameters
78
localparam TEST_LOGIC_RESET = 4'b1111,
79
           RUN_TEST_IDLE    = 4'b1100,
80
           SELECT_DR_SCAN   = 4'b0111,
81
           CAPTURE_DR       = 4'b0110,
82
           SHIFT_DR         = 4'b0010,
83
           EXIT1_DR         = 4'b0001,
84
           PAUSE_DR         = 4'b0011,
85
           EXIT2_DR         = 4'b0000,
86
           UPDATE_DR        = 4'b0101,
87
           SELECT_IR_SCAN   = 4'b0100,
88
           CAPTURE_IR       = 4'b1110,
89
           SHIFT_IR         = 4'b1010,
90
           EXIT1_IR         = 4'b1001,
91
           PAUSE_IR         = 4'b1011,
92
           EXIT2_IR         = 4'b1000,
93
           UPDATE_IR        = 4'b1101;
94
 
95
 
96
 
97
// next state decode for tap controller
98
always @(*)
99
    case (tap_state)    // synopsys parallel_case
100
      TEST_LOGIC_RESET: next_tap_state = tms_pad_in ? TEST_LOGIC_RESET : RUN_TEST_IDLE;
101
      RUN_TEST_IDLE:    next_tap_state = tms_pad_in ? SELECT_DR_SCAN   : RUN_TEST_IDLE;
102
      SELECT_DR_SCAN:   next_tap_state = tms_pad_in ? SELECT_IR_SCAN   : CAPTURE_DR;
103
      CAPTURE_DR:       next_tap_state = tms_pad_in ? EXIT1_DR         : SHIFT_DR;
104
      SHIFT_DR:         next_tap_state = tms_pad_in ? EXIT1_DR         : SHIFT_DR;
105
      EXIT1_DR:         next_tap_state = tms_pad_in ? UPDATE_DR        : PAUSE_DR;
106
      PAUSE_DR:         next_tap_state = tms_pad_in ? EXIT2_DR         : PAUSE_DR;
107
      EXIT2_DR:         next_tap_state = tms_pad_in ? UPDATE_DR        : SHIFT_DR;
108
      UPDATE_DR:        next_tap_state = tms_pad_in ? SELECT_DR_SCAN   : RUN_TEST_IDLE;
109
      SELECT_IR_SCAN:   next_tap_state = tms_pad_in ? TEST_LOGIC_RESET : CAPTURE_IR;
110
      CAPTURE_IR:       next_tap_state = tms_pad_in ? EXIT1_IR         : SHIFT_IR;
111
      SHIFT_IR:         next_tap_state = tms_pad_in ? EXIT1_IR         : SHIFT_IR;
112
      EXIT1_IR:         next_tap_state = tms_pad_in ? UPDATE_IR        : PAUSE_IR;
113
      PAUSE_IR:         next_tap_state = tms_pad_in ? EXIT2_IR         : PAUSE_IR;
114
      EXIT2_IR:         next_tap_state = tms_pad_in ? UPDATE_IR        : SHIFT_IR;
115
      UPDATE_IR:        next_tap_state = tms_pad_in ? SELECT_DR_SCAN   : RUN_TEST_IDLE;
116
    endcase
117
 
118
 
119
//********************************************************************
120
//*** TAP Controller State Machine Register
121
//********************************************************************
122
 
123
 
124
always @(posedge jtag_clk or negedge reset_n)
125
  if (!reset_n)     tap_state <= TEST_LOGIC_RESET;
126
  else              tap_state <= next_tap_state;
127
 
128
 
129
// Decode tap_state to get Shift, Update, and Capture signals
130
 
131
 
132
 
133
 always @(*)
134
   begin
135
   shift_ir     = (tap_state == SHIFT_IR);
136
   shift_dr_o   = (tap_state == SHIFT_DR);
137
   update_ir    = (tap_state == UPDATE_IR);
138
   update_dr_o  = (tap_state == UPDATE_DR);
139
   capture_dr_o = (tap_state == CAPTURE_DR);
140
   capture_ir   = (tap_state == CAPTURE_IR);
141
  end
142
 
143
 
144
// Decode tap_state to get test_logic_reset  signal
145
 
146
always @(posedge jtag_clk  or negedge reset_n)
147
if (!reset_n)                               test_logic_reset_o <= 1'b1;
148
else
149
if (next_tap_state == TEST_LOGIC_RESET)    test_logic_reset_o <= 1'b1;
150
else                                       test_logic_reset_o <= 1'b0;
151
 
152
 
153
//******************************************************
154
//*** Instruction Register
155
//******************************************************
156
 
157
reg     [INST_LENGTH-1:0]      instruction_buffer;
158
reg     [INST_LENGTH-1:0]      instruction;
159
 
160
// buffer the instruction register while shifting
161
 
162
always @(posedge jtag_clk or negedge reset_n)
163
  if (!reset_n)                instruction_buffer <= INST_RESET;
164
  else
165
  if (capture_ir)              instruction_buffer <= INST_RETURN;
166
  else
167
  if (shift_ir)                instruction_buffer <= {tdi_pad_in,instruction_buffer[INST_LENGTH-1:1]};
168
 
169
always @(posedge jtag_clk  or negedge reset_n)
170
  if (!reset_n)                   instruction <= INST_RESET;
171
  else
172
  if (tap_state == TEST_LOGIC_RESET)    instruction <= INST_RESET;
173
  else
174
  if (update_ir)                        instruction <= instruction_buffer;
175
 
176
 
177
 
178
 
179
 
180
assign shiftcapture_dr  =  shift_dr_o || capture_dr_o;
181
assign tdi_o             =  tdi_pad_in;
182
 
183
 
184
// Instruction Decoder
185
assign  extest          = ( instruction == EXTEST );
186
assign  sample          = ( instruction == SAMPLE );
187
assign  clamp           = ( instruction == CLAMP );
188
assign  chip_id_select  = ( instruction == CHIP_ID_ACCESS );
189
 
190
 
191
// bypass anytime we are not doing a defined instructions, or if in clamp or bypass mode
192
 
193
assign   bypass_select  = ( instruction == CLAMP ) || ( instruction == BYPASS );
194
 
195
assign  shiftcapture_dr_clk_o     =  jtag_shift_clk;
196
assign  bsr_select_o              = ( instruction == EXTEST ) || ( instruction == SAMPLE )       ;
197
 
198
assign  select_o[0]               = ( instruction == RPC_ADD );
199
assign  select_o[1]               = ( instruction == RPC_DATA );
200
 
201
 
202
 
203
//**********************************************************
204
//** Boundary scan control signals
205
//**********************************************************
206
 
207
 
208
 
209
always @(posedge jtag_clk  or negedge reset_n)
210
  if (!reset_n)                                   bsr_output_mode <= 1'b0;
211
  else
212
  if (tap_state == TEST_LOGIC_RESET)              bsr_output_mode <= 1'b0;
213
  else
214
  if (update_ir)                                  bsr_output_mode <=    (instruction_buffer  == EXTEST)
215
                                                              || (instruction_buffer  == CLAMP);
216
 
217
 
218
// Control chip pads when we are in highz_mode
219
 
220
always @(posedge jtag_clk  or negedge reset_n)
221
  if (!reset_n)                                 tap_highz_mode <= 1'b0;
222
  else if (tap_state == TEST_LOGIC_RESET)      tap_highz_mode <= 1'b0;
223
  else if (update_ir)                          tap_highz_mode <= (instruction_buffer  == HIGHZ_MODE);
224
 
225
 
226
 
227
 
228
 
229
 
230
//**********************************************************
231
//*** Bypass register
232
//**********************************************************
233
 
234
always @(posedge jtag_clk or negedge trst_n_pad_in)
235
  if (!trst_n_pad_in)         bypass_tdo <= 1'b0;
236
  else
237
  if (capture_dr_o)           bypass_tdo <= 1'b0;
238
  else
239
  if (shift_dr_o)             bypass_tdo <= tdi_pad_in;
240
  else                        bypass_tdo <= bypass_tdo;
241
 
242
 
243
//****************************************************************
244
//*** Choose what goes out on the TDO pin
245
//****************************************************************
246
 
247
 
248
// output the instruction register when tap_state[3] is 1, else
249
//   put out the appropriate data register.  
250
 
251
 
252
 
253
always@(*)
254
  begin
255
     if( tap_state[3] )       next_tdo  =  instruction_buffer[0];
256
     else
257
     if(bypass_select)        next_tdo  =  bypass_tdo;
258
     else
259
     if(chip_id_select)       next_tdo  =  chip_id_tdo;
260
     else
261
     if(select_o[0])          next_tdo  =  tdo_i[0];
262
     else
263
     if(select_o[1])          next_tdo  =  tdo_i[1];
264
     else                     next_tdo  =  1'b0;
265
  end
266
 
267
 
268
reg tdo_pad_out_reg;
269
reg tdo_pad_oe_reg;
270
 
271
always @(posedge clk_n or negedge reset_n)
272
        if (!reset_in)         tdo_pad_out_reg <= 1'b0;
273
        else                        tdo_pad_out_reg <= next_tdo;
274
 
275
 
276
 
277
// output enable for TDO pad
278
 
279
always @(posedge clk_n or negedge reset_n)
280
        if ( !reset_n )    tdo_pad_oe_reg   <= 1'b0;
281
        else                     tdo_pad_oe_reg   <= ( (tap_state == SHIFT_DR) || (tap_state == SHIFT_IR) );
282
 
283
 
284
 
285
assign tdo_pad_out = tdo_pad_out_reg;
286
assign tdo_pad_oe  = tdo_pad_oe_reg;
287
 
288
`ifndef SYNTHESIS
289
 
290
reg [8*16-1:0] tap_string;
291
 
292
always @(tap_state) begin
293
   case (tap_state)
294
      TEST_LOGIC_RESET: tap_string = "TEST_LOGIC_RESET";
295
      RUN_TEST_IDLE:    tap_string = "RUN_TEST_IDLE";
296
      SELECT_DR_SCAN:   tap_string = "SELECT_DR_SCAN";
297
      CAPTURE_DR:       tap_string = "CAPTURE_DR";
298
      SHIFT_DR:         tap_string = "SHIFT_DR";
299
      EXIT1_DR:         tap_string = "EXIT1_DR";
300
      PAUSE_DR:         tap_string = "PAUSE_DR";
301
      EXIT2_DR:         tap_string = "EXIT2_DR";
302
      UPDATE_DR:        tap_string = "UPDATE_DR";
303
      SELECT_IR_SCAN:   tap_string = "SELECT_IR_SCAN";
304
      CAPTURE_IR:       tap_string = "CAPTURE_IR";
305
      SHIFT_IR:         tap_string = "SHIFT_IR";
306
      EXIT1_IR:         tap_string = "EXIT1_IR";
307
      PAUSE_IR:         tap_string = "PAUSE_IR";
308
      EXIT2_IR:         tap_string = "EXIT2_IR";
309
      UPDATE_IR:        tap_string = "UPDATE_IR";
310
      default:          tap_string = "-XXXXXX-";
311
   endcase
312
 
313
   $display("%t  %m   Tap State   = %s",$realtime, tap_string);
314
end
315
 
316
 
317
 
318
 
319
reg [8*16-1:0] inst_string;
320
 
321
always @(instruction) begin
322
   case (instruction)
323
      EXTEST:            inst_string = "EXTEST";
324
      SAMPLE:            inst_string = "SAMPLE";
325
      HIGHZ_MODE:        inst_string = "HIGHZ_MODE";
326
      CHIP_ID_ACCESS:    inst_string = "CHIP_ID_ACCESS";
327
      CLAMP:             inst_string = "CLAMP";
328
      RPC_DATA:          inst_string = "RPC_DATA";
329
      RPC_ADD:           inst_string = "RPC_ADD";
330
      BYPASS:            inst_string = "BYPASS";
331
      default:           inst_string = "-XXXXXX-";
332
   endcase
333
 
334
   $display("%t  %m   Instruction = %s",$realtime, inst_string);
335
end
336
 
337
`endif
338
 
339
endmodule
340
 

powered by: WebSVN 2.1.0

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