diff --git a/tgt-vhdl/process.cc b/tgt-vhdl/process.cc index cc2d9b649..a67f95864 100644 --- a/tgt-vhdl/process.cc +++ b/tgt-vhdl/process.cc @@ -81,6 +81,10 @@ int draw_process(ivl_process_t proc, void *cd) { ivl_scope_t scope = ivl_process_scope(proc); + debug_msg("Translating process in %s (%s:%d)", + ivl_scope_name(scope), ivl_process_file(proc), + ivl_process_lineno(proc)); + // A process should occur in a module scope, therefore it // should have already been assigned a VHDL entity assert(ivl_scope_type(scope) == IVL_SCT_MODULE); diff --git a/tgt-vhdl/scope.cc b/tgt-vhdl/scope.cc index 98426bc36..715ee3424 100644 --- a/tgt-vhdl/scope.cc +++ b/tgt-vhdl/scope.cc @@ -129,7 +129,7 @@ static string visible_nexus_signal_name(nexus_private_t *priv, vhdl_scope *scope * Generates VHDL code to fully represent a nexus. */ void draw_nexus(ivl_nexus_t nexus) -{ +{ nexus_private_t *priv = new nexus_private_t; int nexus_signal_width = -1; priv->const_driver = NULL; @@ -275,6 +275,8 @@ vhdl_var_ref *nexus_to_var_ref(vhdl_scope *scope, ivl_nexus_t nexus) */ static void declare_logic(vhdl_arch *arch, ivl_scope_t scope) { + debug_msg("Declaring logic in scope %s", ivl_scope_name(scope)); + int nlogs = ivl_scope_logs(scope); for (int i = 0; i < nlogs; i++) draw_logic(arch, ivl_scope_log(scope, i)); @@ -321,6 +323,8 @@ static string make_safe_name(ivl_signal_t sig) */ static void declare_signals(vhdl_entity *ent, ivl_scope_t scope) { + debug_msg("Declaring signals in scope %s", ivl_scope_name(scope)); + int nsigs = ivl_scope_sigs(scope); for (int i = 0; i < nsigs; i++) { ivl_signal_t sig = ivl_scope_sig(scope, i); @@ -518,6 +522,9 @@ static int draw_function(ivl_scope_t scope, ivl_scope_t parent) { assert(ivl_scope_type(scope) == IVL_SCT_FUNCTION); + debug_msg("Generating function %s (%s)", ivl_scope_tname(scope), + ivl_scope_name(scope)); + // Find the containing entity vhdl_entity *ent = find_entity(ivl_scope_name(parent)); assert(ent); @@ -663,6 +670,8 @@ static void create_skeleton_entity_for(ivl_scope_t scope) */ static int draw_skeleton_scope(ivl_scope_t scope, void *_parent) { + debug_msg("Initial visit to scope %s", ivl_scope_name(scope)); + switch (ivl_scope_type(scope)) { case IVL_SCT_MODULE: create_skeleton_entity_for(scope); diff --git a/tgt-vhdl/vhdl.cc b/tgt-vhdl/vhdl.cc index f871bec7f..e3ab25fe9 100644 --- a/tgt-vhdl/vhdl.cc +++ b/tgt-vhdl/vhdl.cc @@ -87,6 +87,24 @@ void error(const char *fmt, ...) g_errors++; } +/* + * Print a message only if -pdebug was specified. + */ +void debug_msg(const char *fmt, ...) +{ + std::va_list args; + + va_start(args, fmt); + + if (std::strcmp(ivl_design_flag(g_design, "debug"), "")) { + std::fputs("[DEBUG] ", stdout); + std::vprintf(fmt, args); + std::putchar('\n'); + } + + va_end(args); +} + /* * Find an entity given a scope name. */ diff --git a/tgt-vhdl/vhdl_target.h b/tgt-vhdl/vhdl_target.h index 5d5753379..cf0adf890 100644 --- a/tgt-vhdl/vhdl_target.h +++ b/tgt-vhdl/vhdl_target.h @@ -14,6 +14,7 @@ using namespace std; void error(const char *fmt, ...); +void debug_msg(const char *fmt, ...); int draw_scope(ivl_scope_t scope, void *_parent); int draw_process(ivl_process_t net, void *cd);