Skip to content

Conversation

@marijn-qbaylogic
Copy link
Contributor

dumpVCD was 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:

  • Check copyright notices are up to date in edited files

Comment on lines 375 to 379
labels = "!" : map go [1..]
where
go 0 = ""
go n = chr ( 33 + n `mod` k) : go (n `div` k)
k = 126-33+1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this instead:

Suggested change
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)

Copy link
Contributor Author

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.

Copy link
Member

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 :-).

Copy link
Member

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).

Comment on lines 428 to 430
format 1 label (0,0) = '0': label <> "\n"
format 1 label (0,1) = '1': label <> "\n"
format 1 label (1,_) = 'x': label <> "\n"
Copy link
Member

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.

Copy link
Contributor Author

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]) ++ " " ++ label

Copy link
Member

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.

@marijn-qbaylogic marijn-qbaylogic force-pushed the fix-3082-dumpvcd-trace-limit branch from 1c910be to 8c6d1f8 Compare November 20, 2025 12:56
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.

dumpVCD can only dump 93 signals

4 participants