Skip to content

Commit

Permalink
Handle zero-width custom types
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnbastiaan committed Oct 29, 2019
1 parent 191701d commit 2875675
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
3 changes: 2 additions & 1 deletion clash-ghc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
* [#662](https://github.com/clash-lang/clash-compiler/issues/662): Clash will now constant specialize partially constant constructs
* [#700](https://github.com/clash-lang/clash-compiler/issues/700): Check work content of expression in cast before warning users. Should eliminate a lot of (superfluous) warnings about "specializing on non work-free cast"s.
* [#837](https://github.com/clash-lang/clash-compiler/issues/837): Blackboxes will now report clearer error messages if they're given unexpected arguments.
* [#869](https://github.com/clash-lang/clash-compiler/issues/869): PLL is duplicated in Blinker.hs example
* [#869](https://github.com/clash-lang/clash-compiler/issues/869): PLL is no longer duplicated in Blinker.hs example

* Small fixes without issue reports:
* Fix bug in `rnfX` defined for `Down` ([baef30e](https://github.com/clash-lang/clash-compiler/commit/baef30eae03dc02ba847ffbb8fae7f365c5287c2))
* Render numbers inside gensym ([bc76f0f](https://github.com/clash-lang/clash-compiler/commit/bc76f0f1934fd6e6ed9c33bcf950dae21e2f7903))
* Report blackbox name when encountering an error in 'setSym' ([#858](https://github.com/clash-lang/clash-compiler/pull/858))
* Fix blackbox issues causing Clash to generate invalid HDL ([#865](https://github.com/clash-lang/clash-compiler/pull/865))
* Treat types with a zero-width custom bit representation like other zero-width constructs ([#874](https://github.com/clash-lang/clash-compiler/pull/874))

* Deprecations & removals:
* Removed support for GHC 8.2 ([#842](https://github.com/clash-lang/clash-compiler/pull/842))
Expand Down
14 changes: 4 additions & 10 deletions clash-lib/src/Clash/Netlist/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,8 @@ fixCustomRepr reprs (coreToType' -> Right tyName) sum_@(Sum name subtys) =
case getDataRepr tyName reprs of
Just dRepr@(DataRepr' name' size constrs) ->
if length constrs == length subtys then
CustomSum
name
dRepr
(fromIntegral size)
[packSum reprs ty | ty <- subtys]
let cs = CustomSum name dRepr (fromIntegral size) (map (packSum reprs) subtys)
in if size <= 0 then Void (Just cs) else cs
else
error $ $(curLoc) ++ (Text.unpack $ Text.unwords
[ "Type "
Expand All @@ -272,11 +269,8 @@ fixCustomRepr reprs (coreToType' -> Right tyName) sp@(SP name subtys) =
case getDataRepr tyName reprs of
Just dRepr@(DataRepr' name' size constrs) ->
if length constrs == length subtys then
CustomSP
name
dRepr
(fromIntegral size)
[packSP reprs ty | ty <- subtys]
let csp = CustomSP name dRepr (fromIntegral size) (map (packSP reprs) subtys)
in if size <= 0 then Void (Just csp) else csp
else
error $ $(curLoc) ++ (Text.unpack $ Text.unwords
[ "Type "
Expand Down

0 comments on commit 2875675

Please sign in to comment.