Fix several cmake issues, including TRACE_VCD
This commit is contained in:
parent
6bb57e4630
commit
fc8e1b5a2e
|
@ -370,10 +370,11 @@ Verilate in CMake
|
|||
.. code-block:: CMake
|
||||
|
||||
verilate(target SOURCES source ... [TOP_MODULE top] [PREFIX name]
|
||||
[TRACE] [TRACE_FST] [SYSTEMC] [COVERAGE]
|
||||
[COVERAGE] [SYSTEMC]
|
||||
[TRACE_FST] [TRACE_SAIF] [TRACE_VCD] [TRACE_THREADS num]
|
||||
[INCLUDE_DIRS dir ...] [OPT_SLOW ...] [OPT_FAST ...]
|
||||
[OPT_GLOBAL ..] [DIRECTORY dir] [THREADS num]
|
||||
[TRACE_THREADS num] [VERILATOR_ARGS ...])
|
||||
[VERILATOR_ARGS ...])
|
||||
|
||||
Lowercase and ... should be replaced with arguments; the uppercase parts
|
||||
delimit the arguments and can be passed in any order or left out entirely
|
||||
|
@ -446,10 +447,6 @@ SystemC include directories and link to the SystemC libraries.
|
|||
|
||||
Optional. Enable a multithreaded model; see :vlopt:`--threads`.
|
||||
|
||||
.. describe:: TRACE_THREADS
|
||||
|
||||
Optional. Enable multithreaded FST trace; see :vlopt:`--trace-threads`.
|
||||
|
||||
.. describe:: TOP_MODULE
|
||||
|
||||
Optional. Sets the name of the top module. Defaults to the name of the
|
||||
|
@ -469,6 +466,10 @@ SystemC include directories and link to the SystemC libraries.
|
|||
Optional. Enables SAIF tracing if present, equivalent to "VERILATOR_ARGS
|
||||
--trace-saif".
|
||||
|
||||
.. describe:: TRACE_THREADS
|
||||
|
||||
Optional. Enable multithreaded FST trace; see :vlopt:`--trace-threads`.
|
||||
|
||||
.. describe:: TRACE_VCD
|
||||
|
||||
Optional. Enables VCD tracing if present, equivalent to "VERILATOR_ARGS
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
# binary relative to $VERILATOR_ROOT (such as when inside the git sources).
|
||||
|
||||
ifeq ($(VERILATOR_ROOT),)
|
||||
VERILATOR = verilator
|
||||
VERILATOR_COVERAGE = verilator_coverage
|
||||
else
|
||||
export VERILATOR_ROOT
|
||||
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
|
||||
VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage
|
||||
endif
|
||||
######################################################################
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
# binary relative to $VERILATOR_ROOT (such as when inside the git sources).
|
||||
|
||||
ifeq ($(VERILATOR_ROOT),)
|
||||
VERILATOR = verilator
|
||||
VERILATOR_COVERAGE = verilator_coverage
|
||||
else
|
||||
export VERILATOR_ROOT
|
||||
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
|
||||
VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage
|
||||
endif
|
||||
######################################################################
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
# binary relative to $VERILATOR_ROOT (such as when inside the git sources).
|
||||
|
||||
ifeq ($(VERILATOR_ROOT),)
|
||||
VERILATOR = verilator
|
||||
VERILATOR_COVERAGE = verilator_coverage
|
||||
else
|
||||
export VERILATOR_ROOT
|
||||
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
|
||||
VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage
|
||||
endif
|
||||
######################################################################
|
||||
|
|
|
@ -36,7 +36,7 @@ add_executable(example ../make_tracing_c/sim_main.cpp)
|
|||
target_compile_features(example PUBLIC cxx_std_14)
|
||||
|
||||
# Add the Verilated circuit to the target
|
||||
verilate(example COVERAGE TRACE
|
||||
verilate(example COVERAGE TRACE_VCD
|
||||
INCLUDE_DIRS "../make_tracing_c"
|
||||
VERILATOR_ARGS -f ../make_tracing_c/input.vc -x-assign fast
|
||||
SOURCES ../make_tracing_c/top.v
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
# binary relative to $VERILATOR_ROOT (such as when inside the git sources).
|
||||
|
||||
ifeq ($(VERILATOR_ROOT),)
|
||||
VERILATOR = verilator
|
||||
VERILATOR_COVERAGE = verilator_coverage
|
||||
else
|
||||
export VERILATOR_ROOT
|
||||
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
|
||||
VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage
|
||||
endif
|
||||
######################################################################
|
||||
|
@ -59,7 +61,7 @@ run:
|
|||
@echo
|
||||
@echo "-- RUN ---------------------"
|
||||
@mkdir -p logs
|
||||
build/example +trace
|
||||
build/example +trace_vcd
|
||||
|
||||
@echo
|
||||
@echo "-- COVERAGE ----------------"
|
||||
|
|
|
@ -46,7 +46,7 @@ target_compile_features(example PUBLIC cxx_std_14)
|
|||
set_property(TARGET example PROPERTY CXX_STANDARD ${SystemC_CXX_STANDARD})
|
||||
|
||||
# Add the Verilated circuit to the target
|
||||
verilate(example SYSTEMC COVERAGE TRACE
|
||||
verilate(example COVERAGE SYSTEMC TRACE_VCD
|
||||
INCLUDE_DIRS "../make_tracing_sc"
|
||||
VERILATOR_ARGS -f ../make_tracing_sc/input.vc -x-assign fast
|
||||
SOURCES ../make_tracing_sc/top.v
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
# binary relative to $VERILATOR_ROOT (such as when inside the git sources).
|
||||
|
||||
ifeq ($(VERILATOR_ROOT),)
|
||||
VERILATOR = verilator
|
||||
VERILATOR_COVERAGE = verilator_coverage
|
||||
else
|
||||
export VERILATOR_ROOT
|
||||
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
|
||||
VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage
|
||||
endif
|
||||
######################################################################
|
||||
|
@ -77,7 +79,7 @@ run:
|
|||
@echo
|
||||
@echo "-- RUN ---------------------"
|
||||
@mkdir -p logs
|
||||
build/example +trace
|
||||
build/example +trace_vcd
|
||||
|
||||
@echo
|
||||
@echo "-- COVERAGE ----------------"
|
||||
|
|
|
@ -111,14 +111,11 @@ class CMakeEmitter final {
|
|||
*of << "# Threaded output mode? 1/N threads (from --threads)\n";
|
||||
cmake_set_raw(*of, name + "_THREADS", cvtToStr(v3Global.opt.threads()));
|
||||
*of << "# FST Tracing output mode? 0/1 (from --trace-fst)\n";
|
||||
cmake_set_raw(*of, name + "_TRACE_FST",
|
||||
(v3Global.opt.trace() && v3Global.opt.traceFormat().fst()) ? "1" : "0");
|
||||
cmake_set_raw(*of, name + "_TRACE_FST", (v3Global.opt.traceEnabledFst()) ? "1" : "0");
|
||||
*of << "# SAIF Tracing output mode? 0/1 (from --trace-saif)\n";
|
||||
cmake_set_raw(*of, name + "_TRACE_SAIF",
|
||||
(v3Global.opt.trace() && v3Global.opt.traceFormat().saif()) ? "1" : "0");
|
||||
cmake_set_raw(*of, name + "_TRACE_SAIF", (v3Global.opt.traceEnabledSaif()) ? "1" : "0");
|
||||
*of << "# VCD Tracing output mode? 0/1 (from --trace-vcd)\n";
|
||||
cmake_set_raw(*of, name + "_TRACE_VCD",
|
||||
(v3Global.opt.trace() && v3Global.opt.traceFormat().vcd()) ? "1" : "0");
|
||||
cmake_set_raw(*of, name + "_TRACE_VCD", (v3Global.opt.traceEnabledVcd()) ? "1" : "0");
|
||||
|
||||
*of << "\n### Sources...\n";
|
||||
std::vector<string> classes_fast;
|
||||
|
|
|
@ -557,15 +557,15 @@ public:
|
|||
of.puts("\n");
|
||||
of.puts("# Tracing output mode in FST format? 0/1 (from --trace-fst)\n");
|
||||
of.puts("VM_TRACE_FST = ");
|
||||
of.puts(v3Global.opt.trace() && v3Global.opt.traceFormat().fst() ? "1" : "0");
|
||||
of.puts(v3Global.opt.traceEnabledFst() ? "1" : "0");
|
||||
of.puts("\n");
|
||||
of.puts("# Tracing output mode in SAIF format? 0/1 (from --trace-saif)\n");
|
||||
of.puts("VM_TRACE_SAIF = ");
|
||||
of.puts(v3Global.opt.trace() && v3Global.opt.traceFormat().saif() ? "1" : "0");
|
||||
of.puts(v3Global.opt.traceEnabledSaif() ? "1" : "0");
|
||||
of.puts("\n");
|
||||
of.puts("# Tracing output mode in VCD format? 0/1 (from --trace-vcd)\n");
|
||||
of.puts("VM_TRACE_VCD = ");
|
||||
of.puts(v3Global.opt.trace() && v3Global.opt.traceFormat().vcd() ? "1" : "0");
|
||||
of.puts(v3Global.opt.traceEnabledVcd() ? "1" : "0");
|
||||
of.puts("\n");
|
||||
|
||||
of.puts("\n### Object file lists...\n");
|
||||
|
|
|
@ -145,9 +145,6 @@ class V3EmitMkJsonEmitter final {
|
|||
const std::unique_ptr<std::ofstream> of{
|
||||
V3File::new_ofstream(makeDir + "/" + v3Global.opt.prefix() + ".json")};
|
||||
|
||||
const std::string trace
|
||||
= v3Global.opt.trace() ? (v3Global.opt.traceFormat().vcd() ? "vcd" : "fst") : "off";
|
||||
|
||||
std::vector<string> classesFast;
|
||||
std::vector<string> classesSlow;
|
||||
std::vector<string> supportFast;
|
||||
|
@ -206,7 +203,10 @@ class V3EmitMkJsonEmitter final {
|
|||
.put("coverage", v3Global.opt.coverage())
|
||||
.put("use_timing", v3Global.usesTiming())
|
||||
.put("threads", v3Global.opt.threads())
|
||||
.put("trace", trace)
|
||||
.put("trace", v3Global.opt.trace())
|
||||
.put("trace_fst", v3Global.opt.traceEnabledFst())
|
||||
.put("trace_saif", v3Global.opt.traceEnabledSaif())
|
||||
.put("trace_vcd", v3Global.opt.traceEnabledVcd())
|
||||
.end()
|
||||
.begin("sources")
|
||||
.putList("global", global)
|
||||
|
|
|
@ -609,6 +609,9 @@ public:
|
|||
VTimescale timeComputeUnit(const VTimescale& flag) const;
|
||||
int traceDepth() const { return m_traceDepth; }
|
||||
TraceFormat traceFormat() const { return m_traceFormat; }
|
||||
bool traceEnabledFst() const { return trace() && traceFormat().fst(); }
|
||||
bool traceEnabledSaif() const { return trace() && traceFormat().saif(); }
|
||||
bool traceEnabledVcd() const { return trace() && traceFormat().vcd(); }
|
||||
int traceMaxArray() const { return m_traceMaxArray; }
|
||||
int traceMaxWidth() const { return m_traceMaxWidth; }
|
||||
int traceThreads() const { return m_traceThreads; }
|
||||
|
|
|
@ -128,13 +128,6 @@ define_property(
|
|||
FULL_DOCS "Verilator trace enabled"
|
||||
)
|
||||
|
||||
define_property(
|
||||
TARGET
|
||||
PROPERTY VERILATOR_TRACE_VCD
|
||||
BRIEF_DOCS "Verilator VCD trace enabled"
|
||||
FULL_DOCS "Verilator VCD trace enabled"
|
||||
)
|
||||
|
||||
define_property(
|
||||
TARGET
|
||||
PROPERTY VERILATOR_TRACE_FST
|
||||
|
@ -149,6 +142,13 @@ define_property(
|
|||
FULL_DOCS "Verilator SAIF trace enabled"
|
||||
)
|
||||
|
||||
define_property(
|
||||
TARGET
|
||||
PROPERTY VERILATOR_TRACE_VCD
|
||||
BRIEF_DOCS "Verilator VCD trace enabled"
|
||||
FULL_DOCS "Verilator VCD trace enabled"
|
||||
)
|
||||
|
||||
define_property(
|
||||
TARGET
|
||||
PROPERTY VERILATOR_SYSTEMC
|
||||
|
@ -185,20 +185,6 @@ function(json_get_int RET JSON SECTION VARIABLE)
|
|||
set(${RET} ${JV} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(json_get_trace RET_VCD RET_FST JSON SECTION VARIABLE)
|
||||
string(JSON JV GET "${JSON}" ${SECTION} ${VARIABLE})
|
||||
if(JV STREQUAL "vcd")
|
||||
set(${RET_VCD} 1 PARENT_SCOPE)
|
||||
set(${RET_FST} 0 PARENT_SCOPE)
|
||||
elseif(JV STREQUAL "fst")
|
||||
set(${RET_VCD} 0 PARENT_SCOPE)
|
||||
set(${RET_FST} 1 PARENT_SCOPE)
|
||||
else()
|
||||
set(${RET_VCD} 0 PARENT_SCOPE)
|
||||
set(${RET_FST} 0 PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(json_get_submodules SUBMODULES NSUBMODULES JSON)
|
||||
string(JSON JV ERROR_VARIABLE STATUS GET "${JSON}" submodules)
|
||||
|
||||
|
@ -241,7 +227,7 @@ endfunction()
|
|||
function(verilate TARGET)
|
||||
cmake_parse_arguments(
|
||||
VERILATE
|
||||
"COVERAGE;TRACE;TRACE_FST;SYSTEMC;TRACE_STRUCTS"
|
||||
"COVERAGE;SYSTEMC;TRACE_FST;TRACE_SAIF;TRACE_VCD;TRACE_STRUCTS"
|
||||
"PREFIX;TOP_MODULE;THREADS;TRACE_THREADS;DIRECTORY"
|
||||
"SOURCES;VERILATOR_ARGS;INCLUDE_DIRS;OPT_SLOW;OPT_FAST;OPT_GLOBAL"
|
||||
${ARGN}
|
||||
|
@ -276,10 +262,24 @@ function(verilate TARGET)
|
|||
list(APPEND VERILATOR_ARGS --coverage)
|
||||
endif()
|
||||
|
||||
if(VERILATE_SYSTEMC)
|
||||
list(APPEND VERILATOR_ARGS --sc)
|
||||
else()
|
||||
list(APPEND VERILATOR_ARGS --cc)
|
||||
endif()
|
||||
|
||||
if(VERILATE_TRACE AND VERILATE_TRACE_FST)
|
||||
message(FATAL_ERROR "Cannot have both TRACE and TRACE_FST")
|
||||
endif()
|
||||
|
||||
if(VERILATE_TRACE_FST AND VERILATE_TRACE_VCD)
|
||||
message(FATAL_ERROR "Cannot have both TRACE_FST and TRACE_VCD")
|
||||
endif()
|
||||
|
||||
if(VERILATE_TRACE_SAIF AND VERILATE_TRACE_VCD)
|
||||
message(FATAL_ERROR "Cannot have both TRACE_SAIF and TRACE_VCD")
|
||||
endif()
|
||||
|
||||
if(VERILATE_TRACE)
|
||||
list(APPEND VERILATOR_ARGS --trace-vcd)
|
||||
endif()
|
||||
|
@ -296,12 +296,6 @@ function(verilate TARGET)
|
|||
list(APPEND VERILATOR_ARGS --trace-vcd)
|
||||
endif()
|
||||
|
||||
if(VERILATE_SYSTEMC)
|
||||
list(APPEND VERILATOR_ARGS --sc)
|
||||
else()
|
||||
list(APPEND VERILATOR_ARGS --cc)
|
||||
endif()
|
||||
|
||||
if(VERILATE_TRACE_STRUCTS)
|
||||
list(APPEND VERILATOR_ARGS --trace-structs)
|
||||
endif()
|
||||
|
@ -430,7 +424,9 @@ function(verilate TARGET)
|
|||
json_get_bool(JOPTIONS_COVERAGE "${MANIFEST}" options coverage)
|
||||
json_get_bool(JOPTIONS_USE_TIMING "${MANIFEST}" options use_timing)
|
||||
json_get_int(JOPTIONS_THREADS "${MANIFEST}" options threads)
|
||||
json_get_trace(JOPTIONS_TRACE_VCD JOPTIONS_TRACE_FST "${MANIFEST}" options trace)
|
||||
json_get_bool(JOPTIONS_TRACE_FST "${MANIFEST}" options trace_fst)
|
||||
json_get_bool(JOPTIONS_TRACE_SAIF "${MANIFEST}" options trace_saif)
|
||||
json_get_bool(JOPTIONS_TRACE_VCD "${MANIFEST}" options trace_vcd)
|
||||
|
||||
json_get_list(JSOURCES_GLOBAL "${MANIFEST}" sources global)
|
||||
json_get_list(JSOURCES_CLASSES_SLOW "${MANIFEST}" sources classes_slow)
|
||||
|
@ -465,10 +461,12 @@ function(verilate TARGET)
|
|||
"set(${VERILATE_PREFIX}_TIMING ${JOPTIONS_USE_TIMING})\n"
|
||||
"# Threaded output mode? 1/N threads (from --threads)\n"
|
||||
"set(${VERILATE_PREFIX}_THREADS ${JOPTIONS_THREADS})\n"
|
||||
"# VCD Tracing output mode? 0/1 (from --trace)\n"
|
||||
"set(${VERILATE_PREFIX}_TRACE_VCD ${JOPTIONS_TRACE_VCD})\n"
|
||||
"# FST Tracing output mode? 0/1 (from --trace-fst)\n"
|
||||
"set(${VERILATE_PREFIX}_TRACE_FST ${JOPTIONS_TRACE_FST})\n\n"
|
||||
"# SAIF Tracing output mode? 0/1 (from --trace-saif)\n"
|
||||
"set(${VERILATE_PREFIX}_TRACE_SAIF ${JOPTIONS_TRACE_SAIF})\n\n"
|
||||
"# VCD Tracing output mode? 0/1 (from --trace-vcd)\n"
|
||||
"set(${VERILATE_PREFIX}_TRACE_VCD ${JOPTIONS_TRACE_VCD})\n"
|
||||
"### Sources...\n"
|
||||
"# Global classes, need linked once per executable\n"
|
||||
"set(${VERILATE_PREFIX}_GLOBAL ${JSOURCES_GLOBAL})\n"
|
||||
|
@ -576,10 +574,9 @@ function(verilate TARGET)
|
|||
set_property(TARGET ${TARGET} PROPERTY VERILATOR_COVERAGE ON)
|
||||
endif()
|
||||
|
||||
if(${VERILATE_PREFIX}_TRACE_VCD)
|
||||
# If any verilate() call specifies TRACE, define VM_TRACE in the final build
|
||||
set_property(TARGET ${TARGET} PROPERTY VERILATOR_TRACE ON)
|
||||
set_property(TARGET ${TARGET} PROPERTY VERILATOR_TRACE_VCD ON)
|
||||
if(${VERILATE_PREFIX}_SC)
|
||||
# If any verilate() call specifies SYSTEMC, define VM_SC in the final build
|
||||
set_property(TARGET ${TARGET} PROPERTY VERILATOR_SYSTEMC ON)
|
||||
endif()
|
||||
|
||||
if(${VERILATE_PREFIX}_TRACE_FST)
|
||||
|
@ -594,9 +591,10 @@ function(verilate TARGET)
|
|||
set_property(TARGET ${TARGET} PROPERTY VERILATOR_TRACE_SAIF ON)
|
||||
endif()
|
||||
|
||||
if(${VERILATE_PREFIX}_SC)
|
||||
# If any verilate() call specifies SYSTEMC, define VM_SC in the final build
|
||||
set_property(TARGET ${TARGET} PROPERTY VERILATOR_SYSTEMC ON)
|
||||
if(${VERILATE_PREFIX}_TRACE_VCD)
|
||||
# If any verilate() call specifies TRACE, define VM_TRACE_VCD in the final build
|
||||
set_property(TARGET ${TARGET} PROPERTY VERILATOR_TRACE ON)
|
||||
set_property(TARGET ${TARGET} PROPERTY VERILATOR_TRACE_VCD ON)
|
||||
endif()
|
||||
|
||||
if(${VERILATE_PREFIX}_TRACE_STRUCTS)
|
||||
|
|
Loading…
Reference in New Issue