-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure the VHDL BB for Signed.fromInteger can handle any Netlist E…
…xpr (#2157) Previously it could only handle Identifier. (And Literal, which is handled seperately in Clash.Backend.VHDL.expr_) I've also renamed it to make it clear this blackbox is VHDL only. Fixes #2149
- Loading branch information
1 parent
e502f16
commit 5a86ccf
Showing
6 changed files
with
46 additions
and
12 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
changelog/2022-04-01T16_38_37+02_00_fix_Signed.fromInteger_VHDL_BB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FIXED: The VHDL BB for Signed.fromInteger can now handle any Netlist Expr as input [#2149](https://github.com/clash-lang/clash-compiler/issues/2149) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module T2149 where | ||
|
||
import Clash.Prelude | ||
import Clash.Explicit.Testbench | ||
|
||
topEntity :: Word -> Signed 8 | ||
topEntity = fromIntegral | ||
{-# NOINLINE topEntity #-} | ||
|
||
testBench :: Signal System Bool | ||
testBench = done | ||
where | ||
testInput = stimuliGenerator clk rst (negNr 42 :> posNr 41 :> negNr (-40) :> posNr (-39) :> Nil) | ||
expectedOutput = outputVerifier' clk rst (42 :> 41 :> (-40) :> (-39) :> Nil) | ||
done = expectedOutput (topEntity <$> testInput) | ||
clk = tbSystemClockGen (not <$> done) | ||
rst = systemResetGen | ||
|
||
|
||
-- | Use input as the lower byte of the output, and set its bits 31 and 63 | ||
-- | ||
-- By setting both bit 31 and 63, the sign-bit of the intermediate Integer is always set, | ||
-- no matter if we're representing it as a signed 64 or 32 bit number. | ||
negNr :: Signed 8 -> Word | ||
negNr x = unpack (resize (pack x)) .|. bit 31 .|. bit 63 | ||
|
||
|
||
posNr :: Signed 8 -> Word | ||
posNr x = unpack (resize (pack x)) .|. bit 30 |