VCD Trace control

Requirements

None

Description

This example shows how to control GVSOC VCD custom traces during execution from the simulated SW.

Code

/*
 * Copyright (C) 2021 GreenWaves Technologies
 * All rights reserved.
 *
 * This software may be modified and distributed under the terms
 * of the BSD license.  See the LICENSE file for details.
 *
 */

#include "pmsis.h"
#include "stdio.h"
#include <pmsis/platforms/gvsoc.h>



int main(void)
{
    // Open the 2 traces from their path in the simulated SW and get the descriptor in return
    int trace = gv_vcd_open_trace("/user/kernel/active");
    int trace_state = gv_vcd_open_trace("/user/kernel/state");

    // Now play with the traces

    // Set the integrer trace to 1.
    // Before that it was in the special Z state (middle state in yellow in the view).
    // Since we provided a map file, this value should be seen as a box with active keyword
    gv_vcd_dump_trace(trace, 1);

    // Now set a new string to the string trace
    gv_vcd_dump_trace_string(trace_state, "state0");

    // Deactivate VCD tracing. In the view, this should make a big hole with no traces at all.
    gv_vcd_configure(0, NULL);

    printf("Hello\n");

    // Now give other values
    gv_vcd_configure(1, NULL);

    // This will set the special Z value to the trace, like if it was released.
    gv_vcd_release_trace(trace);
    gv_vcd_dump_trace_string(trace_state, "state1");

    gv_vcd_dump_trace(trace, 1);
    gv_vcd_dump_trace_string(trace_state, "state2");

    printf("Hello\n");

    gv_vcd_release_trace(trace);
    gv_vcd_dump_trace_string(trace_state, "state3");
}