-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Identifiers which are assigned an inlined function now have a prefix with the name of the function that was inlined. This makes it clearer what the provinence of an assigment is in HDL.
- Loading branch information
Alex McKenna
committed
Dec 9, 2019
1 parent
9a57643
commit 197eefb
Showing
9 changed files
with
158 additions
and
63 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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,55 @@ | ||
module NameInlining where | ||
|
||
import qualified Prelude as P | ||
import Data.List (isInfixOf) | ||
import System.Environment (getArgs) | ||
import System.FilePath ((</>), takeDirectory) | ||
|
||
import Clash.Prelude | ||
|
||
f :: Int -> Int -> Int | ||
f a b = g a b * g b a | ||
{-# ANN f (Synthesize | ||
{ t_name = "f" | ||
, t_inputs = [PortName "f_x", PortName "f_y"] | ||
, t_output = PortName "result" | ||
}) #-} | ||
|
||
g :: Int -> Int -> Int | ||
g = setName @"foo" h | ||
|
||
h :: Int -> Int -> Int | ||
h x y = if signum (x - y) == 1 then x else y | ||
{-# ANN h (Synthesize | ||
{ t_name = "h" | ||
, t_inputs = [PortName "h_x", PortName "h_y"] | ||
, t_output = PortName "diff" | ||
}) #-} | ||
|
||
assertIn :: String -> String -> IO () | ||
assertIn needle haystack | ||
| needle `isInfixOf` haystack = return () | ||
| otherwise = P.error $ mconcat [ "Expected:\n\n ", needle | ||
, "\n\nIn:\n\n", haystack ] | ||
|
||
mainVHDL :: IO () | ||
mainVHDL = do | ||
[topDir] <- getArgs | ||
content <- readFile (takeDirectory topDir </> "f" </> "f.vhdl") | ||
|
||
assertIn "g_foo" content | ||
|
||
mainVerilog :: IO () | ||
mainVerilog = do | ||
[topDir] <- getArgs | ||
content <- readFile (takeDirectory topDir </> "f" </> "f.v") | ||
|
||
assertIn "g_foo" content | ||
|
||
mainSystemVerilog :: IO () | ||
mainSystemVerilog = do | ||
[topDir] <- getArgs | ||
content <- readFile (takeDirectory topDir </> "f" </> "f.sv") | ||
|
||
assertIn "g_foo" content | ||
|
Oops, something went wrong.