1 |
63 |
julius |
// ----------------------------------------------------------------------------
|
2 |
|
|
|
3 |
|
|
// Main module providing the JTAG interface: definition
|
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 |
|
|
#ifndef JTAG_SC__H
|
32 |
|
|
#define JTAG_SC__H
|
33 |
|
|
|
34 |
|
|
#include "systemc"
|
35 |
|
|
#include "TapAction.h"
|
36 |
|
|
|
37 |
|
|
//! Default size of the FIFO queuing TAP actions
|
38 |
|
|
#define DEFAULT_TAP_FIFO_SIZE 256
|
39 |
|
|
|
40 |
|
|
//! The main JTAG interface module
|
41 |
|
|
|
42 |
|
|
//! This provides a pin interface on one side (to drive JTAG ports on a chip)
|
43 |
|
|
//! and a FIFO on the other, allowing the user to queue JTAG actions.
|
44 |
|
|
|
45 |
|
|
//! The pin interface is:
|
46 |
|
|
//! - sysReset (input) The system reset. When this is asserted, the interface
|
47 |
|
|
//! will do nothing except drive TRST low.
|
48 |
|
|
//! - tck (input) The JTAG clock (supplied externally)
|
49 |
|
|
//! - tdi (output) Drives the TDI pin
|
50 |
|
|
//! - tdo (input) Receives the TDO pin
|
51 |
|
|
//! - tms (output) Drives the TMS pin
|
52 |
|
|
//! - trst (output) Drives the TRST pin
|
53 |
|
|
|
54 |
|
|
//! @note The JTAG pins are reversed, because this module is @b driving the
|
55 |
|
|
//! pins.
|
56 |
|
|
|
57 |
|
|
//! The FIFO allows the user to queue actions, which are of abstract type
|
58 |
|
|
//! TapAction::. This is subclassed to provide specific actions for reset
|
59 |
|
|
//! (TapActionReset::), DR-scan (TapActionDRScan::) and IR-scan
|
60 |
|
|
//! (TapActionIRScan::).
|
61 |
|
|
|
62 |
|
|
//! The size of the FIFO can optionally be specified in the constructor.
|
63 |
|
|
|
64 |
|
|
//! The class provides a method, sensitive to the clock, which reads actions
|
65 |
|
|
//! from the FIFO and processes them, issuing the requisite sequence of
|
66 |
|
|
//! changes of the JTAG pins until the action is complete. It then notifies
|
67 |
|
|
//! the action owner of completion, through an sc_event, which is part of the
|
68 |
|
|
//! ::TapAction class.
|
69 |
|
|
//!
|
70 |
462 |
julius |
class JtagSC:public sc_core::sc_module {
|
71 |
63 |
julius |
public:
|
72 |
|
|
|
73 |
462 |
julius |
// The ports. Note that the naming of the low level JTAG ports is reversed,
|
74 |
|
|
// because we are driving the inputs! */
|
75 |
|
|
sc_core::sc_in < bool > sysReset; //!< The system reset (active high)
|
76 |
63 |
julius |
|
77 |
462 |
julius |
sc_core::sc_in < bool > tck; //!< External JTAG TCK
|
78 |
|
|
sc_core::sc_out < bool > tdi; //!< JTAG TDI pin
|
79 |
|
|
sc_core::sc_in < bool > tdo; //!< JTAG TDO pin
|
80 |
|
|
sc_core::sc_out < bool > tms; //!< JTAG TMS pin
|
81 |
|
|
sc_core::sc_out < bool > trst; //!< JTAG TRST pin
|
82 |
63 |
julius |
|
83 |
462 |
julius |
//! JTAG action queue
|
84 |
|
|
sc_core::sc_fifo < TapAction * >*tapActionQueue;
|
85 |
63 |
julius |
|
86 |
462 |
julius |
// Constructor and destructor
|
87 |
|
|
JtagSC(sc_core::sc_module_name name,
|
88 |
|
|
int fifo_size = DEFAULT_TAP_FIFO_SIZE);
|
89 |
|
|
~JtagSC();
|
90 |
63 |
julius |
|
91 |
|
|
protected:
|
92 |
|
|
|
93 |
462 |
julius |
// Method to process the actions
|
94 |
|
|
void processActions();
|
95 |
63 |
julius |
|
96 |
|
|
private:
|
97 |
|
|
|
98 |
462 |
julius |
//! The TAP state machine
|
99 |
|
|
TapStateMachine * stateMachine;
|
100 |
63 |
julius |
|
101 |
462 |
julius |
//! The next TAP action
|
102 |
|
|
TapAction *currentTapAction;
|
103 |
63 |
julius |
|
104 |
462 |
julius |
}; // JtagSC ()
|
105 |
63 |
julius |
|
106 |
462 |
julius |
#endif // JTAG_SC__H
|