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

Reg(False) / Reg(True) are valid statements #1280

Open
dnltz opened this issue Jan 12, 2024 · 3 comments
Open

Reg(False) / Reg(True) are valid statements #1280

dnltz opened this issue Jan 12, 2024 · 3 comments

Comments

@dnltz
Copy link
Contributor

dnltz commented Jan 12, 2024

I recently tried to create a Register with a default Bool value like

val first = RegInit(False)

but accidentally used Reg intead of RegInit. It seems like SpinalHDL interprets True/False as Bool and it passed all internal checks. I only realized my signal's default value sometimes changes in the simulation.

Is this behavior intended?

Can we forbid the following two statements or at least throw an warning?

val first = Reg(True)
val last = Reg(False)
@Dolu1990
Copy link
Member

Hi,

Yes, basicaly Reg(x) is equivalent to Reg(cloneOf(x))
The intend is that for instance, if you have some signal, and you want to create a register of the same type, you can just do :
Reg(myReferenceSignal).

Maybe, Reg(directLiteral) should be forbiden for satefy, as it is likely not wanted.

@dnltz
Copy link
Contributor Author

dnltz commented Jan 13, 2024

Agree, in my opinion True/False create the impression of an default value but I have no if there's a use-case for that.

I can try to forbid the directLiteral value, if you dont mind.

@Dolu1990
Copy link
Member

Sure ^^
I m curious how many times it will trigger the issue in the code base XD

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

2 participants