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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [src/] [JtagSC.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
// Main module providing the JTAG interface: 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 "JtagSC.h"
32
 
33 462 julius
SC_HAS_PROCESS(JtagSC);
34 63 julius
 
35
//! Constructor for the JTAG handler.
36
 
37
//! @param[in] name       Name of this module, passed to the parent
38
//!                       constructor. 
39
//! @param[in] fifo_size  Size of the FIFO on which to queue TAP actions.
40
 
41 462 julius
JtagSC::JtagSC(sc_core::sc_module_name name, int fifo_size):
42
sc_module(name), currentTapAction(NULL)
43 63 julius
{
44 462 julius
        tapActionQueue = new sc_core::sc_fifo < TapAction * >(fifo_size);
45
        stateMachine = new TapStateMachine();
46 63 julius
 
47 462 julius
        SC_METHOD(processActions);
48
        sensitive << tck.pos();
49 63 julius
 
50 462 julius
}                               // JtagSC ()
51 63 julius
 
52
//! Destructor for the JTAG handler.
53
 
54
//! Give up our state machine and FIFO
55
 
56 462 julius
JtagSC::~JtagSC()
57 63 julius
{
58 462 julius
        delete stateMachine;
59
        delete tapActionQueue;
60 63 julius
 
61 462 julius
}                               // ~JtagSC ()
62 63 julius
 
63
//! Method to drive the jtag ports.
64
 
65
//! Initial version just drives the reset.
66
 
67
void
68 462 julius
 JtagSC::processActions()
69 63 julius
{
70 462 julius
        // TRST is driven as the inverse of the system reset
71
        trst = !sysReset;
72 63 julius
 
73 462 julius
        // Do nothing else if in CPU reset (active high)
74
        if (sysReset) {
75
                return;
76
        }
77
        // Functions setting the outputs will need bools (they are not generally
78
        // SystemC modules, so don't handle the likes of sc_in<> correctly).
79
        bool tdi_o;
80
        bool tms_o;
81 63 julius
 
82 462 julius
        // Try to get an action if we don't have one
83
        if (NULL == currentTapAction) {
84
                if (false == tapActionQueue->nb_read(currentTapAction)) {
85
                        // Nothing there, so head for Run-Test/Idle state.
86
                        stateMachine->targetState(TAP_RUN_TEST_IDLE, tms_o);
87
                        tms = tms_o;
88 63 julius
 
89 462 julius
                        return;
90
                }
91
        }
92
        // Process the action, notifying the originator when done.
93 63 julius
 
94 462 julius
        if (currentTapAction->process(stateMachine, tdi_o, tdo, tms_o)) {
95
                currentTapAction->getDoneEvent()->notify();
96
                currentTapAction = NULL;
97 63 julius
        }
98 462 julius
        // Select the new TAP state
99
        stateMachine->nextState(tms_o);
100 63 julius
 
101 462 julius
        // Drive the signal ports
102
        tdi = tdi_o;
103
        tms = tms_o;
104 63 julius
 
105 462 julius
}                               // processActions()

powered by: WebSVN 2.1.0

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