Christiaan Baaij [Mon, 17 Aug 2009 10:18:11 +0000 (12:18 +0200)]
Merge branch 'cλash' of git.stderr.nl/matthijs/projects/master-project
* 'cλash' of http://git.stderr.nl/matthijs/projects/master-project:
Make letflat work for nonrec lets in rec lets as well.
Revert "Limit flattenLets to non-recursive lets only."
Disable letmerge.
Make letremoveunused work for recursive lets again.
Make letflat work for recursive lets again.
Turn of Normalize debugging again, accidentally committed.
Matthijs Kooijman [Mon, 17 Aug 2009 09:54:01 +0000 (11:54 +0200)]
Make letflat work for nonrec lets in rec lets as well.
Matthijs Kooijman [Mon, 17 Aug 2009 09:42:37 +0000 (11:42 +0200)]
Revert "Limit flattenLets to non-recursive lets only."
This reverts commit
de2b45772572a90429ffe41a86a7ba08e7de6d4b.
Matthijs Kooijman [Mon, 17 Aug 2009 09:36:06 +0000 (11:36 +0200)]
Disable letmerge.
When faced with nested recursive and non-recursive lets, letmerge becomes
complicated very quickly, so we might need to rewrite it if it's really
needed. For now, just disable it to prevent it from breaking things.
Matthijs Kooijman [Mon, 17 Aug 2009 09:28:20 +0000 (11:28 +0200)]
Make letremoveunused work for recursive lets again.
The non-recursive version is also changed to work for each nested let in
turn, instead of running on a bunch of them at the same time.
Matthijs Kooijman [Mon, 17 Aug 2009 09:22:43 +0000 (11:22 +0200)]
Make letflat work for recursive lets again.
Matthijs Kooijman [Mon, 17 Aug 2009 07:39:26 +0000 (09:39 +0200)]
Turn of Normalize debugging again, accidentally committed.
This reverst part of commit
93e2a90772f1f599c1abe5ec5403e80dd1719b5c,
"Order the extracted bindings from a case expression properly."
Christiaan Baaij [Fri, 14 Aug 2009 15:50:26 +0000 (17:50 +0200)]
Merge branch 'cλash' of git.stderr.nl/matthijs/projects/master-project
* 'cλash' of http://git.stderr.nl/matthijs/projects/master-project:
Order the extracted bindings from a case expression properly.
Matthijs Kooijman [Fri, 14 Aug 2009 15:37:03 +0000 (17:37 +0200)]
Order the extracted bindings from a case expression properly.
Since the case value can use any of the binders bound by the pattern, the
bindings resulting from the pattern should come before the binding from
the value.
Christiaan Baaij [Fri, 14 Aug 2009 15:35:46 +0000 (17:35 +0200)]
Fix replace function to make Quartus II happy
Christiaan Baaij [Fri, 14 Aug 2009 14:35:05 +0000 (16:35 +0200)]
Merge branch 'cλash' of git.stderr.nl/matthijs/projects/master-project
* 'cλash' of http://git.stderr.nl/matthijs/projects/master-project:
Add lambdasimpl normalization pass.
Make letremoveunused work for non-recursive lets.
Let casesimpl generate non-recursive lets.
Add mkNonRecLets and use it.
Make letmerge work with non-recursive lets.
Limit flattenLets to non-recursive lets only.
Move flattenLets from Normalize to CoreTools.
Make inlinebind work for non-recursive lets.
Add empty let removal normalization pass.
Rename letremove to letremovesimple.
Don't try to simplify nested lets.
Make letflat work with non-recursive lets.
Make letsimpl work on and generate a non-recursive let.
No longer add a top level let before normalization.
Make some normalizations generate nonrecursive lets.
Turn let recursification into its opposite.
Christiaan Baaij [Fri, 14 Aug 2009 14:34:16 +0000 (16:34 +0200)]
Ignore casts that just repack state. Don't make VHDL for them, their type is empty
Christiaan Baaij [Fri, 14 Aug 2009 14:32:54 +0000 (16:32 +0200)]
Add builtin blockRAM primitive
Matthijs Kooijman [Fri, 14 Aug 2009 14:17:32 +0000 (16:17 +0200)]
Add lambdasimpl normalization pass.
This pass puts the value of a lambda in a let binding, to make a lambda
always evaluate to either a let or a simple variable reference. This was
previously not needed, since there used to be a let always (even an empty
one), but this is no longer the case.
Matthijs Kooijman [Fri, 14 Aug 2009 14:08:08 +0000 (16:08 +0200)]
Make letremoveunused work for non-recursive lets.
Matthijs Kooijman [Fri, 14 Aug 2009 13:51:29 +0000 (15:51 +0200)]
Let casesimpl generate non-recursive lets.
Matthijs Kooijman [Fri, 14 Aug 2009 13:47:28 +0000 (15:47 +0200)]
Add mkNonRecLets and use it.
This function creates a bunch nested non-recursive lets. It is similar to
MkCore.mkCoreLets, but works only for non-recursive lets, which makes it a
bit more elegant in usage.
Matthijs Kooijman [Fri, 14 Aug 2009 13:43:09 +0000 (15:43 +0200)]
Make letmerge work with non-recursive lets.
Matthijs Kooijman [Fri, 14 Aug 2009 13:38:03 +0000 (15:38 +0200)]
Limit flattenLets to non-recursive lets only.
flattenLets is currently used for splitNormalized only, which should be
non-recursive lets only. To use it in other places to filter lets, we
should only flatten non-recursive lets, so we can create new non-recursive
lets afterwards.
Matthijs Kooijman [Fri, 14 Aug 2009 13:29:12 +0000 (15:29 +0200)]
Move flattenLets from Normalize to CoreTools.
Matthijs Kooijman [Fri, 14 Aug 2009 13:24:44 +0000 (15:24 +0200)]
Make inlinebind work for non-recursive lets.
This removes the code for recursive lets, since it is no longer needed.
Matthijs Kooijman [Fri, 14 Aug 2009 13:19:28 +0000 (15:19 +0200)]
Add empty let removal normalization pass.
Matthijs Kooijman [Fri, 14 Aug 2009 13:17:07 +0000 (15:17 +0200)]
Rename letremove to letremovesimple.
Matthijs Kooijman [Fri, 14 Aug 2009 12:38:49 +0000 (14:38 +0200)]
Don't try to simplify nested lets.
This would cause loops with letflat (and possibly with itself as well).
Matthijs Kooijman [Fri, 14 Aug 2009 12:38:11 +0000 (14:38 +0200)]
Make letflat work with non-recursive lets.
This replaces the implementation that worked with recursive lets, since
that is no longer needed.
Matthijs Kooijman [Fri, 14 Aug 2009 12:17:51 +0000 (14:17 +0200)]
Make letsimpl work on and generate a non-recursive let.
Previously, letsimpl would work on a recursive let only, and add a new
binding to that recursive let. Now, it works on any let and produces a new
non-recursive let.
Matthijs Kooijman [Fri, 14 Aug 2009 12:12:50 +0000 (14:12 +0200)]
No longer add a top level let before normalization.
This was previously required to ensure there was always a let on top
level. However, since we are using nonrecursive lets now and use a
splitNormalized instead of hard matching a Let constructor, there is no
need for an (empty) let at the top anymore.
Matthijs Kooijman [Fri, 14 Aug 2009 12:10:40 +0000 (14:10 +0200)]
Make some normalizations generate nonrecursive lets.
Matthijs Kooijman [Fri, 14 Aug 2009 12:02:50 +0000 (14:02 +0200)]
Merge branch 'master' of git://github.com/christiaanb/clash into cλash
* 'master' of git://github.com/christiaanb/clash:
Hopefully generate completely unique varNames now (also for comp_ins labels)
Generate more unique variable names, generate truely unique entity names
Add boolean or and and, tuple fst and snd function.
Added equals builtin. And fixed show function generation for integers
Class Num is re-exported by CLasH.HardwareTypes, so no need to use the one in Prelude
Matthijs Kooijman [Fri, 14 Aug 2009 12:00:45 +0000 (14:00 +0200)]
Turn let recursification into its opposite.
Instead of making all lets recursive, it now makes all lets nonrecursive,
wherever possible. This breaks normalization, since most other passes work
with recursive lets exclusively.
Christiaan Baaij [Fri, 14 Aug 2009 11:30:08 +0000 (13:30 +0200)]
Merge branch 'cλash' of git.stderr.nl/matthijs/projects/master-project
* 'cλash' of http://git.stderr.nl/matthijs/projects/master-project:
Be more strict in state recognition.
Matthijs Kooijman [Fri, 14 Aug 2009 11:27:31 +0000 (13:27 +0200)]
Be more strict in state recognition.
Previously, any cast that involves a state variable, would be classified
as state (un)packing. Now, only do this if the cast actually changes a
variable from (packed) state to non state (e.g., unpacked state).
Christiaan Baaij [Thu, 13 Aug 2009 16:03:30 +0000 (18:03 +0200)]
Hopefully generate completely unique varNames now (also for comp_ins labels)
Christiaan Baaij [Thu, 13 Aug 2009 15:20:33 +0000 (17:20 +0200)]
Merge branch 'cλash' of git.stderr.nl/matthijs/projects/master-project
* 'cλash' of http://git.stderr.nl/matthijs/projects/master-project:
Don't generate a state proc for an empty state.
Make splitNormalized work for non-recursive lets.
Add and use splitNormalized helper function.
Christiaan Baaij [Thu, 13 Aug 2009 15:19:48 +0000 (17:19 +0200)]
Generate more unique variable names, generate truely unique entity names
Matthijs Kooijman [Thu, 13 Aug 2009 14:40:43 +0000 (16:40 +0200)]
Don't generate a state proc for an empty state.
This can happen when a function has no state itself, but only substates.
Matthijs Kooijman [Thu, 13 Aug 2009 14:24:44 +0000 (16:24 +0200)]
Make splitNormalized work for non-recursive lets.
For now, normalized expressions can only contain a (single) recursive let,
but this should become nested non-recursive lets only in the future.
Matthijs Kooijman [Thu, 13 Aug 2009 14:12:31 +0000 (16:12 +0200)]
Add and use splitNormalized helper function.
This function puts the matching of a normalized expression in a single
place instead of spread out over multiple places. This prevents some code
duplication and allows for better error reporting.
Christiaan Baaij [Thu, 13 Aug 2009 12:15:42 +0000 (14:15 +0200)]
Add boolean or and and, tuple fst and snd function.
And add reducer, which uses the above functions
Christiaan Baaij [Thu, 13 Aug 2009 09:25:04 +0000 (11:25 +0200)]
Added equals builtin. And fixed show function generation for integers
Christiaan Baaij [Thu, 13 Aug 2009 07:55:33 +0000 (09:55 +0200)]
Class Num is re-exported by CLasH.HardwareTypes, so no need to use the one in Prelude
Matthijs Kooijman [Wed, 12 Aug 2009 15:28:17 +0000 (17:28 +0200)]
Revert "Put mkAssocElems in the TranslatorSession."
This reverts commit
374a42ba3cf333ae53fa1d992620d25286641ae2.
Conflicts:
cλash/CLasH/VHDL/Testbench.hs
cλash/CLasH/VHDL/VHDLTools.hs
Matthijs Kooijman [Wed, 12 Aug 2009 15:17:51 +0000 (17:17 +0200)]
Revert "Don't generate VHDL for state packing."
This is now handled by the previous commit, which ensures mkConcSm (and
thus genApplication) don't even see state (un)packing bindings.
This reverts commit
fda239f0ae8fc6a2250e6719c3f564c9b2390c4a.
Matthijs Kooijman [Wed, 12 Aug 2009 15:16:07 +0000 (17:16 +0200)]
Throw away old and unused functions for state.
Matthijs Kooijman [Wed, 12 Aug 2009 15:12:53 +0000 (17:12 +0200)]
Generate a state proc for a stateful function.
This means that stateful functions can now be succesfully compiled to some
extent (the Alu example only works without the simplifier).
Matthijs Kooijman [Wed, 12 Aug 2009 15:11:43 +0000 (17:11 +0200)]
Don't inline register_bank.
Matthijs Kooijman [Wed, 12 Aug 2009 15:09:41 +0000 (17:09 +0200)]
Only do State packing once in register_bank.
Matthijs Kooijman [Wed, 12 Aug 2009 15:06:52 +0000 (17:06 +0200)]
Improve Normalize debug output.
Matthijs Kooijman [Wed, 12 Aug 2009 14:14:50 +0000 (16:14 +0200)]
Add isStateCon helper.
Matthijs Kooijman [Wed, 12 Aug 2009 14:13:21 +0000 (16:13 +0200)]
Use mkBinderFor instead of mkInternalVar.
Matthijs Kooijman [Wed, 12 Aug 2009 14:09:41 +0000 (16:09 +0200)]
Add identical let binding merge normalization pass.
Matthijs Kooijman [Wed, 12 Aug 2009 13:08:02 +0000 (15:08 +0200)]
Add cast simplification normalization pass.
This ensures that the casts used for packing and unpacking State variables
only operate on simple variables.
Matthijs Kooijman [Wed, 12 Aug 2009 10:19:27 +0000 (12:19 +0200)]
Make output ports optional.
This makes the output port in an Entity of the Maybe Port type, so we can
leave out the output port (for example when its type is empty). This makes
the code a bit more robus in the face of empty types.
Matthijs Kooijman [Wed, 12 Aug 2009 09:05:48 +0000 (11:05 +0200)]
Fix more comments.
Matthijs Kooijman [Wed, 12 Aug 2009 09:04:38 +0000 (11:04 +0200)]
Fix comment.
Christiaan Baaij [Sat, 8 Aug 2009 11:21:17 +0000 (13:21 +0200)]
Fix haddock comments
Christiaan Baaij [Fri, 7 Aug 2009 13:58:14 +0000 (15:58 +0200)]
Add support for translating designs defined over multiple modules
Have to test the stability, it works for HighOrdAlu
Christiaan Baaij [Fri, 7 Aug 2009 12:29:22 +0000 (14:29 +0200)]
Have reduceCoreListToHsList work with simplified modules
Christiaan Baaij [Fri, 7 Aug 2009 08:11:35 +0000 (10:11 +0200)]
We now use compileToCoreSimplified, I'm sure there will be dragons
Christiaan Baaij [Fri, 7 Aug 2009 07:22:52 +0000 (09:22 +0200)]
State newtype has been moved to CLasH.HardwareTypes
Christiaan Baaij [Fri, 7 Aug 2009 07:20:15 +0000 (09:20 +0200)]
Alu.hs now uses the new CLasH.HardwareTypes
Matthijs Kooijman [Thu, 6 Aug 2009 17:22:09 +0000 (19:22 +0200)]
Merge branch 'master' of git://github.com/christiaanb/clash into cλash
* 'master' of git://github.com/christiaanb/clash:
Add the type-alias Vector for TFVec to HardwareTypes, and don't export TFVec.TFVec anymore
Add the module hardware types, that exports all builtin types.
Add new modules to cabal file
Matthijs Kooijman [Thu, 6 Aug 2009 17:21:17 +0000 (19:21 +0200)]
Rewrite Alu using the State newtype.
This is the way stateful functions will be working. Alu.hs now compiles,
but it does not result in valid (stateful) VHDL yet.
Matthijs Kooijman [Thu, 6 Aug 2009 17:19:52 +0000 (19:19 +0200)]
Filter out empty-typed binders in selector cases.
This makes sure that the non-empty binders are skipped when calculating
the field number, which prevents overflow when indexing the field names.
Matthijs Kooijman [Thu, 6 Aug 2009 17:18:48 +0000 (19:18 +0200)]
Add hasNonEmptyType helper function.
Matthijs Kooijman [Thu, 6 Aug 2009 17:09:11 +0000 (19:09 +0200)]
Let argsToVHDLExpr ignore empty types.
This makes sure that state arguments are not passed to called functions.
Matthijs Kooijman [Thu, 6 Aug 2009 17:08:22 +0000 (19:08 +0200)]
Generalize vhdl_ty to work an all TypedThings.
Matthijs Kooijman [Thu, 6 Aug 2009 17:06:43 +0000 (19:06 +0200)]
Add isJustM helper function.
Matthijs Kooijman [Thu, 6 Aug 2009 16:47:09 +0000 (18:47 +0200)]
Rename eitherCoreOrExprArgs to argsToVHDLExprs.
Also add a helper function to make it more readable.
Matthijs Kooijman [Thu, 6 Aug 2009 15:54:03 +0000 (17:54 +0200)]
Remove the getType field name from OrdType.
This conflicted with the getType method from TypedThing. The field label
was never used.
Matthijs Kooijman [Thu, 6 Aug 2009 15:45:56 +0000 (17:45 +0200)]
Put mkAssocElems in the TranslatorSession.
Matthijs Kooijman [Thu, 6 Aug 2009 15:43:40 +0000 (17:43 +0200)]
Remove unused mkAssocElemIndexed.
Matthijs Kooijman [Thu, 6 Aug 2009 15:40:25 +0000 (17:40 +0200)]
Don't generate VHDL for substate extractor cases.
Matthijs Kooijman [Thu, 6 Aug 2009 15:32:25 +0000 (17:32 +0200)]
Fix letremoveunused, it removed all used bindings.
Matthijs Kooijman [Thu, 6 Aug 2009 15:21:49 +0000 (17:21 +0200)]
Fix the trace output of normalized functions.
Before, it would output the un-normalized version.
Matthijs Kooijman [Thu, 6 Aug 2009 15:13:54 +0000 (17:13 +0200)]
Filtering out state arguments is no longer needed.
Since State types generate empty VHDL types now, they will be filtered out
automatically.
Matthijs Kooijman [Thu, 6 Aug 2009 15:13:14 +0000 (17:13 +0200)]
Generate the empty type for State types.
Matthijs Kooijman [Thu, 6 Aug 2009 15:08:25 +0000 (17:08 +0200)]
Allow explicit empty VHDL types using Maybe.
The VHDL type generating functions can now return "Nothing" to mean that an
empty type would be generated. There are still some spots (builtin
functions mostly) that should handle this more gracefully, but it works
for now. Only single-constructor zero-argument algebraic types generate
the empty type currently, e.g. ().
Matthijs Kooijman [Thu, 6 Aug 2009 14:21:32 +0000 (16:21 +0200)]
Don't generate input ports for State arguments.
Matthijs Kooijman [Thu, 6 Aug 2009 14:20:51 +0000 (16:20 +0200)]
Don't generate VHDL for state packing.
Matthijs Kooijman [Thu, 6 Aug 2009 14:15:20 +0000 (16:15 +0200)]
Add TypedThing class, and generalize hasStateType with it.
Matthijs Kooijman [Thu, 6 Aug 2009 13:56:44 +0000 (15:56 +0200)]
Add letremoveunused transformation.
This transformation removes all unused let bindings.
Matthijs Kooijman [Thu, 6 Aug 2009 13:56:23 +0000 (15:56 +0200)]
Add changeif normalization helper function.
Matthijs Kooijman [Thu, 6 Aug 2009 13:56:04 +0000 (15:56 +0200)]
Add expr_uses_binders predicate.
Matthijs Kooijman [Thu, 6 Aug 2009 13:55:43 +0000 (15:55 +0200)]
Add {is,has}StateType predicates.
Matthijs Kooijman [Thu, 6 Aug 2009 13:47:19 +0000 (15:47 +0200)]
Let mkTupleShow support empty tuples.
Christiaan Baaij [Thu, 6 Aug 2009 13:02:40 +0000 (15:02 +0200)]
Add the type-alias Vector for TFVec to HardwareTypes, and don't export TFVec.TFVec anymore
Christiaan Baaij [Thu, 6 Aug 2009 12:54:43 +0000 (14:54 +0200)]
Add the module hardware types, that exports all builtin types.
This way, users only have to import CLasH.HardwareTypes to get
access to all translatable hardware types.
Christiaan Baaij [Thu, 6 Aug 2009 11:29:11 +0000 (13:29 +0200)]
Add new modules to cabal file
Matthijs Kooijman [Thu, 6 Aug 2009 10:06:32 +0000 (12:06 +0200)]
Remove the unused "stateful" argument fomr makeVHDL*.
State will be explicitely specified in the Haskell sources, so no reason
anymore to pass the statefulness of a function around.
Matthijs Kooijman [Wed, 5 Aug 2009 15:10:41 +0000 (17:10 +0200)]
Merge branch 'master' of git://github.com/christiaanb/clash into cλash
* 'master' of git://github.com/christiaanb/clash:
Fix builtin functions (!),take and RangedWord
Conflicts:
cλash/CLasH/VHDL/Generate.hs
Matthijs Kooijman [Wed, 5 Aug 2009 15:04:48 +0000 (17:04 +0200)]
Restructure the "finder" functions.
Previously, there were three different functions for the top entity,
initial state and test input. Now, there is just a single one, which
guarantees that these things are properly linked together. This should no
also support generating multiple entities at the same time (though there
is no top level interface for this yet).
This change also makes the testbench generation optional. A bunch of
functions were moved from Utils to GhcTools, to prevent a dependency loop.
Matthijs Kooijman [Wed, 5 Aug 2009 15:04:06 +0000 (17:04 +0200)]
Add catMaybesM and concatM helper functions.
Matthijs Kooijman [Wed, 5 Aug 2009 15:00:47 +0000 (17:00 +0200)]
Use the right id for the testbench architecture.
Christiaan Baaij [Wed, 5 Aug 2009 14:17:17 +0000 (16:17 +0200)]
Fix builtin functions (!),take and RangedWord
Matthijs Kooijman [Wed, 5 Aug 2009 13:21:45 +0000 (15:21 +0200)]
Fix testbench again.
The testbench code has also been moved to a separate module.
Matthijs Kooijman [Wed, 5 Aug 2009 13:20:14 +0000 (15:20 +0200)]
Split of part of getNormalized into normalizeExpr.
Matthijs Kooijman [Wed, 5 Aug 2009 12:51:53 +0000 (14:51 +0200)]
Add unzipM helper function.
Matthijs Kooijman [Wed, 5 Aug 2009 12:05:45 +0000 (14:05 +0200)]
Slightly simplify getEntity.
Matthijs Kooijman [Wed, 5 Aug 2009 11:59:39 +0000 (13:59 +0200)]
Move around some helper functions.
This moves some stuff from NormalizeTools and NormalizeTypes into the
(new) BinderTools and TranslatorTypes. This also puts most of these
function in the TranslatorSession instead of the TransformMonad.