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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [src/] [TapStateMachine.cpp] - Blame information for rev 862

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 63 julius
// ----------------------------------------------------------------------------
2
 
3
// The TAP state machine: implementation
4
 
5
// Copyright (C) 2009  Embecosm Limited <info@embecosm.com>
6
 
7
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
 
9
// This file is part of the Embecosm cycle accurate SystemC JTAG library.
10
 
11
// This program is free software: you can redistribute it and/or modify it
12
// under the terms of the GNU Lesser General Public License as published by
13
// the Free Software Foundation, either version 3 of the License, or (at your
14
// option) any later version.
15
 
16
// This program is distributed in the hope that it will be useful, but WITHOUT
17
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
19
// License for more details.
20
 
21
// You should have received a copy of the GNU Lesser General Public License
22
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 
24
// The C/C++ parts of this program are commented throughout in a fashion
25
// suitable for processing with Doxygen.
26
 
27
// The C/C++ parts of this program are commented throughout in a fashion
28
// suitable for processing with Doxygen.
29
 
30
// ----------------------------------------------------------------------------
31
 
32
// $Id$
33
 
34
#include "TapStateMachine.h"
35
 
36
//! Constructor
37
 
38
//! Start in the Test-Logic-Reset state, although we cannot know this reflects
39
//! the hardware until it has been through a TAP reset sequence. This is
40
//! reflected in the ::tapResetDone flag.
41
 
42 462 julius
TapStateMachine::TapStateMachine():
43
state(TAP_TEST_LOGIC_RESET), resetDone(false)
44 63 julius
{
45
 
46 462 julius
}                               // TapStateMachine ()
47 63 julius
 
48
//! Accessor to get the current TAP state
49
 
50
//! Only guaranteed to match the target hardware if it has been through a
51
//! reset sequence.
52
 
53
//! @return  The current TAP state
54 462 julius
TapState TapStateMachine::getState()
55 63 julius
{
56 462 julius
        return state;
57 63 julius
 
58 462 julius
}                               // getState ()
59 63 julius
 
60
//! Accessor to get the current TAP reset state.
61
 
62
//! It is the responsibility of classes using this class to correctly set this
63
//! state.
64
 
65
//! @return  The current TAP reset state
66 462 julius
bool TapStateMachine::getResetDone()
67 63 julius
{
68 462 julius
        return resetDone;
69 63 julius
 
70 462 julius
}                               // getResetDone ()
71 63 julius
 
72
//! Accessor to set the current TAP reset state.
73
 
74
//! It is the responsibility of classes using this class to correctly set this
75
//! state.
76
 
77
//! @param[in]  The desired TAP reset state
78 462 julius
void TapStateMachine::setResetDone(bool _resetDone)
79 63 julius
{
80 462 julius
        resetDone = _resetDone;
81 63 julius
 
82 462 julius
}                               // setResetDone ()
83 63 julius
 
84
//! Drive the TAP state machine
85
 
86
//! @param tms       The JTAG TMS pin
87 462 julius
void TapStateMachine::nextState(bool tms)
88 63 julius
{
89 462 julius
        static const TapState mapHigh[TAP_SIZE] = {     // When TMS = 1/true          
90
                TAP_TEST_LOGIC_RESET,   // from TAP_TEST_LOGIC_RESET  
91
                TAP_SELECT_DR_SCAN,     // from TAP_RUN_TEST_IDLE     
92
                TAP_SELECT_IR_SCAN,     // from TAP_SELECT_DR_SCAN    
93
                TAP_EXIT1_DR,   // from TAP_CAPTURE_DR        
94
                TAP_EXIT1_DR,   // from TAP_SHIFT_DR          
95
                TAP_UPDATE_DR,  // from TAP_EXIT1_DR          
96
                TAP_EXIT2_DR,   // from TAP_PAUSE_DR          
97
                TAP_UPDATE_DR,  // from TAP_EXIT2_DR          
98
                TAP_SELECT_DR_SCAN,     // from TAP_UPDATE_DR         
99
                TAP_TEST_LOGIC_RESET,   // from TAP_SELECT_IR_SCAN    
100
                TAP_EXIT1_IR,   // from TAP_CAPTURE_IR        
101
                TAP_EXIT1_IR,   // from TAP_SHIFT_IR          
102
                TAP_UPDATE_IR,  // from TAP_EXIT1_IR          
103
                TAP_EXIT2_IR,   // from TAP_PAUSE_IR          
104
                TAP_UPDATE_IR,  // from TAP_EXIT2_IR          
105
                TAP_SELECT_DR_SCAN
106
        };                      // from TAP_UPDATE_IR         
107 63 julius
 
108 462 julius
        static const TapState mapLow[TAP_SIZE] = {      // When TMS = 0/false
109
                TAP_RUN_TEST_IDLE,      // from TAP_TEST_LOGIC_RESET
110
                TAP_RUN_TEST_IDLE,      // from TAP_RUN_TEST_IDLE   
111
                TAP_CAPTURE_DR, // from TAP_SELECT_DR_SCAN  
112
                TAP_SHIFT_DR,   // from TAP_CAPTURE_DR      
113
                TAP_SHIFT_DR,   // from TAP_SHIFT_DR        
114
                TAP_PAUSE_DR,   // from TAP_EXIT1_DR        
115
                TAP_PAUSE_DR,   // from TAP_PAUSE_DR        
116
                TAP_SHIFT_DR,   // from TAP_EXIT2_DR        
117
                TAP_RUN_TEST_IDLE,      // from TAP_UPDATE_DR       
118
                TAP_CAPTURE_IR, // from TAP_SELECT_IR_SCAN  
119
                TAP_SHIFT_IR,   // from TAP_CAPTURE_IR      
120
                TAP_SHIFT_IR,   // from TAP_SHIFT_IR        
121
                TAP_PAUSE_IR,   // from TAP_EXIT1_IR        
122
                TAP_PAUSE_IR,   // from TAP_PAUSE_IR        
123
                TAP_SHIFT_IR,   // from TAP_EXIT2_IR        
124
                TAP_RUN_TEST_IDLE
125
        };                      // from TAP_UPDATE_IR         
126 63 julius
 
127 462 julius
        state = tms ? mapHigh[state] : mapLow[state];
128 63 julius
 
129 462 julius
}                               // nextState()
130 63 julius
 
131
//! Determine if we are in a particular TAP state
132
 
133
//! Set TMS to get there optimally
134
 
135
//! @param[in]  target  The desired TAP state
136
//! @param[out] tms     Value of TMS to move towards the target state. Set
137
//!                     even if we are already in the state (in case we want
138
//!                     to loop).
139
 
140
//! @return  True if we are already in the target state
141 462 julius
bool TapStateMachine::targetState(TapState target, bool & tms)
142 63 julius
{
143 462 julius
        // Map of the value of TMS which moves the state machine from the the state
144
        // in the row (first) to the state in the column (second)
145
        static const bool map[TAP_SIZE][TAP_SIZE] = {
146
                //  T  R  S  C  S  E  P  E  U  S  C  S  E  P  E  U 
147
                //  L  T  D  D  D  1  D  2  D  I  I  I  1  I  2  I
148
                //  R  I  R  R  R  D  R  D  R  R  R  R  I  R  I  R
149
                //        S        R     R     S        R     R
150
                {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},      // map[TLR][x]
151
                {1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},        // map[RTI][x]
152
                {1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1},     // map[SDRS][x]
153
                {1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},        // map[CDR][x]
154
                {1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},        // map[SDR][x]
155
                {1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1},   // map[E1DR][x]
156
                {1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1},        // map[PDR][x]
157
                {1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1},   // map[E2DR][x]
158
                {1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},        // map[UDR][x]
159
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},     // map[SIRS][x]
160
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1},        // map[CIR][x]
161
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1},        // map[SIR][x]
162
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1},   // map[E1IR][x]
163
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1},        // map[PIR][x]
164
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1},   // map[E2IR][x]
165
                {1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
166
        };                      // map[UIR][x]
167 63 julius
 
168 462 julius
        tms = map[state][target];
169
        return state == target;
170 63 julius
 
171 462 julius
}                               // targetState()

powered by: WebSVN 2.1.0

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