Skip to content

Conversation

@marijn-qbaylogic
Copy link
Contributor

@marijn-qbaylogic marijn-qbaylogic commented Nov 17, 2025

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.

Additionally, single bit traces were logged with an extra newline, causing empty lines in the VCD. This has been removed as well.

Fixes: #3082

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
Copy link
Member

@DigitalBrains1 DigitalBrains1 left a comment

Choose a reason for hiding this comment

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

I'd like to stress that newlines are necessary after one-bit signals; it's just that we emitted two of them.

Please also add something similar to the PR cover letter (the first message in the PR).

@@ -0,0 +1 @@
FIXED: Removed the limit on the number of traces in `dumpVCD`. Also removed unnecessary newlines after 1-bit signals. [#3082](https://github.com/clash-lang/clash-compiler/issues/3082)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
FIXED: Removed the limit on the number of traces in `dumpVCD`. Also removed unnecessary newlines after 1-bit signals. [#3082](https://github.com/clash-lang/clash-compiler/issues/3082)
FIXED: Removed the limit on the number of traces in `dumpVCD`. Also removed unnecessary double newlines after 1-bit signals. [#3082](https://github.com/clash-lang/clash-compiler/issues/3082)

Copy link
Member

Choose a reason for hiding this comment

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

A different way to phrase it would be

Suggested change
FIXED: Removed the limit on the number of traces in `dumpVCD`. Also removed unnecessary newlines after 1-bit signals. [#3082](https://github.com/clash-lang/clash-compiler/issues/3082)
FIXED: Removed the limit on the number of traces in `dumpVCD`. Also removed unnecessary blank lines after 1-bit signals. [#3082](https://github.com/clash-lang/clash-compiler/issues/3082)

I think that's even more clear.

offensiveNames = filter (any (not . printable)) traceNames

labels = map chr [33..126]
-- Generate labels like reversed digits: 0:[1,2,01,11,21,02,12,22,001,...]
Copy link
Member

@DigitalBrains1 DigitalBrains1 Dec 15, 2025

Choose a reason for hiding this comment

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

Suggested change
-- Generate labels like reversed digits: 0:[1,2,01,11,21,02,12,22,001,...]
-- Generate labels almost like digits: if the alphabet were "012", generate
-- [0,1,2,00,01,02,10,11,12 ..]

Although frankly it can do without the comment; it's just that the current comment is wrong. Feel free to just omit it altogether.

Copy link
Member

@DigitalBrains1 DigitalBrains1 left a comment

Choose a reason for hiding this comment

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

Yup!

@DigitalBrains1 DigitalBrains1 enabled auto-merge (squash) December 15, 2025 16:31
@DigitalBrains1 DigitalBrains1 merged commit fb8f164 into master Dec 15, 2025
7 checks passed
@DigitalBrains1 DigitalBrains1 deleted the fix-3082-dumpvcd-trace-limit branch December 15, 2025 17:18
mergify bot pushed a commit that referenced this pull request Dec 15, 2025
`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.

Additionally, single bit traces were logged with an extra newline,
causing empty lines in the VCD. This has been removed as well.

Fixes: #3082
(cherry picked from commit fb8f164)
DigitalBrains1 pushed a commit that referenced this pull request Dec 16, 2025
`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.

Additionally, single bit traces were logged with an extra newline,
causing empty lines in the VCD. This has been removed as well.

Fixes: #3082
(cherry picked from commit fb8f164)

Co-authored-by: marijn-qbaylogic <marijn@qbaylogic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dumpVCD can only dump 93 signals

4 participants