Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index out of bounds in builder.rs #10

Closed
rameloni opened this issue Jun 10, 2024 · 2 comments · Fixed by #11 or #18
Closed

Index out of bounds in builder.rs #10

rameloni opened this issue Jun 10, 2024 · 2 comments · Fixed by #11 or #18
Labels
bug Something isn't working

Comments

@rameloni
Copy link
Owner

rameloni commented Jun 10, 2024

This error is raised during the building process of TyVcdBuilder<hgldd::Hgldd>. It seems to happen when a vector is specified. However, the build doesn't fail with any vector. I put below a successful and a failing example in chisel.

class InterfaceBundle extends Bundle {
  val vec = Vec(2, new VecType)
}

class WithBundlesAndVecs extends Module {
  val io = IO(Input(new InterfaceBundle))
}

The error occurs or not depending on the number of fields in VecType.
I noticed it occurs when the VecType has more than 2 fields.

Failure

class VecType extends Bundle {
  val x = UInt(32.W)
  val y = Bool()
  val z = UInt(32.W)  // the 3rd causes failure
}

Also with more than 2 "indirect" subfields.

class VecType extends Bundle {
  val x = UInt(32.W)
  val y = new Bundle {
     val a = Bool()
     val b = Bool()
     val c = Bool()  // the 3rd causes failure
  }
}

No failure

class VecType extends Bundle {
  val x = UInt(32.W)
  val y = Bool()
}

It doesn't fail when the absolute number of fields is greater than 2 but each "subtype" has less than 3 members. The bundle below has 3 fields in total but VecType and the anonymous bundle have only 2.

class VecType extends Bundle {
  val x = UInt(32.W) 
  val y = new Bundle {
     val a = Bool() 
     val b = Bool()
  }
}
@rameloni
Copy link
Owner Author

The error occurs at the following lines:

#[allow(clippy::needless_range_loop)]
for i in 0..obj.port_vars.len() {
let mut var = obj.port_vars[i].clone();
var.value = Some(expressions[i].clone());
fields.push(Self::create_variable(&var, objects));
}

@rameloni rameloni added the bug Something isn't working label Jun 10, 2024
@rameloni rameloni reopened this Jun 11, 2024
@rameloni
Copy link
Owner Author

This errors occurs again when there is a multi-dimensional vector of aggregate types.

Related to #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant