Skip to content
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

Handle zero-width custom types #874

Merged
merged 1 commit into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clash-ghc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,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