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

Subversion Repositories socgen

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

powered by: WebSVN 2.1.0

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