Skip to content

Commit

Permalink
Bump version number to 0.1.0.2; fix name mangling in ToVHDL; tweak
Browse files Browse the repository at this point in the history
Fibonacci example to remove "module" header (should me Main, not Fibonacci)
  • Loading branch information
aprocter committed May 19, 2016
1 parent 2b3714d commit 051b526
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
5 changes: 3 additions & 2 deletions ReWire.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: ReWire
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
version: 0.1.0.1
version: 0.1.0.2

-- A short (one-line) description of the package.
synopsis: A Haskell-to-VHDL compiler
Expand Down Expand Up @@ -54,7 +54,8 @@ data-files: lib/*.hs
cabal-version: >=1.10

library
build-depends: base >=4.6 && <5
build-depends: ghc >=7.6.3
, base >=4.6 && <5
, bytestring >= 0.10
, containers >= 0.5
, deepseq >= 1.3.0
Expand Down
26 changes: 15 additions & 11 deletions ReWire/PreHDL/ToVHDL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ module ReWire.PreHDL.ToVHDL where

import ReWire.PreHDL.Syntax
import Data.List (intercalate)
import Encoding (zEncodeString) -- this is from the ghc package

mangle :: String -> String
mangle = zEncodeString

vTy :: Ty -> String
vTy (TyBits n) = "std_logic_vector(0 to " ++ show (n-1) ++ ")"
Expand Down Expand Up @@ -34,8 +38,8 @@ vRHS :: RHS -> String
vRHS (BoolRHS b) = vBool b
vRHS (LocRHS "input") = "input_tmp" -- FIXME: kludge
vRHS (LocRHS l) = l
vRHS (FunCallRHS s []) = s
vRHS (FunCallRHS s ls) = s ++ "(" ++ intercalate "," ls ++ ")"
vRHS (FunCallRHS s []) = mangle s
vRHS (FunCallRHS s ls) = mangle s ++ "(" ++ intercalate "," ls ++ ")"
vRHS (ConstRHS bs) = "\"" ++ concatMap show bs ++ "\""
vRHS (SliceRHS lo hi r) = r ++ "(" ++ show lo ++ " to " ++ show hi ++ ")"
vRHS (ConcatRHS ls) = "(" ++ intercalate " & " ls ++ ")"
Expand Down Expand Up @@ -75,23 +79,23 @@ vCmd (CaseIf bs) = let (b1,c1) = head bs


vFunDefnProto :: FunDefn -> String
vFunDefnProto fd = "function " ++ funDefnName fd ++ (if null params
then ""
else "(" ++ intercalate " ; " (map ((++" : std_logic_vector") . regDeclName) params) ++ ")")
++ " return std_logic_vector;"
vFunDefnProto fd = "function " ++ mangle (funDefnName fd) ++ (if null params
then ""
else "(" ++ intercalate " ; " (map ((++" : std_logic_vector") . regDeclName) params) ++ ")")
++ " return std_logic_vector;"
where params = funDefnParams fd

vFunDefn :: FunDefn -> String
vFunDefn fd = "function " ++ funDefnName fd ++ (if null params
then ""
else "(" ++ intercalate " ; " (map ((++" : std_logic_vector") . regDeclName) params) ++ ")")
++ " return std_logic_vector\n"
vFunDefn fd = "function " ++ mangle (funDefnName fd) ++ (if null params
then ""
else "(" ++ intercalate " ; " (map ((++" : std_logic_vector") . regDeclName) params) ++ ")")
++ " return std_logic_vector\n"
++ "is\n"
++ indent (concatMap ((++"\n") . vRegDecl) (funDefnRegDecls fd))
++ "begin\n"
++ indent (vCmd (funDefnBody fd) ++ "\n")
++ indent ("return " ++ funDefnResultReg fd ++ ";\n")
++ "end " ++ funDefnName fd ++ ";"
++ "end " ++ mangle (funDefnName fd) ++ ";"
where params = funDefnParams fd

flopName, flopNextName :: String -> String
Expand Down
2 changes: 0 additions & 2 deletions examples/Fibonacci/Fibonacci.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module Fibonacci where

--
-- The compiler doesn't yet support a "prelude" so we will have to define a
-- few things ourselves!
Expand Down

0 comments on commit 051b526

Please sign in to comment.