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");
}
# Copyright (c) 2022 GreenWaves Technologies SAS
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of GreenWaves Technologies SAS nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
cmake_minimum_required(VERSION 3.19)
###############################################################################
# Panel Control
###############################################################################
set(TARGET_NAME "user_vcd")
set(TARGET_SRCS example.c)
###############################################################################
# CMake pre initialization
###############################################################################
include($ENV{GAP_SDK_HOME}/utils/cmake/setup.cmake)
list(APPEND GAPY_RUNNER_ARGS
--vcd
--event=/user
# int trace
--target-opt=gvsoc/events/traces/kernel/tag=overview
--target-opt=gvsoc/events/traces/kernel/type=int
--target-opt=gvsoc/events/traces/kernel/path=/user/kernel/active
--target-opt=gvsoc/events/traces/kernel/vcd_path=user.kernel.active[31:0]
--target-opt=gvsoc/events/traces/kernel/view_path=overview.kernel
--target-opt=gvsoc/events/traces/kernel/filter=${CMAKE_CURRENT_SOURCE_DIR}/map_file.txt
# Second one is a string trace
--target-opt=gvsoc/events/traces/kernel_state/tag=state
--target-opt=gvsoc/events/traces/kernel_state/type=string
--target-opt=gvsoc/events/traces/kernel_state/path=/user/kernel/state
--target-opt=gvsoc/events/traces/kernel_state/vcd_path=user.kernel.state
--target-opt=gvsoc/events/traces/kernel_state/view_path=overview.kernel
)
project(${TARGET_NAME} C ASM)
add_executable(${TARGET_NAME} ${TARGET_SRCS})
###############################################################################
# CMake post initialization
###############################################################################
setupos(${TARGET_NAME})