-
Notifications
You must be signed in to change notification settings - Fork 164
Removed the limit on the number of traces in dumpVCD
#3083
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
base: master
Are you sure you want to change the base?
Conversation
| labels = "!" : map go [1..] | ||
| where | ||
| go 0 = "" | ||
| go n = chr ( 33 + n `mod` k) : go (n `div` k) | ||
| k = 126-33+1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this instead:
| labels = "!" : map go [1..] | |
| where | |
| go 0 = "" | |
| go n = chr ( 33 + n `mod` k) : go (n `div` k) | |
| k = 126-33+1 | |
| labels = concatMap (\s -> map (snoc s) alphabet) ([]: labels) | |
| where | |
| alphabet = map chr [33..126] |
You'll need to import
import Data.List.Extra (snoc)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one fancy way of doing things.
Are there specific things that make it better? I do agree it's better, but there might be stuff I am missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the alphabet were "abc", this is what it would generate:
>>> import Text.Show.Pretty
>>> pPrint $ P.take 20 labels
[ "a"
, "b"
, "c"
, "aa"
, "ab"
, "ac"
, "ba"
, "bb"
, "bc"
, "ca"
, "cb"
, "cc"
, "aaa"
, "aab"
, "aac"
, "aba"
, "abb"
, "abc"
, "aca"
, "acb"
]It is almost how a base-n number system would work, except that 0 is also significant in leading positions. It just seems like a clean numbering to me.
It's also more Haskelly if you ask me :-).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The recursion step of the algorithm in words is roughly this:
To form all labels of length up to n+1 we take all labels up to a length n and for all of those labels and all letters of the alphabet, we append the letter of the alphabet to the label. Also, for each letter of the alphabet, include just that letter as a label (because by increasing the length of all labels we lost the labels of length 1 plus we clearly need to start somewhere).
| format 1 label (0,0) = '0': label <> "\n" | ||
| format 1 label (0,1) = '1': label <> "\n" | ||
| format 1 label (1,_) = 'x': label <> "\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file seems to use ++ for concatenating strings, in the interest of consistency I'd like to see that maintained here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at these lines, why do we even add a newline? It isn't there a few lines later:
format n label (mask,val) =
"b" ++ map digit (reverse [0..n-1]) ++ " " ++ labelThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're completely right, they don't need a newline! It's already handled in two Text.intercalate "\n"s. Let's remove it.
1c910be to
8c6d1f8
Compare
dumpVCDwas limited to 93 traces, because it could only generate single character trace identifier codes. The codes are now generated ad infinitum, and the restriction has been removed.Fixes: #3082
Still TODO: