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
Fix Index maxBound #79
Fix Index maxBound #79
Conversation
The test also succeeded on the Travis system, so it's not just my system. I did some further digging. --- Bounds_outputVerifierzm_11.v.orig 2015-09-16 17:07:55.743103623 +0200
+++ Bounds_outputVerifierzm_11.v 2015-09-16 17:14:42.189103247 +0200
@@ -43,6 +43,10 @@
if (eta_i2 != repANF_0) begin
$display("%s, expected: %b, actual: %b", ("outputVerifier"), repANF_0, eta_i2);
$finish;
+ end else if (eta_i2 == repANF_0) begin
+ $display("%s, expected: %b, considered equal to actual: %b", ("outputVerifier"), repANF_0, eta_i2);
+ end else begin
+ $display("%s, expected: %b, considered neither equal nor unequal to actual: %b", ("outputVerifier"), repANF_0, eta_i2);
end
end
// pragma translate_on It shows what's happening in the test:
Now the question is why it's getting those z's |
The problem is due to the wrong implementation of the static evaluater at: https://github.com/clash-lang/clash-compiler/blob/master/clash-ghc/src-ghc/CLaSH/GHC/Evaluator.hs#L23, specifically the combination of cases:
I'll fix that tomorrow. |
c409e2b fixes the static evaluator. Can rebase your branch on top of it? |
b8b7d6a fixes the all |
Yes, it will rebase it on the current master, tomorrow. |
Mmm, with that it fails with
Where as on my local machine this fails with
Seems like Travis is automatically merging this with master before checking, and the z's are gone. |
7aeb246
to
d6d519c
Compare
I tried to pick some non-trivial case, ie non powers of 2. Note that this test currently fails, because: - maxBound on Index is broken for VHDL - min/maxBound on Unsigned are broken when being converted to Integer The maxBound on Index will be fixed in the next commit.
Even if the the bits are X,Z,etc. This should prevent any false positives in the tests results.
d6d519c
to
36a2764
Compare
I traced the source of the ghdl error: signal repANF_8 : unsigned(3 downto 0);
signal repANF_11 : integer;
...
repANF_8 <= to_unsigned(repANF_11,integer(ceil(log2(real(max(2,10))))));
repANF_11 <= 10 - 1; And ghdl doesn't like that conversion to_unsigned of the signal, even though the signal is static. |
@leonschoorl did you try to report this as a ghdl bug? |
No, I just figured this out. Although is it at least annoying that it doesn't provide any location information for the error. |
The problem is that, initially, all scalars in VHDL are initialised to their so-called The type of
where
That is, What you see is that, at initialisation of the VHDL simulator, 0ns delta cycle 0, Perhaps other simulators either initialise |
As a work-around, make the
|
That works for the case in outputVerifierzm, but because of the way I generate the stimuli I would like to do But it doesn't seem possible to get the length of a vector as SNat. |
just do:
|
This makes them easier to translate from clash
Oh that's easy. I was under the impression the there was something "magic" about stimuliGenerator that was required to generate a proper testbench. And another thing I ran into here, pattern matching on |
No, there's nothing "magic" about With regards to pattern matching on I'm thinking to work around it by introducing a pattern synonym in the next version of the CLaSH prelude. |
This started out as one simple thing, and then became many things.
If you like I can open separate issues.
First the vhdl primitive for maxBound on Index was broken.
Here is a fix for that.
I also included a test which checks the bounds of Index and some other types.
But this test currently fails, because it turns out that when min/maxBound of type Unsigned are converted to Integer, then something breaks.
When translating clash seems think:
Furthermore the testbench for Bounds should currently fail for both VHDL and Verilog.
And it does fail in both Modelsim and ISim.
But I couldn't get iverilog/vvp to fail it on my machine.
If the vvp test for this succeeds on the Travis CI system in the current state, then is a bug.