-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix (System)Verilog literal rendering of Index values
There was confusion between the size in bits and the type level argument to Index. Fixes #2813
- Loading branch information
1 parent
d4975ff
commit 3f14181
Showing
3 changed files
with
10 additions
and
5 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
changelog/2024-10-01T14_41_36+02_00_fix_index_literal_rendering
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: Clash hanging when rendering `Index n` literals, for large values of `n` [#2813](https://github.com/clash-lang/clash-compiler/issues/2813) |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{-| | ||
Copyright : (C) 2015-2016, University of Twente, | ||
2017-2018, Google Inc., | ||
2021-2023, QBayLogic B.V., | ||
2021-2024, QBayLogic B.V., | ||
2022 , Google Inc. | ||
License : BSD2 (see the file LICENSE) | ||
Maintainer : QBayLogic B.V. <[email protected]> | ||
|
@@ -65,7 +65,7 @@ import Clash.Netlist.Types hiding (intWidth, usages, | |
import Clash.Netlist.Util | ||
import Clash.Signal.Internal (ActiveEdge (..)) | ||
import Clash.Util | ||
(SrcSpan, noSrcSpan, curLoc, makeCached, indexNote) | ||
(SrcSpan, clogBase, noSrcSpan, curLoc, makeCached, indexNote) | ||
import Clash.Util.Graph (reverseTopSort) | ||
|
||
-- | State for the 'Clash.Backend.SystemVerilog.SystemVerilogM' monad: | ||
|
@@ -1228,7 +1228,9 @@ expr_ _ (BlackBoxE pNm _ _ _ _ bbCtx _) | |
expr_ _ (BlackBoxE pNm _ _ _ _ bbCtx _) | ||
| pNm == "Clash.Sized.Internal.Index.fromInteger#" | ||
, [Literal _ (NumLit n), Literal _ i] <- extractLiterals bbCtx | ||
= exprLitSV (Just (Index (fromInteger n),fromInteger n)) i | ||
, Just k <- clogBase 2 n | ||
, let k' = max 1 k | ||
= exprLitSV (Just (Index (fromInteger n),k')) i | ||
|
||
expr_ b (BlackBoxE _ libs imps inc bs bbCtx b') = | ||
parenIf (b || b') (Ap (renderBlackBox libs imps inc bs bbCtx <*> pure 0)) | ||
|
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