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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 63 julius
// ----------------------------------------------------------------------------
2
 
3
// TAP IR-Scan action: 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
// ----------------------------------------------------------------------------
28
 
29
// $Id$
30
 
31
#include "TapActionIRScan.h"
32
#include "TapStateMachine.h"
33
 
34
//! Constructor
35
 
36
//! Sets up the superclass with the SystemC completion event and initializes
37
//! our state as appropriate.
38
 
39
//! @param[in] doneEvent  SystemC event to be signalled when this action is
40
//!                       complete.
41
//! @param[in] _iRegIn    The register to shift in.
42
//! @param[in] _iRegSize  Size in bits of the register to shift in.
43
 
44 462 julius
TapActionIRScan::TapActionIRScan(sc_core::sc_event * _doneEvent,
45
                                 uint32_t _iRegIn,
46
                                 int _iRegSize):TapAction(_doneEvent),
47
iRegIn(_iRegIn),
48
iRegSize(_iRegSize), iRegOut(0), bitsShifted(0), iRScanState(SHIFT_IR_PREPARING)
49 63 julius
{
50
 
51 462 julius
}                               // TapActionIRScan ()
52 63 julius
 
53
//! Process the Shift-IR action
54
 
55
//! This drives the IR-Scan state. We can only do this if we have the TAP
56
//! state machine in a consistent state, which in turn is only possible if we
57
//! have been through a reset cycle.
58
 
59
//! If the state machine shows it has yet to be through a reset cycle, we
60
//! drive that cycle, after issuing a warning. This functionality is provided
61
//! by the parent class, TapAction::.
62
 
63
//! @param[in]  tapStateMachine  The TAP state machine with which this action
64
//!                              is associated. 
65
//! @param[out] tdi              The value to drive on TDI
66
//! @param[in]  tdo              The value currently on TDO
67
//! @param[out] tms              The value to drive on TMS
68
 
69
//! @return  True if the action is complete
70
 
71 462 julius
bool TapActionIRScan::process(TapStateMachine * tapStateMachine,
72
                              bool & tdi, bool tdo, bool & tms)
73 63 julius
{
74 462 julius
        // Ensure we are in a consistent state. If not then we'll have moved towards
75
        // it and can return with the given tms
76
        if (!checkResetDone(tapStateMachine, tms, true)) {
77
                return false;
78
        }
79
        // We are consistent, so work through the IR-Scan process
80
        switch (iRScanState) {
81
        case SHIFT_IR_PREPARING:
82 63 julius
 
83 462 julius
                // Are we in the Shift-IR state yet?
84
                if (!tapStateMachine->targetState(TAP_SHIFT_IR, tms)) {
85
                        return false;   // Not there. Accept the TMS value
86
                } else {
87
                        iRScanState = SHIFT_IR_SHIFTING;        // Drop through
88
                }
89 63 julius
 
90 462 julius
        case SHIFT_IR_SHIFTING:
91 63 julius
 
92 462 julius
                // Are we still shifting stuff?
93
                if (bitsShifted < iRegSize) {
94
                        // We are in the Shift-IR state. Another bit about to be done, so
95
                        // increment the count
96
                        bitsShifted++;
97 63 julius
 
98 462 julius
                        // Shift out the TDI value from the bottom of the register
99
                        tdi = iRegIn & 1;
100
                        iRegIn >>= 1;
101 63 julius
 
102 462 julius
                        // Record the TDO value. This is always a cycle late, so we ignore
103
                        // it the first time. The value shifts in from the top.
104
                        if (bitsShifted > 1) {
105
                                iRegOut >>= 1;  // Move all the existing bits right
106 63 julius
 
107 462 julius
                                if (tdo)        // OR any new bit in
108
                                {
109
                                        uint32_t tmpBit = 1 << (iRegSize - 1);
110
                                        iRegOut |= tmpBit;
111
                                }
112
                        }
113
                        // TMS is 0 to keep us here UNLESS this is the last bit, in which
114
                        // case it is 1 to move us into Exit1-IR.
115
                        tms = (bitsShifted == iRegSize);
116 63 julius
 
117 462 julius
                        return false;
118
                } else {
119
                        // Capture the last TDO bit
120
                        iRegOut >>= 1;  // Move all the existing bits right
121 63 julius
 
122 462 julius
                        if (tdo)        // OR any new bit in
123
                        {
124
                                uint32_t tmpBit = 1 << (iRegSize - 1);
125
                                iRegOut |= tmpBit;
126
                        }
127 63 julius
 
128 462 julius
                        iRScanState = SHIFT_IR_UPDATING;        // Drop through
129
                }
130 63 julius
 
131 462 julius
        case SHIFT_IR_UPDATING:
132 63 julius
 
133 462 julius
                // Are we still trying to update?
134
                if (!tapStateMachine->targetState(TAP_UPDATE_IR, tms)) {
135
                        return false;   // Not there. Accept the TMS value
136
                } else {
137
                        return true;    // All done
138
                }
139 63 julius
        }
140 462 julius
}                               // process ()
141 63 julius
 
142
//! Get the shifted out register
143
 
144
//! @return  The value of the shifted our register
145
 
146 462 julius
uint32_t TapActionIRScan::getIRegOut()
147 63 julius
{
148 462 julius
        return iRegOut;
149 63 julius
 
150 462 julius
}                               // getIRegOut ()

powered by: WebSVN 2.1.0

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