Skip to content

Commit

Permalink
vlog95: for a part/pv look for the strength at the driver
Browse files Browse the repository at this point in the history
A part/pv passes strength information so we need to use the real driver
to get the appropriate drive information.
  • Loading branch information
caryr committed Feb 13, 2013
1 parent 6de80ad commit 8b4dc05
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
1 change: 0 additions & 1 deletion tgt-vlog95/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ static void emit_expr_binary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid)
emit_expr(scope, ivl_expr_oper2(expr), wid);
fprintf(vlog_out, "))");
break;
break;
default:
emit_expr(scope, ivl_expr_oper1(expr), wid);
fprintf(vlog_out, "<unknown>");
Expand Down
47 changes: 45 additions & 2 deletions tgt-vlog95/logic_lpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,53 @@ static void emit_gate_strength(ivl_net_logic_t nlogic, unsigned strength_type)
"gate", ivl_logic_file(nlogic), ivl_logic_lineno(nlogic));
}

/*
* Look for a single driver behind an LPM that passes strength information
* and get the real drive information from it.
*/
static void get_unique_lpm_drive(ivl_lpm_t lpm, ivl_drive_t *drive1,
ivl_drive_t *drive0)
{
ivl_nexus_t nex = ivl_lpm_data(lpm, 0);
unsigned idx, count = ivl_nexus_ptrs(nex);
unsigned have_driver = 0;

for (idx = 0; idx < count; idx += 1) {
ivl_nexus_ptr_t nex_ptr = ivl_nexus_ptr(nex, idx);
ivl_drive_t cur_drive1 = ivl_nexus_ptr_drive1(nex_ptr);
ivl_drive_t cur_drive0 = ivl_nexus_ptr_drive0(nex_ptr);
if ((cur_drive1 == IVL_DR_HiZ) &&
(cur_drive0 == IVL_DR_HiZ)) continue;
assert(! have_driver);
*drive1 = cur_drive1;
*drive0 = cur_drive0;
have_driver = 1;
}

/* This should never happen. */
if (! have_driver) {
fprintf(stderr, "%s:%u: vlog95 error: Unable to find drive "
"information for strength transparent LPM.\n",
ivl_lpm_file(lpm), ivl_lpm_lineno(lpm));
vlog_errors += 1;
}
}

static void emit_lpm_strength(ivl_lpm_t lpm)
{
emit_strength(ivl_lpm_drive1(lpm), ivl_lpm_drive0(lpm), 2,
"LPM", ivl_lpm_file(lpm), ivl_lpm_lineno(lpm));
ivl_lpm_type_t type = ivl_lpm_type(lpm);
ivl_drive_t drive1 = IVL_DR_STRONG;
ivl_drive_t drive0 = IVL_DR_STRONG;
/* This LPM object passes strength information so we need to look
* for the strength information at the real driver. */
if (type == IVL_LPM_PART_PV) {
get_unique_lpm_drive(lpm, &drive1, &drive0);
} else {
drive1 = ivl_lpm_drive1(lpm);
drive0 = ivl_lpm_drive0(lpm);
}
emit_strength(drive1, drive0, 2, "LPM",
ivl_lpm_file(lpm), ivl_lpm_lineno(lpm));
}

static void emit_delay(ivl_scope_t scope, ivl_expr_t rise, ivl_expr_t fall,
Expand Down

0 comments on commit 8b4dc05

Please sign in to comment.