Skip to content

Commit

Permalink
Add debugging output to VHDL target
Browse files Browse the repository at this point in the history
Prints progress when -pdebug=1 specified.

Adds a new debug_msg function to print progress messages.
  • Loading branch information
nickg authored and steveicarus committed Nov 30, 2008
1 parent fc00bd9 commit 1cc5586
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tgt-vhdl/process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 10 additions & 1 deletion tgt-vhdl/scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions tgt-vhdl/vhdl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
1 change: 1 addition & 0 deletions tgt-vhdl/vhdl_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1cc5586

Please sign in to comment.