Add debugging output to VHDL target

Prints progress when -pdebug=1 specified.

Adds a new debug_msg function to print progress messages.
This commit is contained in:
Nick Gasson 2008-11-29 22:16:46 +00:00 committed by Stephen Williams
parent fc00bd9a5b
commit 1cc5586c4d
4 changed files with 33 additions and 1 deletions

View File

@ -81,6 +81,10 @@ int draw_process(ivl_process_t proc, void *cd)
{ {
ivl_scope_t scope = ivl_process_scope(proc); 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 // A process should occur in a module scope, therefore it
// should have already been assigned a VHDL entity // should have already been assigned a VHDL entity
assert(ivl_scope_type(scope) == IVL_SCT_MODULE); assert(ivl_scope_type(scope) == IVL_SCT_MODULE);

View File

@ -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) 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); int nlogs = ivl_scope_logs(scope);
for (int i = 0; i < nlogs; i++) for (int i = 0; i < nlogs; i++)
draw_logic(arch, ivl_scope_log(scope, 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) 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); int nsigs = ivl_scope_sigs(scope);
for (int i = 0; i < nsigs; i++) { for (int i = 0; i < nsigs; i++) {
ivl_signal_t sig = ivl_scope_sig(scope, 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); 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 // Find the containing entity
vhdl_entity *ent = find_entity(ivl_scope_name(parent)); vhdl_entity *ent = find_entity(ivl_scope_name(parent));
assert(ent); 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) 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)) { switch (ivl_scope_type(scope)) {
case IVL_SCT_MODULE: case IVL_SCT_MODULE:
create_skeleton_entity_for(scope); create_skeleton_entity_for(scope);

View File

@ -87,6 +87,24 @@ void error(const char *fmt, ...)
g_errors++; 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. * Find an entity given a scope name.
*/ */

View File

@ -14,6 +14,7 @@
using namespace std; using namespace std;
void error(const char *fmt, ...); void error(const char *fmt, ...);
void debug_msg(const char *fmt, ...);
int draw_scope(ivl_scope_t scope, void *_parent); int draw_scope(ivl_scope_t scope, void *_parent);
int draw_process(ivl_process_t net, void *cd); int draw_process(ivl_process_t net, void *cd);