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.
Matthijs Kooijman [Wed, 5 Aug 2009 10:36:38 +0000 (12:36 +0200)]
Remove compatability aliases for the old sessions.
Matthijs Kooijman [Wed, 5 Aug 2009 10:12:28 +0000 (12:12 +0200)]
Make vhdl generation and normalization lazy.
Previously, first all function would be (recursively) normalized, and then
VHDL would be generated. Now, functions are normalized when needed, and
recursion is done while generating VHDL (so we know exactly which
components we are instantiating).
This disables the testbench and TFVec constructor for now, I'll fix that
in the next commits.
This also moves some code around, to prevent loops between Generate and
VHDL (again...).
The VHDLSession and NormalizeSession have been removed, and replaced with
the (previously unused) TranslatorSession. There are a few backward
compatibility aliases in place, so the next commit will probably remove
these and do a bunch of trivial replaces all over the code.
Matthijs Kooijman [Mon, 3 Aug 2009 10:26:43 +0000 (12:26 +0200)]
Put a comment on UniqSupply generation back.
Matthijs Kooijman [Mon, 3 Aug 2009 10:20:29 +0000 (12:20 +0200)]
Merge branch 'master' of git://github.com/christiaanb/clash into cλash
* 'master' of git://github.com/christiaanb/clash:
TFVec builtin should now completely work
Clean up imports in Generate.hs
Use createDirectoryIfMissing to create the vhdl directory, as it can create the parent directories too
Reflect API changes of clash in clash-nolibdir
Bring back listBind(ings) in Utils.hs by reorganising Translator.hs and GhcTools.hs
Fix a few comments so Haddock will complete
Further clean up Translator.hs (almost done now)
Cleanup Translator.hs
Fail again when we find a global function
Partially fixed TFVec builtin function. Still needs to be verified
Christiaan Baaij [Mon, 3 Aug 2009 07:51:55 +0000 (09:51 +0200)]
TFVec builtin should now completely work
Christiaan Baaij [Sun, 2 Aug 2009 19:17:21 +0000 (21:17 +0200)]
Clean up imports in Generate.hs
Christiaan Baaij [Sun, 2 Aug 2009 19:07:46 +0000 (21:07 +0200)]
Use createDirectoryIfMissing to create the vhdl directory, as it can create the parent directories too
Christiaan Baaij [Sun, 2 Aug 2009 18:51:29 +0000 (20:51 +0200)]
Reflect API changes of clash in clash-nolibdir
Christiaan Baaij [Sat, 1 Aug 2009 18:41:19 +0000 (20:41 +0200)]
Bring back listBind(ings) in Utils.hs by reorganising Translator.hs and GhcTools.hs
Christiaan Baaij [Fri, 31 Jul 2009 19:01:02 +0000 (21:01 +0200)]
Fix a few comments so Haddock will complete
Christiaan Baaij [Fri, 31 Jul 2009 18:46:17 +0000 (20:46 +0200)]
Further clean up Translator.hs (almost done now)
Christiaan Baaij [Fri, 31 Jul 2009 15:17:04 +0000 (17:17 +0200)]
Cleanup Translator.hs
Can be reduced in size even more by parameterizing the findcore functions
to work for both strings and annotations
Christiaan Baaij [Fri, 31 Jul 2009 15:15:54 +0000 (17:15 +0200)]
Fail again when we find a global function
Was only disabled to fix the builtin TFVec function
Christiaan Baaij [Fri, 31 Jul 2009 13:21:02 +0000 (15:21 +0200)]
Partially fixed TFVec builtin function. Still needs to be verified
Matthijs Kooijman [Fri, 31 Jul 2009 12:34:34 +0000 (14:34 +0200)]
Merge casevalsimpl and casewild into casesimpl.
Both transformations had a very similar structure, which are now merged.
Matthijs Kooijman [Fri, 31 Jul 2009 11:04:05 +0000 (13:04 +0200)]
Fix a small bug in the case wildening.
This bug could be triggered when the scrutinee was a datatype containing a
non-representable value. This is probably not translatable, but handle it
properly anyway.
Matthijs Kooijman [Fri, 31 Jul 2009 10:37:08 +0000 (12:37 +0200)]
Prevent conflicts with inlinenonrep in normalization.
This is a followup on
ebdc2024d7cf71: Let inlinefun inline everything non-representable.
which make inlinefun more general. A few other normalizations tried to
prevent loops with inline fun, but now work correctly for the (new)
inlinenonrep.
Matthijs Kooijman [Fri, 31 Jul 2009 09:26:59 +0000 (11:26 +0200)]
Merge branch 'master' of git://github.com/christiaanb/clash into cλash
* 'master' of git://github.com/christiaanb/clash:
Quick hack implementation of FSVec literals, needs to be fixed
We need the latest vhdl package
We now make a show function for all default datatypes.
Add automated testbench generation according to supplied test input
Conflicts:
cλash/CLasH/Translator.hs