Skip to content

Commit

Permalink
Fix for pr3499807.
Browse files Browse the repository at this point in the history
If a tranif gate has a delay, the vvp code generator needs to generate
a unique label for the island port used for the tranif enable, to
prevent a name collision if the undelayed signal is also connected
to the island.

Also add an assertion in vvp to catch bugs like this.
  • Loading branch information
Martin Whitaker authored and caryr committed Mar 12, 2012
1 parent bae0243 commit 327194c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 6 additions & 6 deletions tgt-vvp/draw_switch.c
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2010,2012 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -38,7 +38,6 @@ void draw_switch_in_scope(ivl_switch_t sw)
ivl_expr_t fall_exp = ivl_switch_delay(sw, 1);
ivl_expr_t decay_exp= ivl_switch_delay(sw, 2);

/* We do not support tran delays. */
if ((rise_exp || fall_exp || decay_exp) &&
(!number_is_immediate(rise_exp, 64, 0) ||
number_is_unknown(rise_exp) ||
Expand Down Expand Up @@ -76,15 +75,16 @@ void draw_switch_in_scope(ivl_switch_t sw)
processing doesn't have to deal with it. */
const char*raw = draw_net_input(enable);

snprintf(str_e_buf, sizeof str_e_buf, "p%p", sw);
str_e = str_e_buf;

fprintf(vvp_out, "%s/d .delay 1 "
"(%" PRIu64 ",%" PRIu64 ",%" PRIu64 ") %s;\n",
raw, get_number_immediate64(rise_exp),
str_e, get_number_immediate64(rise_exp),
get_number_immediate64(fall_exp),
get_number_immediate64(decay_exp), raw);

fprintf(vvp_out, "p%p .import I%p, %s/d;\n", enable, island, raw);
snprintf(str_e_buf, sizeof str_e_buf, "p%p", enable);
str_e = str_e_buf;
fprintf(vvp_out, "%s .import I%p, %s/d;\n", str_e, island, str_e);

} else if (enable) {
str_e = draw_island_net_input(island, enable);
Expand Down
5 changes: 4 additions & 1 deletion vvp/vvp_island.cc
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2010,2012 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -94,6 +94,9 @@ void vvp_island::add_port(const char*key, vvp_net_t*net)
if (ports_ == 0)
ports_ = new symbol_map_s<vvp_net_t>;

// each port should have a unique label
assert(ports_->sym_get_value(key) == 0);

ports_->sym_set_value(key, net);
}

Expand Down

0 comments on commit 327194c

Please sign in to comment.