The Sparta Modeling Framework
Loading...
Searching...
No Matches
Logger Hex Macros

Macros

#define HEX(val, width)
 
#define HEX16(val)   HEX(val, 16)
 
#define HEX8(val)   HEX(val, 8)
 

Detailed Description

These macros are meant to be used within a Logger ouput macro to print hex values and then return the logger to the default state.

Example usage:

class Fetch : public sparta::Unit
{
    void FetchSomeInsts() const {
        const int addr = 0xdeadbeef;
        DLOG("Got instruction at " << HEX8(addr));"
    }
}

Example debug logger output:

{0000000000 00000000 top.fetch debug} FetchSomeInsts: Got instruction at 0xdeadbeef

Macro Definition Documentation

◆ HEX

#define HEX (   val,
  width 
)
Value:
"0x" << std::setw(width) << std::setfill('0') << std::hex \
<< std::right << val << std::setfill(' ') << std::dec

Macro to simplify printing of hex values

Parameters
valThe value to print
widthThe number of digits to print

Definition at line 149 of file LogUtils.hpp.

◆ HEX16

#define HEX16 (   val)    HEX(val, 16)

Macro to simplify printing of 16 digit hex value

Parameters
valThe value to print

Definition at line 158 of file LogUtils.hpp.

◆ HEX8

#define HEX8 (   val)    HEX(val, 8)

Macro to simplify printing of 8 digit hex values

Parameters
valThe value to print

Definition at line 165 of file LogUtils.hpp.