Skip to content

Commit

Permalink
~IF Primitive template allows SNat's as ~LIT literals
Browse files Browse the repository at this point in the history
  • Loading branch information
christiaanb committed Feb 16, 2017
1 parent 10e0fb7 commit 922fcf5
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions clash-lib/src/CLaSH/Netlist/BlackBox/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,20 @@ renderElem b (IF c t f) = do
(Length e) -> case lineToType b [e] of
(Vector n _) -> n
_ -> error $ $(curLoc) ++ "IF: veclen of a non-vector type"
(L n) -> case bbInputs b !! n of
(either id fst -> Literal _ l,_,_) ->
case l of
NumLit i -> fromInteger i
BitLit bl -> case bl of
N.H -> 1
N.L -> 0
_ -> error $ $(curLoc) ++ "IF: LIT bit literal must be high or low"
BoolLit bl -> bool 0 1 bl
_ -> error $ $(curLoc) ++ "IF: LIT must be a numeric lit"
_ -> error $ $(curLoc) ++ "IF: LIT must be a numeric lit"
(L n) -> case bbInputs b !! n of
(l,_,_)
| Literal _ l' <- either id fst l ->
case l' of
NumLit i -> fromInteger i
BitLit bl -> case bl of
N.H -> 1
N.L -> 0
_ -> error $ $(curLoc) ++ "IF: LIT bit literal must be high or low"
BoolLit bl -> bool 0 1 bl
_ -> error $ $(curLoc) ++ "IF: LIT must be a numeric lit"
| DataCon (Signed _) _ [Literal _ (NumLit i)] <- either id fst l
-> fromInteger i
k -> error $ $(curLoc) ++ ("IF: LIT must be a numeric lit:" ++ show k)
(Depth e) -> case lineToType b [e] of
(RTree n _) -> n
_ -> error $ $(curLoc) ++ "IF: treedepth of non-tree type"
Expand Down

0 comments on commit 922fcf5

Please sign in to comment.