The logger will require a simple TLM 2.0 initiator socket, which
will use the generic payload with a custom extension,
JtagExtensionSC
. The relevant headers are
included.
#include <tlm.h> #include <tlm_utils/simple_initiator_socket.h> #include "JtagExtensionSC.h"
The logger declares an initiator TLM 2.0 port to connect to the target port in the Or1ksim wrapper. This is the public interface to this module.
tlm_utils::simple_initiator_socket<JtagLoggerSC, 1> jtag;
A constructor is needed to connect the extension to the generic payload and to declare the SystemC thread generating JTAG transactions.
JtagLoggerSC (sc_core::sc_module_name name);
The module uses a single allocation of payload and extension. The temptation is to allocate and free these dynamically locally where they are needed. However, as noted earlier (see Section 11.2 this is an expensive operation in SystemC, so we have a single instance of each. The extension will be associated with the payload in the constructor.
tlm::tlm_generic_payload payload; JtagExtensionSC ext;
A SystemC thread is used to generate the traffic, and this is
implemented in the private method, runJtag
.
virtual void runJtag();
The JTAG registers for the Or1ksim debug unit have a complex structure. A set of utility methods is provided to construct the registers.
void jtagReset (sc_core::sc_time &delay); void jtagInstruction (unsigned char inst, sc_core::sc_time &delay); void jtagSelectModule (unsigned char moduleId, sc_core::sc_time &delay); void jtagWriteCommand (unsigned char accessType, unsigned long int addr, unsigned long int numBytes, sc_core::sc_time &delay); void jtagGoCommandRead (unsigned char data[], unsigned long int dataBytes, sc_core::sc_time &delay); // Utilities unsigned long int crc32 (unsigned long long int value, int num_bits, unsigned long int crc_in); unsigned long long reverseBits (unsigned long long val, int len);
The definition of the JTAG logger module class,
JtagLoggerSC
may be found in
sys-models/jtag-soc/JtagLoggerSC.h
in the
distribution.