CPUDyntransComponent Class Reference

Back to the index.

Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CPUDyntransComponent Class Referenceabstract

A base-class for processors Component implementations that use dynamic translation. More...

#include <CPUDyntransComponent.h>

Inheritance diagram for CPUDyntransComponent:
CPUComponent Component AddressDataBus UnitTestable ReferenceCountable I960_CPUComponent M88K_CPUComponent MIPS_CPUComponent

Public Member Functions

 CPUDyntransComponent (const string &className, const string &cpuKind)
 Constructs a CPUDyntransComponent. More...
 
virtual int Execute (GXemul *gxemul, int nrOfCycles)
 Execute one or more cycles. More...
 
- Public Member Functions inherited from CPUComponent
 CPUComponent (const string &className, const string &cpuKind)
 Constructs a CPUComponent. More...
 
SymbolRegistryGetSymbolRegistry ()
 Gets a reference to the CPU's symbol registry. More...
 
const SymbolRegistryGetSymbolRegistry () const
 
virtual void ResetState ()
 Resets the state variables of this component. More...
 
virtual double GetCurrentFrequency () const
 Returns the current frequency (in Hz) that the component runs at. More...
 
virtual CPUComponentAsCPUComponent ()
 Returns the component's CPUComponent interface. More...
 
virtual void GetMethodNames (vector< string > &names) const
 Retrieves a component's implemented method names. More...
 
virtual bool MethodMayBeReexecutedWithoutArgs (const string &methodName) const
 Returns whether a method name may be re-executed without args. More...
 
virtual void ExecuteMethod (GXemul *gxemul, const string &methodName, const vector< string > &arguments)
 Executes a method on the component. More...
 
virtual AddressDataBusAsAddressDataBus ()
 Returns the component's AddressDataBus interface, if any. More...
 
virtual void AddressSelect (uint64_t address)
 Place an address on the bus. More...
 
virtual bool ReadData (uint8_t &data, Endianness endianness)
 Reads 8-bit data from the currently selected address. More...
 
virtual bool ReadData (uint16_t &data, Endianness endianness)
 Reads 16-bit data from the currently selected address. More...
 
virtual bool ReadData (uint32_t &data, Endianness endianness)
 Reads 32-bit data from the currently selected address. More...
 
virtual bool ReadData (uint64_t &data, Endianness endianness)
 Reads 64-bit data from the currently selected address. More...
 
virtual bool WriteData (const uint8_t &data, Endianness endianness)
 Writes 8-bit data to the currently selected address. More...
 
virtual bool WriteData (const uint16_t &data, Endianness endianness)
 Writes 16-bit data to the currently selected address. More...
 
virtual bool WriteData (const uint32_t &data, Endianness endianness)
 Writes 32-bit data to the currently selected address. More...
 
virtual bool WriteData (const uint64_t &data, Endianness endianness)
 Writes 64-bit data to the currently selected address. More...
 
virtual size_t DisassembleInstruction (uint64_t vaddr, size_t maxLen, unsigned char *instruction, vector< string > &result)=0
 Disassembles an instruction into readable strings. More...
 
- Public Member Functions inherited from Component
virtual ~Component ()
 
string GetClassName () const
 Gets the class name of the component. More...
 
string GetVisibleClassName () const
 Gets the visible class name of the component. More...
 
refcount_ptr< ComponentClone () const
 Clones the component and all its children. More...
 
const refcount_ptr< ComponentLightClone () const
 Makes a light clone of the component and all its children. More...
 
void DetectChanges (const refcount_ptr< Component > &oldClone, ostream &changeMessages) const
 Compare an older clone to the current tree, to find changes. More...
 
string GenerateTreeDump (const string &branchTemplate, bool htmlLinksForClassNames=false, string prefixForComponentUrls="") const
 Generates an ASCII tree dump of a component tree. More...
 
virtual string GenerateDetails () const
 Generate details about the component. More...
 
void Reset ()
 Resets the state of this component and all its children. More...
 
bool PreRunCheck (GXemul *gxemul)
 Checks the state of this component and all its children, before starting execution. More...
 
void FlushCachedState ()
 Resets the cached state of this component and all its children. More...
 
virtual RootComponentAsRootComponent ()
 Returns the component's RootComponent interface. More...
 
void SetParent (Component *parentComponent)
 Sets the parent component of this component. More...
 
ComponentGetParent ()
 Gets this component's parent component, if any. More...
 
const ComponentGetParent () const
 
string GeneratePath () const
 Generates a string representation of the path to the Component. More...
 
string GenerateShortestPossiblePath () const
 Generates a short string representation of the path to the Component. More...
 
const refcount_ptr< ComponentLookupPath (string path) const
 Looks up a path from this Component, and returns a pointer to the found Component, if any. More...
 
vector< string > FindPathByPartialMatch (const string &partialPath, bool shortestPossible=false) const
 Finds complete component paths, given a partial path. More...
 
void AddChild (refcount_ptr< Component > childComponent, size_t insertPosition=(size_t) -1)
 Adds a reference to a child component. More...
 
size_t RemoveChild (Component *childToRemove)
 Removes a reference to a child component. More...
 
ComponentsGetChildren ()
 Gets pointers to child components. More...
 
const ComponentsGetChildren () const
 Gets pointers to child components, as a const reference. More...
 
void GetVariableNames (vector< string > &names) const
 Retrieves a component's state variable names. More...
 
StateVariableGetVariable (const string &name)
 Gets a pointer to a state variable. More...
 
const StateVariableGetVariable (const string &name) const
 Gets a pointer to a state variable. More...
 
bool SetVariableValue (const string &name, const string &expression)
 Sets a variable to a new value. More...
 
void Serialize (ostream &ss, SerializationContext &context) const
 Serializes the Component into a string stream. More...
 
bool CheckConsistency () const
 Checks consistency by serializing and deserializing the component (including all its child components), and comparing the checksum of the original tree with the deserialized tree. More...
 
void AddChecksum (Checksum &checksum) const
 Adds this component's state, including children, to a checksum. More...
 
- Public Member Functions inherited from ReferenceCountable
 ReferenceCountable ()
 Default constructor, which initializes the reference count to zero. More...
 
 ~ReferenceCountable ()
 
- Public Member Functions inherited from AddressDataBus
 AddressDataBus ()
 Constructs an AddressDataBus instance. More...
 
virtual ~AddressDataBus ()
 

Static Public Member Functions

static void RunUnitTests (int &nSucceeded, int &nFailures)
 
- Static Public Member Functions inherited from CPUComponent
static void RunUnitTests (int &nSucceeded, int &nFailures)
 
- Static Public Member Functions inherited from Component
static string GetAttribute (const string &attributeName)
 Creates a Component. More...
 
static refcount_ptr< ComponentDeserialize (ostream &messages, const string &str, size_t &pos)
 Deserializes a string into a component tree. More...
 
- Static Public Member Functions inherited from UnitTestable
static void RunUnitTests (int &nSucceeded, int &nFailures)
 Runs unit test cases. More...
 

Protected Member Functions

virtual int GetDyntransICshift () const =0
 
void DyntransToBeTranslatedBegin (struct DyntransIC *)
 
bool DyntransReadInstruction (uint16_t &iword)
 
bool DyntransReadInstruction (uint32_t &iword, int offset=0)
 
void DyntransToBeTranslatedDone (struct DyntransIC *)
 
void DyntransResyncPC ()
 Calculate m_pc based on m_nextIC and m_firstIConPage. More...
 
void DyntransPCtoPointers ()
 Calculate m_nextIC and m_firstIConPage, based on m_pc. More...
 
 DECLARE_DYNTRANS_INSTR (nop)
 
 DECLARE_DYNTRANS_INSTR (abort)
 
 DECLARE_DYNTRANS_INSTR (endOfPage)
 
 DECLARE_DYNTRANS_INSTR (endOfPage2)
 
 DECLARE_DYNTRANS_INSTR (branch_samepage)
 
 DECLARE_DYNTRANS_INSTR (set_u64_imms32)
 
 DECLARE_DYNTRANS_INSTR (mov_u64_u64)
 
 DECLARE_DYNTRANS_INSTR (add_u32_u32_immu32)
 
 DECLARE_DYNTRANS_INSTR (add_u32_u32_u32)
 
 DECLARE_DYNTRANS_INSTR (add_u64_u64_imms32_truncS32)
 
 DECLARE_DYNTRANS_INSTR (add_u64_u64_u64_truncS32)
 
 DECLARE_DYNTRANS_INSTR (add_u64_u64_imms32)
 
 DECLARE_DYNTRANS_INSTR (sub_u32_u32_immu32)
 
 DECLARE_DYNTRANS_INSTR (sub_u32_u32_u32)
 
 DECLARE_DYNTRANS_INSTR (sub_u64_u64_u64_truncS32)
 
 DECLARE_DYNTRANS_INSTR (and_u32_u32_immu32)
 
 DECLARE_DYNTRANS_INSTR (and_u64_u64_immu32)
 
 DECLARE_DYNTRANS_INSTR (or_u32_u32_immu32)
 
 DECLARE_DYNTRANS_INSTR (or_u32_u32_u32)
 
 DECLARE_DYNTRANS_INSTR (or_u64_u64_immu32)
 
 DECLARE_DYNTRANS_INSTR (xor_u32_u32_immu32)
 
 DECLARE_DYNTRANS_INSTR (xor_u32_u32_u32)
 
 DECLARE_DYNTRANS_INSTR (xor_u64_u64_immu32)
 
 DECLARE_DYNTRANS_INSTR (xor_u64_u64_u64)
 
 DECLARE_DYNTRANS_INSTR (shift_left_u64_u64_imm5_truncS32)
 
 DECLARE_DYNTRANS_INSTR (shift_right_u64_u64asu32_imm5_truncS32)
 
- Protected Member Functions inherited from CPUComponent
virtual void FlushCachedStateForComponent ()
 Resets the cached state of this component. More...
 
virtual bool PreRunCheckForComponent (GXemul *gxemul)
 Checks the state of this component, before starting execution. More...
 
virtual void ShowRegisters (GXemul *gxemul, const vector< string > &arguments) const
 
uint64_t Unassemble (int nRows, bool indicatePC, uint64_t vaddr, ostream &output)
 
virtual bool VirtualToPhysical (uint64_t vaddr, uint64_t &paddr, bool &writable)=0
 Virtual to physical address translation (MMU). More...
 
virtual string VirtualAddressAsString (uint64_t vaddr)
 Format a virtual address as a displayable string. More...
 
virtual uint64_t PCtoInstructionAddress (uint64_t pc)
 Convert PC value to instuction address. More...
 
bool FunctionTraceCall ()
 
bool FunctionTraceReturn ()
 
virtual int FunctionTraceArgumentCount ()
 
virtual int64_t FunctionTraceArgument (int n)
 
virtual bool FunctionTraceReturnImpl (int64_t &retval)
 
- Protected Member Functions inherited from Component
 Component (const string &className, const string &visibleClassName)
 Base constructor for a Component. More...
 
template<class T >
bool AddVariable (const string &name, T *variablePointer)
 Adds a state variable of type T to the Component. More...
 
bool AddCustomVariable (const string &name, CustomStateVariableHandler *variableHandler)
 Adds a custom state variable to the Component. More...
 
virtual bool CheckVariableWrite (StateVariable &var, const string &oldValue)
 Checks whether a write to a variable is OK. More...
 
GXemulGetRunningGXemulInstance ()
 Returns a reference to the current GXemul instance. More...
 
UIGetUI ()
 Gets an UI reference for outputting debug messages during runtime. More...
 

Protected Attributes

virtual void(*)(CPUDyntransComponent *cpu, DyntransIC *icGetDyntransToBeTranslated ()
 
struct DyntransICm_firstIConPage
 
struct DyntransICm_nextIC
 
int m_dyntransPageMask
 
int m_dyntransICentriesPerPage
 
int m_dyntransICshift
 
int m_executedCycles
 
int m_nrOfCyclesToExecute
 
DyntransTranslationCache m_translationCache
 
struct DyntransIC m_abortIC
 
- Protected Attributes inherited from CPUComponent
double m_frequency
 
bool m_paused
 
string m_cpuArchitecture
 
int m_pageSize
 
uint64_t m_pc
 
uint64_t m_lastDumpAddr
 
uint64_t m_lastUnassembleVaddr
 
bool m_hasUsedUnassemble
 
bool m_isBigEndian
 
bool m_showFunctionTraceCall
 
bool m_showFunctionTraceReturn
 
int32_t m_functionCallTraceDepth
 
int64_t m_nrOfTracedFunctionCalls
 
bool m_inDelaySlot
 
uint64_t m_delaySlotTarget
 
AddressDataBusm_addressDataBus
 
uint64_t m_addressSelect
 
bool m_exceptionOrAbortInDelaySlot
 

Detailed Description

A base-class for processors Component implementations that use dynamic translation.

Definition at line 85 of file CPUDyntransComponent.h.

Constructor & Destructor Documentation

◆ CPUDyntransComponent()

CPUDyntransComponent::CPUDyntransComponent ( const string &  className,
const string &  cpuKind 
)

Constructs a CPUDyntransComponent.

Parameters
classNameThe class name for the component.
cpuKindThe CPU kind, e.g. "MIPS R4400" for a MIPS R4400 processor.

Definition at line 36 of file CPUDyntransComponent.cc.

References DYNTRANS_PAGE_NSPECIALENTRIES, DyntransIC::f, GetDyntransICshift(), m_abortIC, m_dyntransICentriesPerPage, m_dyntransICshift, m_dyntransPageMask, m_firstIConPage, m_nextIC, CPUComponent::m_pageSize, and m_translationCache.

Member Function Documentation

◆ DECLARE_DYNTRANS_INSTR() [1/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( nop  )
protected

◆ DECLARE_DYNTRANS_INSTR() [2/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( abort  )
protected

◆ DECLARE_DYNTRANS_INSTR() [3/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( endOfPage  )
protected

◆ DECLARE_DYNTRANS_INSTR() [4/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( endOfPage2  )
protected

◆ DECLARE_DYNTRANS_INSTR() [5/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( branch_samepage  )
protected

◆ DECLARE_DYNTRANS_INSTR() [6/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( set_u64_imms32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [7/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( mov_u64_u64  )
protected

◆ DECLARE_DYNTRANS_INSTR() [8/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( add_u32_u32_immu32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [9/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( add_u32_u32_u32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [10/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( add_u64_u64_imms32_truncS32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [11/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( add_u64_u64_u64_truncS32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [12/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( add_u64_u64_imms32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [13/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( sub_u32_u32_immu32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [14/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( sub_u32_u32_u32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [15/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( sub_u64_u64_u64_truncS32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [16/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( and_u32_u32_immu32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [17/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( and_u64_u64_immu32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [18/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( or_u32_u32_immu32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [19/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( or_u32_u32_u32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [20/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( or_u64_u64_immu32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [21/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( xor_u32_u32_immu32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [22/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( xor_u32_u32_u32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [23/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( xor_u64_u64_immu32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [24/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( xor_u64_u64_u64  )
protected

◆ DECLARE_DYNTRANS_INSTR() [25/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( shift_left_u64_u64_imm5_truncS32  )
protected

◆ DECLARE_DYNTRANS_INSTR() [26/26]

CPUDyntransComponent::DECLARE_DYNTRANS_INSTR ( shift_right_u64_u64asu32_imm5_truncS32  )
protected

◆ DyntransPCtoPointers()

void CPUDyntransComponent::DyntransPCtoPointers ( )
protected

Calculate m_nextIC and m_firstIConPage, based on m_pc.

This function may return pointers to within an existing translation page (hopefully the most common case, since it is the fastest), or it may allocate a new empty page.

Definition at line 232 of file CPUDyntransComponent.cc.

References DyntransIC::f, m_dyntransICshift, m_dyntransPageMask, m_firstIConPage, m_nextIC, and CPUComponent::m_pc.

Referenced by DyntransToBeTranslatedDone(), and Execute().

◆ DyntransReadInstruction() [1/2]

bool CPUDyntransComponent::DyntransReadInstruction ( uint16_t &  iword)
protected

◆ DyntransReadInstruction() [2/2]

bool CPUDyntransComponent::DyntransReadInstruction ( uint32_t &  iword,
int  offset = 0 
)
protected

◆ DyntransResyncPC()

void CPUDyntransComponent::DyntransResyncPC ( )
protected

Calculate m_pc based on m_nextIC and m_firstIConPage.

Definition at line 252 of file CPUDyntransComponent.cc.

References m_abortIC, m_dyntransICentriesPerPage, m_dyntransICshift, m_dyntransPageMask, m_firstIConPage, m_nextIC, and CPUComponent::m_pc.

Referenced by DyntransToBeTranslatedBegin(), and Execute().

◆ DyntransToBeTranslatedBegin()

void CPUDyntransComponent::DyntransToBeTranslatedBegin ( struct DyntransIC ic)
protected

Definition at line 297 of file CPUDyntransComponent.cc.

References DyntransResyncPC(), DyntransIC::f, ic, and m_nextIC.

◆ DyntransToBeTranslatedDone()

void CPUDyntransComponent::DyntransToBeTranslatedDone ( struct DyntransIC ic)
protected

◆ Execute()

int CPUDyntransComponent::Execute ( GXemul gxemul,
int  nrOfCycles 
)
virtual

Execute one or more cycles.

Note 1: A component must attempt to execute exactly the number of specified cycles.

Note 2: If e.g. a breakpoint is reached, or some fatal error occurs (such as an unimplemented feature in the emulation of the component is triggered), then it is ok to return fewer than the requested number of cycles. Execution will then stop (or the breakpoint will be handled, etc).

Note 3: The framework will only call this function if the component has a StateVariable named "frequency". Components that do not have any frequency do not execute anything periodically by themselves.

Parameters
gxemulA pointer to the GXemul instance.
nrOfCyclesThe requested number of cycles to run.
Returns
The number of cycles actually executed.

Reimplemented from Component.

Definition at line 89 of file CPUDyntransComponent.cc.

References addr, DyntransPCtoPointers(), DyntransResyncPC(), f(), DyntransIC::f, GetDyntransToBeTranslated, GXemul::GetRunState(), GXemul::GetUI(), ic, IC, m_dyntransICentriesPerPage, m_executedCycles, m_firstIConPage, CPUComponent::m_inDelaySlot, m_nextIC, m_nrOfCyclesToExecute, CPUComponent::m_pc, CPUComponent::m_showFunctionTraceCall, m_translationCache, CPUComponent::PCtoInstructionAddress(), UI::ShowDebugMessage(), GXemul::SingleStepping, and CPUComponent::Unassemble().

◆ GetDyntransICshift()

virtual int CPUDyntransComponent::GetDyntransICshift ( ) const
protectedpure virtual

◆ RunUnitTests()

static void CPUDyntransComponent::RunUnitTests ( int &  nSucceeded,
int &  nFailures 
)
static

Member Data Documentation

◆ GetDyntransToBeTranslated

virtual void(*)(CPUDyntransComponent* cpu, DyntransIC* ic) CPUDyntransComponent::GetDyntransToBeTranslated()
protected

Definition at line 108 of file CPUDyntransComponent.h.

Referenced by DyntransToBeTranslatedDone(), and Execute().

◆ m_abortIC

struct DyntransIC CPUDyntransComponent::m_abortIC
protected

◆ m_dyntransICentriesPerPage

int CPUDyntransComponent::m_dyntransICentriesPerPage
protected

◆ m_dyntransICshift

int CPUDyntransComponent::m_dyntransICshift
protected

◆ m_dyntransPageMask

int CPUDyntransComponent::m_dyntransPageMask
protected

◆ m_executedCycles

int CPUDyntransComponent::m_executedCycles
protected

Definition at line 614 of file CPUDyntransComponent.h.

Referenced by DYNTRANS_INSTR(), DyntransToBeTranslatedDone(), and Execute().

◆ m_firstIConPage

struct DyntransIC* CPUDyntransComponent::m_firstIConPage
protected

◆ m_nextIC

struct DyntransIC* CPUDyntransComponent::m_nextIC
protected

◆ m_nrOfCyclesToExecute

int CPUDyntransComponent::m_nrOfCyclesToExecute
protected

Definition at line 615 of file CPUDyntransComponent.h.

Referenced by DYNTRANS_INSTR(), DyntransToBeTranslatedDone(), and Execute().

◆ m_translationCache

DyntransTranslationCache CPUDyntransComponent::m_translationCache
protected

Definition at line 620 of file CPUDyntransComponent.h.

Referenced by CPUDyntransComponent(), and Execute().


The documentation for this class was generated from the following files:

Generated on Fri Dec 7 2018 19:52:23 for GXemul by doxygen 1.8.13