Skip to content

Commit

Permalink
Reformat to 2 spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
WoWaster committed Sep 17, 2024
1 parent b1d438c commit 2f85136
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 89 deletions.
70 changes: 35 additions & 35 deletions lamagraph-compiler/src/Lamagraph/Compiler/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,58 @@
LamagraphML syntax
-}
module Lamagraph.Compiler.Syntax (
-- * Grammar rules
-- $rules
-- * Grammar rules
-- $rules

-- * Lexical conventions
-- * Lexical conventions

-- ** Blanks
-- $lexing_blanks
-- ** Blanks
-- $lexing_blanks

-- ** Comments
-- $lexing_comments
-- ** Comments
-- $lexing_comments

-- ** Identifiers
-- $lexing_idents
-- ** Identifiers
-- $lexing_idents

-- ** Integer literals
-- $lexing_int_lits
-- ** Integer literals
-- $lexing_int_lits

-- ** Character literals
-- $lexing_char_lits
-- ** Character literals
-- $lexing_char_lits

-- ** String literals
-- $lexing_string_lits
-- ** String literals
-- $lexing_string_lits

-- ** Operators
-- $lexing_operators
-- ** Operators
-- $lexing_operators

-- ** Keywords
-- $lexing_keywords
-- ** Keywords
-- $lexing_keywords

-- * Names
-- $names
-- * Names
-- $names

-- * Type expressions
-- $types
-- * Type expressions
-- $types

-- * Constants
-- $constants
-- * Constants
-- $constants

-- * Patterns
-- $patterns
-- * Patterns
-- $patterns

-- * Expressions
-- $expressions
-- * Expressions
-- $expressions

-- * Type definitions
-- $typedefs
-- * Type definitions
-- $typedefs

-- * Declarations and Modules
-- $decls
-- * Declarations and Modules
-- $decls

-- * Missing things
-- $missing
-- * Missing things
-- $missing
) where

{- $rules
Expand Down
2 changes: 1 addition & 1 deletion lamagraph-compiler/src/Lib.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Lib (
someFunc,
someFunc,
) where

someFunc :: IO ()
Expand Down
46 changes: 23 additions & 23 deletions lamagraph-core/src/Example/Project.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@ In this case, we are using the @Dom50@ domain, which we created with @createDoma
and we are using 8-bit unsigned numbers.
-}
topEntity ::
Clock Dom50 ->
Reset Dom50 ->
Enable Dom50 ->
Signal Dom50 (Unsigned 8) ->
Signal Dom50 (Unsigned 8)
Clock Dom50 ->
Reset Dom50 ->
Enable Dom50 ->
Signal Dom50 (Unsigned 8) ->
Signal Dom50 (Unsigned 8)
topEntity = exposeClockResetEnable accum
-- To specify the names of the ports of our top entity, we create a @Synthesize@ annotation.
{-# ANN
topEntity
( Synthesize
{ t_name = "accum"
, t_inputs =
[ PortName "CLK"
, PortName "RST"
, PortName "EN"
, PortName "DIN"
]
, t_output = PortName "DOUT"
}
)
#-}
topEntity
( Synthesize
{ t_name = "accum"
, t_inputs =
[ PortName "CLK"
, PortName "RST"
, PortName "EN"
, PortName "DIN"
]
, t_output = PortName "DOUT"
}
)
#-}
-- Make sure GHC does not apply any optimizations to the boundaries of the design.
-- For GHC versions 9.2 or older, use: {-# NOINLINE topEntity #-}
{-# OPAQUE topEntity #-}
Expand All @@ -50,9 +50,9 @@ topEntity = exposeClockResetEnable accum
It has hidden clock, reset, and enable signals.
-}
accum ::
(HiddenClockResetEnable dom, KnownNat n) =>
Signal dom (Unsigned n) ->
Signal dom (Unsigned n)
(HiddenClockResetEnable dom, KnownNat n) =>
Signal dom (Unsigned n) ->
Signal dom (Unsigned n)
accum = mealy accumT 0
where
accumT s i = (s + i, s)
where
accumT s i = (s + i, s)
50 changes: 25 additions & 25 deletions lamagraph-core/tests/Tests/Example/Project.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ import Example.Project (accum)
-- Define a Hedgehog property to test the @accum@ function
prop_accum :: H.Property
prop_accum = H.property $ do
-- Simulate for a random duration between 1 and 100 cycles
simDuration <- H.forAll (Gen.integral (Range.linear 1 100))

-- Generate a list of random unsigned numbers.
inp <-
H.forAll
( Gen.list
(Range.singleton simDuration)
(genUnsigned Range.linearBounded)
)
let
-- Simulate the @accum@ function for the pre-existing @System@ domain
-- and 8 bit unsigned numbers.
--
-- The (hidden) reset input of @accum@ will be asserted in the first cycle;
-- during this cycle it will emit its initial value and the input is
-- ignored. So we need to present a dummy input value.
simOut = C.sampleN (simDuration + 1) (accum @C.System @8 (C.fromList (0 : inp)))
-- Calculate the expected output. The first cycle is the initial value, and
-- the result of the final input value does not appear because the
-- accumulator has 1 cycle latency.
expected = 0 : init (scanl (+) 0 inp)

-- Check that the simulated output matches the expected output
simOut H.=== expected
-- Simulate for a random duration between 1 and 100 cycles
simDuration <- H.forAll (Gen.integral (Range.linear 1 100))

-- Generate a list of random unsigned numbers.
inp <-
H.forAll
( Gen.list
(Range.singleton simDuration)
(genUnsigned Range.linearBounded)
)
let
-- Simulate the @accum@ function for the pre-existing @System@ domain
-- and 8 bit unsigned numbers.
--
-- The (hidden) reset input of @accum@ will be asserted in the first cycle;
-- during this cycle it will emit its initial value and the input is
-- ignored. So we need to present a dummy input value.
simOut = C.sampleN (simDuration + 1) (accum @C.System @8 (C.fromList (0 : inp)))
-- Calculate the expected output. The first cycle is the initial value, and
-- the result of the final input value does not appear because the
-- accumulator has 1 cycle latency.
expected = 0 : init (scanl (+) 0 inp)

-- Check that the simulated output matches the expected output
simOut H.=== expected

accumTests :: TestTree
accumTests = $(testGroupGenerator)
Expand Down
10 changes: 5 additions & 5 deletions lamagraph-core/tests/unittests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import qualified Tests.Example.Project

main :: IO ()
main =
defaultMain $
testGroup
"."
[ Tests.Example.Project.accumTests
]
defaultMain $
testGroup
"."
[ Tests.Example.Project.accumTests
]

0 comments on commit 2f85136

Please sign in to comment.