Skip to content

Commit

Permalink
Get ChiselSim working with CIRCT 1.66+ (#3890) (#3891)
Browse files Browse the repository at this point in the history
Fix an incorrect assumption in ChiselSim that a 'filelist.f' will exist
that includes all modules, _including blackboxes_, in the design.  Change
this to try to also copy files from the black box filelist.  This makes
ChiselSim work with CIRCT 1.66 and earlier (which put everything in
'filelist.f') and CIRCT 1.66+ (which does not include blackboxes in
'filelist.f').

Note that this is intended as a temporary solution until FIRRTL has a rock
solid ABI that is implemented by CIRCT where all modules can be discovered
under an arbitrary public module.

See CIRCT changes here: llvm/circt#6729

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
(cherry picked from commit 9448d32)

Co-authored-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
  • Loading branch information
mergify[bot] and seldridge authored Mar 1, 2024
1 parent d5b0c84 commit d9a40ea
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions src/main/scala/chisel3/simulator/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,38 @@ package object simulator {
)
)

// Move the relevant files over to primary-sources
val filelist =
new java.io.BufferedReader(new java.io.FileReader(s"${workspace.supportArtifactsPath}/filelist.f"))
try {
filelist.lines().forEach { immutableFilename =>
var filename = immutableFilename
/// Some files are provided as absolute paths
if (filename.startsWith(workspace.supportArtifactsPath)) {
filename = filename.substring(workspace.supportArtifactsPath.length + 1)
// Move the files indicated by a filelist.
def moveFiles(filename: String) = {
val filelist = new java.io.BufferedReader(new java.io.FileReader(filename))
try {
filelist.lines().forEach { immutableFilename =>
var filename = immutableFilename
/// Some files are provided as absolute paths
if (filename.startsWith(workspace.supportArtifactsPath)) {
filename = filename.substring(workspace.supportArtifactsPath.length + 1)
}
java.nio.file.Files.move(
java.nio.file.Paths.get(s"${workspace.supportArtifactsPath}/$filename"),
java.nio.file.Paths.get(s"${workspace.primarySourcesPath}/$filename")
)
}
java.nio.file.Files.move(
java.nio.file.Paths.get(s"${workspace.supportArtifactsPath}/$filename"),
java.nio.file.Paths.get(s"${workspace.primarySourcesPath}/$filename")
)
} finally {
filelist.close()
}
} finally {
filelist.close()
}

// Move a file in a filelist which may not exist.
def maybeMoveFiles(filename: String) = try {
moveFiles(filename)
} catch {
case _ @(_: java.nio.file.NoSuchFileException | _: java.io.FileNotFoundException) =>
}

// Move files indicated by 'filelist.f' (which must exist). Move files
// indicated by a black box filelist (which may exist).
moveFiles(s"${workspace.supportArtifactsPath}/filelist.f")
maybeMoveFiles(s"${workspace.supportArtifactsPath}/firrtl_black_box_resource_files.f")

// Initialize Module Info
val dut = someDut.get
val ports = {
Expand Down

0 comments on commit d9a40ea

Please sign in to comment.