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

feat: add loadHex function for SparseMemory #1015

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

hanm2019
Copy link
Contributor

@hanm2019 hanm2019 commented Jan 12, 2023

Closes #1014

Context, Motivation & Description

the SparseMemory in lib/src/main/scala/spinal/lib/bus/amba4/axi/sim/AxiMemorySim.scala has a function loadbin() so that in the simulation, we can init the memory through bin file. It may be more convenient that offer a function loadHex(), so that we can directly init the memory by hex file

Impact on code generation

Has no impact on code generation, this function impact the simulation of AxiMemorySim

However, I am not sure the implement of loadHex() is right, would you please review this code, I have test this function on a hex file.

Checklist

  • Unit tests were added
  • API changes are or will be documented:

@numero-744 numero-744 changed the title add loadHex function for SparseMemory feat: add loadHex function for SparseMemory Jan 12, 2023
hanm2019 and others added 3 commits January 13, 2023 09:23
…cala

Co-authored-by: Côme <42908717+numero-744@users.noreply.github.com>
Co-authored-by: Côme <42908717+numero-744@users.noreply.github.com>
@hanm2019
Copy link
Contributor Author

I also update the readHexFile function in HexTools.
In my opinion, the HexOffset may bigger than 0x80000000, If the datatype of HexOffset is int, this value will exceed the value range of int. Maybe use Long is better.
I also update the hToI function with the same reason.

for example. In hex file, there is a line:

:02 00 00 04 8000 7A

this line means that the offset will change to 0x8000 << 16. If the hToI use Integer.parseInt to parse this string, It will get -2147483648, not the 2147483648.

@kleinai
Copy link
Collaborator

kleinai commented Jan 14, 2023

Makes sense. Is this ready to merge now?

@Readon
Copy link
Collaborator

Readon commented Jan 17, 2023

Is that possible to add some test for this? It would be good in two points.

  1. help user to know how to use it.
  2. ensure code is working as expected.

@hanm2019
Copy link
Contributor Author

Is that possible to add some test for this? It would be good in two points.

  1. help user to know how to use it.
  2. ensure code is working as expected.

I have add some test for loadHex

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

Successfully merging this pull request may close these issues.

add loadHex function for SparseMemory
4 participants