Line 28... |
Line 28... |
|
|
// $Id$
|
// $Id$
|
|
|
#include "JtagSC.h"
|
#include "JtagSC.h"
|
|
|
|
|
SC_HAS_PROCESS( JtagSC );
|
SC_HAS_PROCESS( JtagSC );
|
|
|
//! Constructor for the JTAG handler.
|
//! Constructor for the JTAG handler.
|
|
|
//! @param[in] name Name of this module, passed to the parent
|
//! @param[in] name Name of this module, passed to the parent
|
//! constructor.
|
//! constructor.
|
//! @param[in] fifo_size Size of the FIFO on which to queue TAP actions.
|
//! @param[in] fifo_size Size of the FIFO on which to queue TAP actions.
|
|
|
JtagSC::JtagSC (sc_core::sc_module_name name,
|
JtagSC::JtagSC(sc_core::sc_module_name name, int fifo_size):
|
int fifo_size) :
|
sc_module(name), currentTapAction(NULL)
|
sc_module (name),
|
|
currentTapAction (NULL)
|
|
{
|
{
|
tapActionQueue = new sc_core::sc_fifo<TapAction *> (fifo_size);
|
tapActionQueue = new sc_core::sc_fifo<TapAction *> (fifo_size);
|
stateMachine = new TapStateMachine ();
|
stateMachine = new TapStateMachine ();
|
|
|
SC_METHOD (processActions);
|
SC_METHOD (processActions);
|
sensitive << tck.pos ();
|
sensitive << tck.pos ();
|
|
|
} // JtagSC ()
|
} // JtagSC ()
|
|
|
|
|
//! Destructor for the JTAG handler.
|
//! Destructor for the JTAG handler.
|
|
|
//! Give up our state machine and FIFO
|
//! Give up our state machine and FIFO
|
|
|
JtagSC::~JtagSC ()
|
JtagSC::~JtagSC ()
|
Line 62... |
Line 58... |
delete stateMachine;
|
delete stateMachine;
|
delete tapActionQueue;
|
delete tapActionQueue;
|
|
|
} // ~JtagSC ()
|
} // ~JtagSC ()
|
|
|
|
|
//! Method to drive the jtag ports.
|
//! Method to drive the jtag ports.
|
|
|
//! Initial version just drives the reset.
|
//! Initial version just drives the reset.
|
|
|
void
|
void
|
Line 74... |
Line 69... |
{
|
{
|
// TRST is driven as the inverse of the system reset
|
// TRST is driven as the inverse of the system reset
|
trst = !sysReset;
|
trst = !sysReset;
|
|
|
// Do nothing else if in CPU reset (active high)
|
// Do nothing else if in CPU reset (active high)
|
if (sysReset)
|
if (sysReset) {
|
{
|
|
return;
|
return;
|
}
|
}
|
|
|
// Functions setting the outputs will need bools (they are not generally
|
// Functions setting the outputs will need bools (they are not generally
|
// SystemC modules, so don't handle the likes of sc_in<> correctly).
|
// SystemC modules, so don't handle the likes of sc_in<> correctly).
|
bool tdi_o;
|
bool tdi_o;
|
bool tms_o;
|
bool tms_o;
|
|
|
// Try to get an action if we don't have one
|
// Try to get an action if we don't have one
|
if (NULL == currentTapAction)
|
if (NULL == currentTapAction) {
|
{
|
if (false == tapActionQueue->nb_read(currentTapAction)) {
|
if (false == tapActionQueue->nb_read (currentTapAction))
|
|
{
|
|
// Nothing there, so head for Run-Test/Idle state.
|
// Nothing there, so head for Run-Test/Idle state.
|
stateMachine->targetState (TAP_RUN_TEST_IDLE, tms_o);
|
stateMachine->targetState (TAP_RUN_TEST_IDLE, tms_o);
|
tms = tms_o;
|
tms = tms_o;
|
|
|
return;
|
return;
|
}
|
}
|
}
|
}
|
|
|
// Process the action, notifying the originator when done.
|
// Process the action, notifying the originator when done.
|
|
|
if (currentTapAction->process (stateMachine, tdi_o, tdo, tms_o))
|
if (currentTapAction->process(stateMachine, tdi_o, tdo, tms_o)) {
|
{
|
|
currentTapAction->getDoneEvent()->notify();
|
currentTapAction->getDoneEvent()->notify();
|
currentTapAction = NULL;
|
currentTapAction = NULL;
|
}
|
}
|
|
|
// Select the new TAP state
|
// Select the new TAP state
|
stateMachine->nextState (tms_o);
|
stateMachine->nextState (tms_o);
|
|
|
// Drive the signal ports
|
// Drive the signal ports
|
tdi = tdi_o;
|
tdi = tdi_o;
|