chipsalliance / chipsalliance/chisel

Reading binary by loadMemoryFromFile() causes MalformedInputException

Open
#1,835 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Scala
Stars
4.8k
Forks
658
Avg merge
18h 59m
Merged PRs (30d)
14

Description

**Type of issue**: bug report
**Impact**: no functional change
**Development Phase**: request

**If the current behavior is a bug, please provide the steps to reproduce the problem:**

This call:
```scala
loadMemoryFromFile(mem, fileName, MemoryLoadFileType.Binary)
```
causes error:
```
java.nio.charset.MalformedInputException: Input length = 1
````

However, the same binary can be loaded by `java.nio.file.Files.readAllBytes` without problems.

Complete code to reproduce error: https://gist.github.com/learning-chip/07007f5a6c8f0c69f85d806e89756f85
Instruction binary is generated by: https://gist.github.com/learning-chip/f3d00568437ef5e2541c0ea6ac792a1d
Both can run in the online notebook at https://github.com/freechipsproject/chisel-bootcamp

**Please tell us about your environment:**
Chisel v3.4.2
chiseltest v0.3.2

Contributor guide

Open the contributing guide

Research direction

Start at the loadMemoryFromFile(mem, fileName, MemoryLoadFileType.Binary) entry point and compare its binary-file handling with java.nio.file.Files.readAllBytes. Use the complete reproduction gist and the generated instruction binary to reproduce the MalformedInputException under Chisel 3.4.2 and chiseltest 0.3.2. Done means the binary loads without a charset-related exception while existing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, scala
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.