Permalink
Browse files

Handle packed array slices at module ports.

  • Loading branch information...
1 parent 63b7fe0 commit e7a974347eb5ace09da5fc77b0f116add6c0c1b4 @steveicarus committed Apr 23, 2012
Showing with 46 additions and 16 deletions.
  1. +19 −8 elab_net.cc
  2. +27 −8 tgt-vvp/vvp_scope.c
View
@@ -364,15 +364,26 @@ bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
bool bit_defined_flag;
/* bool flag = */ calculate_bits_(des, scope, msb, bit_defined_flag);
ivl_assert(*this, bit_defined_flag);
- midx = sig->sb_to_idx(prefix_indices, msb);
- if (midx >= (long)sig->vector_width()) {
- cerr << get_fileline() << ": error: Index " << sig->name()
- << "[" << msb << "] is out of range."
- << endl;
- des->errors += 1;
- midx = 0;
+
+ if (prefix_indices.size()+2 <= sig->packed_dims().size()) {
+ long tmp_loff;
+ unsigned long tmp_lwid;
+ bool rcl = sig->sb_to_slice(prefix_indices, msb,
+ tmp_loff, tmp_lwid);
+ ivl_assert(*this, rcl);
+ midx = tmp_loff + tmp_lwid - 1;
+ lidx = tmp_loff;
+ } else {
+ midx = sig->sb_to_idx(prefix_indices, msb);
+ if (midx >= (long)sig->vector_width()) {
+ cerr << get_fileline() << ": error: Index " << sig->name()
+ << "[" << msb << "] is out of range."
+ << endl;
+ des->errors += 1;
+ midx = 0;
+ }
+ lidx = midx;
}
- lidx = midx;
} else {
cerr << get_fileline() << ": internal error: "
View
@@ -427,14 +427,19 @@ static void draw_reg_in_scope(ivl_signal_t sig)
{
int msb;
int lsb;
- if (ivl_signal_packed_dimensions(sig) > 1) {
- // FIX ME: Improve this when vvp becomes aware of packed
- // arrays.
+ switch (ivl_signal_packed_dimensions(sig)) {
+ case 0:
+ msb = 0;
+ lsb = 0;
+ break;
+ case 1:
+ msb = ivl_signal_packed_msb(sig, 0);
+ lsb = ivl_signal_packed_lsb(sig, 0);
+ break;
+ default:
msb = ivl_signal_width(sig) - 1;
lsb = 0;
- } else {
- msb = ivl_signal_msb(sig);
- lsb = ivl_signal_lsb(sig);
+ break;
}
const char*datatype_flag = ivl_signal_integer(sig) ? "/i" :
@@ -483,8 +488,22 @@ static void draw_reg_in_scope(ivl_signal_t sig)
*/
static void draw_net_in_scope(ivl_signal_t sig)
{
- int msb = ivl_signal_msb(sig);
- int lsb = ivl_signal_lsb(sig);
+ int msb;
+ int lsb;
+ switch (ivl_signal_packed_dimensions(sig)) {
+ case 0:
+ msb = 0;
+ lsb = 0;
+ break;
+ case 1:
+ msb = ivl_signal_packed_msb(sig, 0);
+ lsb = ivl_signal_packed_lsb(sig, 0);
+ break;
+ default:
+ msb = ivl_signal_width(sig) - 1;
+ lsb = 0;
+ break;
+ }
const char*datatype_flag = ivl_signal_signed(sig)? "/s" : "";
const char*local_flag = ivl_signal_local(sig)? "*" : "";

0 comments on commit e7a9743

Please sign in to comment.