ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
Public Member Functions | Public Attributes | List of all members
etiss::instr::OPCode Class Reference

defines the relevant bits and their value to identify an instruction. More...

#include <Instruction.h>

Collaboration diagram for etiss::instr::OPCode:
Collaboration graph
[legend]

Public Member Functions

template<typename T , typename = typename std::enable_if<std::is_integral<T>::value, T>::type>
 OPCode (unsigned width, const T code, const T mask)
 ctor that uses integral values for mask and code More...
 
 OPCode (const BitArray &code, const BitArray &mask)
 
 OPCode (const OPCode &cpy)
 copy ctor More...
 
bool operator< (const OPCode &o) const
 comparison operator for map/sets. More...
 
bool operator== (const OPCode &o) const
 
bool operator!= (const OPCode &o) const
 

Public Attributes

const BitArray code_
 
const BitArray mask_
 

Detailed Description

defines the relevant bits and their value to identify an instruction.

e.g. l.add of the or1k architecture:

opcode: 0x38 (bit 31-25), 0x0 (bit 9-8), 0x0 (bit 3-0)

the resulting code as passed to the constructor would be: 0xE0000000 the resulting mask as passed to the constructor would be: 0xFC00030F

to simplify that procedure a simple language is provided to generate those values from a representation that is much more similar to the opcode definition in text form.

see uint32_t parse_i32(const char * s) or for a more general implementation see template <typename T> T parse_i(const char * s)

if there is c++11 support then the literal operator ""_i32 can be used instead of parse_i32()

the syntax for parse_i/parse_i32 is very simple. the number of bits is followed by an 'x' and the value represented in hex (additional bits from the hex representation are discarded). further such definitions are seperated by a space character. the definitions further to the left will be left shifted by the length of followind definitions. e.g for l.add:

uint32_t code = parse_i32("6x32 16x0 2x0 4x0 4x0"); // or parse_i32("6x32 26x0") or parse_i32("6x32 15x0 1x0 2x0 4x0 4x0") uint32_t mask = parse_i32("6xFF 16x0 2xF 4x0 4xF");

Definition at line 271 of file Instruction.h.

Constructor & Destructor Documentation

◆ OPCode() [1/3]

template<typename T , typename = typename std::enable_if<std::is_integral<T>::value, T>::type>
etiss::instr::OPCode::OPCode ( unsigned  width,
const T  code,
const T  mask 
)
inline

ctor that uses integral values for mask and code

Attention
only if DEBUG is defined as non zero a warning message will be printed if the code doesn't fit the mask
Parameters
widthwidth in bits

Definition at line 283 of file Instruction.h.

References etiss::log(), etiss::toString(), etiss::VERBOSE, and etiss::WARNING.

Here is the call graph for this function:

◆ OPCode() [2/3]

etiss::instr::OPCode::OPCode ( const BitArray code,
const BitArray mask 
)
Attention
the width of code and mask MUST be equal

Definition at line 221 of file Instruction.cpp.

References code_, etiss::ERROR, etiss::log(), mask_, and etiss::WARNING.

Here is the call graph for this function:

◆ OPCode() [3/3]

etiss::instr::OPCode::OPCode ( const OPCode cpy)

copy ctor

Definition at line 236 of file Instruction.cpp.

Member Function Documentation

◆ operator!=()

bool etiss::instr::OPCode::operator!= ( const OPCode o) const
inline

Definition at line 314 of file Instruction.h.

◆ operator<()

bool etiss::instr::OPCode::operator< ( const OPCode o) const

comparison operator for map/sets.

compares mask and code to provide some sort of order. has no further meaning.

Definition at line 238 of file Instruction.cpp.

References code_, and mask_.

◆ operator==()

bool etiss::instr::OPCode::operator== ( const OPCode o) const
inline

Definition at line 313 of file Instruction.h.

Member Data Documentation

◆ code_

const BitArray etiss::instr::OPCode::code_

Definition at line 274 of file Instruction.h.

Referenced by OPCode(), and operator<().

◆ mask_

const BitArray etiss::instr::OPCode::mask_

Definition at line 275 of file Instruction.h.

Referenced by OPCode(), and operator<().


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