Skip to content

Conversation

@quark17
Copy link
Collaborator

@quark17 quark17 commented Jan 15, 2025

For signals without source names, BSC constructs a name based on the assigned expression. If the expression contains a number, that number appears in the name. BSC filters out a few characters, such as decimal points (.) but was not eliminating negative signs (-) which can show up if a Real literal is small enough that E notation with a negative exponent is used. In that case, BSC was generating a signal name with a negative sign in it, which is not legal for names in Verilog or Bluesim. In the Verilog backend, such names are probably inlined anyway, but I ran into a situation ($display of a Real value) where the signal survived in Bluesim and caused a C++ compilation failure.

Filtering out the decimal point causes a real number to look like a large integer, which was confusing when I saw such signal names. So instead of fixing this bug by adding - to the list of characters to be removed, I changed BSC so that it replaced decimal points by d and negative signs by neg, so that the value in the name is not misinterpreted.

If a real literal was small enough to use E notation with a negative
exponent, that negative sign would appear in signal names derived from
that expression, which is illegal for both Verilog and Bluesim.  We
were eliminating decimal points from numbers, but failing to remove
negative signs.  Instead of removing them, however, we now replace
them (with "d" and "neg") so that the value in the name is not
misinterpreted.
@quark17 quark17 force-pushed the signal-name-from-real branch from 9b8178f to 9370cbc Compare January 17, 2025 09:40
This was accidentally missing from the new jobs for testing GHC versions
@quark17 quark17 merged commit 934465e into B-Lang-org:main Jan 17, 2025
79 checks passed
@quark17 quark17 deleted the signal-name-from-real branch January 17, 2025 18:30
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.

1 participant