0

I need to convert this code:

bool hw = (gpio_ctrl(idx) >> 5) & 1;
uint8_t cnfg = (gpio_ctrl(idx) >> 3) & 3;
sc_dt::sc_logic oe_n = Log_1; // Default disable
sc_dt::sc_logic od = Log_Z; // Default disable


DEBUG_PRINTF(("GPIO update_ouput: CTRL=0x%x IDX=%d, HW=%d CNFG=%d, OE_N=%d, od=%d\n", gpio_ctrl(idx), idx, hw, cnfg, oe_n, od));

into being logged with Semantic.

I tried simplistically doing this:

SEM_MSG(gpio_output_logic_update, SEM_INFO, "GPIO output logic update", "Control register index", ("value", SEM_ATTR_HEX), "HW (active low)", "Config style", "OE_N", "OD");

     // ...

    SEM_TRACE(gpio_output_logic_update, source, idx, gpio_ctrl(idx), hw, cnfg, oe_n, od);

but SEM_MSG doesn't magically understand sc_logic.

GreenAsJade
  • 14,459
  • 11
  • 63
  • 98

2 Answers2

0

You can use to_char() method returning a char version of sc_logic. (or to_bool()). See 7.9.2.2 section of IEEE Std 1666-2011.

SEM_TRACE(gpio_output_logic_update, source, idx, gpio_ctrl(idx), hw, cnfg, oe_n.to_char(), od.to_char());
AndresM
  • 1,293
  • 10
  • 19
Guillaume
  • 1,277
  • 8
  • 11
  • Looked promising, but the problem with this is that semantic interprets the char as a numeric value, and renders it as such (the ascii value). – GreenAsJade Aug 02 '16 at 03:19
0

What I currently have done is to declare a semantic enum for the sc_logic values, and trace that using the value of the sc_logic. It's slightly convoluted to read ("why do I have to take the value() of the sc_logic variable?") but it works...

// Support logging sc_logic values

SEM_ENUM(sc_dt::sc_logic_value_t, (sc_dt::Log_0, "0"), (sc_dt::Log_1, "1"), (sc_dt::Log_Z, "Z"), (sc_dt::Log_X, "X"));

//...

SEM_MSG(gpio_output_logic_update, SEM_INFO, "GPIO output logic update", "index", ("value", SEM_ATTR_HEX), "HW", "CNFG", "OE_N", "OD");

//..

    SEM_TRACE(gpio_output_logic_update, source, idx, gpio_ctrl(idx), hw, cnfg, oe_n.value(), od.value());
GreenAsJade
  • 14,459
  • 11
  • 63
  • 98