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

Can't find field of aggregate Memory in nested Module #971

Closed
nhynes opened this issue Dec 28, 2018 · 3 comments
Closed

Can't find field of aggregate Memory in nested Module #971

nhynes opened this issue Dec 28, 2018 · 3 comments

Comments

@nhynes
Copy link

nhynes commented Dec 28, 2018

Type of issue: bug report

Impact: no functional change

What is the current behavior?

Pseudo-MWE

class MyModule extends Module {
  val io = IO(...)
  val mem = SyncReadMem(42, new Bundle {
    val a = Bool()
    val b = Bool()
  })
}

class Top extends Module {
  val io = IO(...)
  val mm = Module(new MyModule)
}

// in TopTest.scala
class TestingTop extends Top {
  loadMemoryFromFile(mm.mem, "memfile")
  // annotation could also go in MyModule itself but gives the same error
}

Compiling this yields the following error

java.util.NoSuchElementException: key not found: MyModule.mem_b
...
...
at treadle.executable.MemoryInitializer.$anonfun$memoryMetadata$1(Memory.scala:614)

For some reason mem_a is found? I wonder if I'm not running into DCE since it works fine when MyModule is the Top.

What is the expected behavior?

It should Just Work (TM).

Please tell us about your environment:

master branch of all relevant repos (including chisel-testers2 since that seems to be relevant)

@nhynes nhynes changed the title Incorrect module name for nested LoadMemoryAnnotation Incorrect LoadMemoryAnnotation component name for nested Module's memory Dec 28, 2018
@nhynes nhynes changed the title Incorrect LoadMemoryAnnotation component name for nested Module's memory Can't find field of aggregate Memory in nested Module Dec 28, 2018
@nhynes
Copy link
Author

nhynes commented Dec 28, 2018

Yep. DCE FTW. Sorry for the spam.

For reference, a quick and dirty fix is to just

ptionsManager.firrtlOptions.annotations :+ firrtl.transforms.NoDCEAnnotation

@Croyyin
Copy link

Croyyin commented Jun 15, 2021

Yep. DCE FTW. Sorry for the spam.

For reference, a quick and dirty fix is to just

ptionsManager.firrtlOptions.annotations :+ firrtl.transforms.NoDCEAnnotation

I'm sorry to disturb you, but I wonder where I should use ''ptionsManager.firrtlOptions.annotations :+ firrtl.transforms.NoDCEAnnotation''.

@wubinyi
Copy link

wubinyi commented Jul 2, 2021

Yep. DCE FTW. Sorry for the spam.
For reference, a quick and dirty fix is to just

ptionsManager.firrtlOptions.annotations :+ firrtl.transforms.NoDCEAnnotation

I'm sorry to disturb you, but I wonder where I should use ''ptionsManager.firrtlOptions.annotations :+ firrtl.transforms.NoDCEAnnotation''.

You can do it like the following code.

import org.scalatest._
import chiseltest._
import chisel3._
import chiseltest.experimental.TestOptionBuilder.ChiselScalatestOptionBuilder
import firrtl.transforms.NoDCEAnnotation

class myModuleTests extends FlatSpec with ChiselScalatestTester with Matchers {

	behavior of "my module"

	it should("do something") in {
		val annotations = Seq(
			NoDCEAnnotation
		)
		test(new MyModule()).withAnnotations(annotations) {dut =>
                        // "write your test"
		}
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants