Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions doc/user_guide/bluetcl.tex
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,13 @@ \subsubsubsection{Bluetcl::module}
{\bf module} {\bf methods} {\em modname}& Returns a list of the flattened methods
in the module. \\
\hline
{\bf module} {\bf ports} {\em modname}& Returns a list of the ports in the module. \\
{\bf module} {\bf ports} {\em modname}& Returns a list of the ports in the
module, organized by interface element. For each method, the entry includes
its argument ports (\te{args}) and a \te{results} field listing the method's
output ports, each given as a \te{port} name and bit \te{size}. The
\te{results} list may be empty (for an action method with no return value) or
contain more than one port (when a method's result is split across several
output ports). \\
\hline
{\bf module} {\bf porttypes} {\em modname}& Returns a list of the types of the ports in
the module. \\
Expand Down Expand Up @@ -430,7 +436,8 @@ \subsubsubsection{Bluetcl::submodule}
\hline
{\bf submodule} {\bf full} {\em modname}& Returns information about each
submodule in the specified module and the rules which use the methods
of the submodule. \\
of the submodule. The per-method port information uses the same format as
{\bf module ports}, including the \te{results} field of output ports. \\
\hline
\hline
\end{tabular}
Expand Down
246 changes: 153 additions & 93 deletions src/Libraries/Base1/Prelude.bs

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions src/Libraries/Base1/SplitPorts.bs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ data DeepSplit a = DeepSplit a
-- Tag to indicate that the DeepSplitPorts recursion should terminate
data NoSplit a = NoSplit a

instance (ShallowSplitPorts a p) => SplitPorts (ShallowSplit a) p where
instance SplitPorts (ShallowSplit a) (ShallowPortsOf a) where
splitPorts (ShallowSplit x) = shallowSplitPorts x
unsplitPorts = ShallowSplit ∘ shallowUnsplitPorts
portNames _ = shallowSplitPortNames (_ :: a)

instance (DeepSplitPorts a p) => SplitPorts (DeepSplit a) p where
instance SplitPorts (DeepSplit a) (DeepPortsOf a) where
splitPorts (DeepSplit x) = deepSplitPorts x
unsplitPorts = DeepSplit ∘ deepUnsplitPorts
portNames _ = deepSplitPortNames (_ :: a)
Expand All @@ -30,6 +30,7 @@ instance DeepSplitPorts (NoSplit a) (Port a) where

-- Helper class using generics, to split a struct or vector into a tuple of ports.
class ShallowSplitPorts a p | a -> p where
type ShallowPortsOf a = p
shallowSplitPorts :: a -> p
shallowUnsplitPorts :: p -> a
shallowSplitPortNames :: a -> String -> List String
Expand All @@ -44,7 +45,8 @@ class ShallowSplitPorts' r p | r -> p where
shallowUnsplitPorts' :: p -> r
shallowSplitPortNames' :: r -> String -> List String

instance (ShallowSplitPorts' a p, ShallowSplitPorts' b q, AppendTuple p q r) => ShallowSplitPorts' (a, b) r where
instance (ShallowSplitPorts' a p, ShallowSplitPorts' b q) =>
ShallowSplitPorts' (a, b) (TAppendTuple p q) where
shallowSplitPorts' (a, b) = shallowSplitPorts' a `appendTuple` shallowSplitPorts' b
shallowUnsplitPorts' x = case splitTuple x of
(a, b) -> (shallowUnsplitPorts' a, shallowUnsplitPorts' b)
Expand Down Expand Up @@ -77,14 +79,15 @@ instance (ShallowSplitPorts' r p) => ShallowSplitPorts' (Meta m r) p where
shallowUnsplitPorts' = Meta ∘ shallowUnsplitPorts'
shallowSplitPortNames' _ = shallowSplitPortNames' (_ :: r)

instance (SplitPorts a p) => ShallowSplitPorts' (Conc a) p where
instance ShallowSplitPorts' (Conc a) (PortsOf a) where
shallowSplitPorts' (Conc x) = splitPorts x
shallowUnsplitPorts' = Conc ∘ unsplitPorts
shallowSplitPortNames' _ = portNames (_ :: a)


-- Helper class using generics, to recursively split structs and vectors into a tuple of ports.
class DeepSplitPorts a p | a -> p where
type DeepPortsOf a = p
deepSplitPorts :: a -> p
deepUnsplitPorts :: p -> a
deepSplitPortNames :: a -> String -> List String
Expand Down Expand Up @@ -142,7 +145,7 @@ class DeepSplitPorts' r a p | r a -> p where
deepSplitPortNames' :: r -> a -> String -> List String

-- Terminate recursion for n /= 1 constructors
instance (SplitPorts a p) => DeepSplitPorts' r a p where
instance DeepSplitPorts' r a (PortsOf a) where
deepSplitPorts' _ = splitPorts
deepUnsplitPorts' _ = unsplitPorts
deepSplitPortNames' _ = portNames
Expand All @@ -158,7 +161,8 @@ class DeepSplitPorts'' r p | r -> p where
deepUnsplitPorts'' :: p -> r
deepSplitPortNames'' :: r -> String -> List String

instance (DeepSplitPorts'' a p, DeepSplitPorts'' b q, AppendTuple p q r) => DeepSplitPorts'' (a, b) r where
instance (DeepSplitPorts'' a p, DeepSplitPorts'' b q) =>
DeepSplitPorts'' (a, b) (TAppendTuple p q) where
deepSplitPorts'' (a, b) = deepSplitPorts'' a `appendTuple` deepSplitPorts'' b
deepUnsplitPorts'' x = case splitTuple x of
(a, b) -> (deepUnsplitPorts'' a, deepUnsplitPorts'' b)
Expand Down
8 changes: 4 additions & 4 deletions src/Libraries/Base1/Vector.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1293,14 +1293,14 @@ instance ConcatTuple 1 a a where
unconcatTuple x = cons x nil

-- Linear recursive implementation: O(n^2)
-- instance (Add n1 1 n, ConcatTuple n1 a b, AppendTuple a b c) => ConcatTuple n a c where
-- instance (Add n1 1 n, ConcatTuple n1 a b) => ConcatTuple n a (TAppendTuple a b) where
-- concatTuple v = appendTuple (head v) $ concatTuple (tail v)
-- unconcatTuple x = case splitTuple x of
-- (y, z) -> cons y $ unconcatTuple z

-- O(n lg n) optimization: split into chunks that are powers of 2
instance (Add lgn 1 (TLog (TAdd n 1)), Add (TExp lgn) n1 n, ConcatTuple n1 a b, ConcatTuple' lgn a c, AppendTuple b c d) =>
ConcatTuple n a d where
instance (Add lgn 1 (TLog (TAdd n 1)), Add (TExp lgn) n1 n, ConcatTuple n1 a b, ConcatTuple' lgn a c) =>
ConcatTuple n a (TAppendTuple b c) where
concatTuple v =
let v1 :: Vector n1 a = take v
v2 :: Vector (TExp lgn) a = drop v
Expand All @@ -1320,7 +1320,7 @@ instance ConcatTuple' 0 a a where
concatTuple' v = head v
unconcatTuple' x = cons x nil

instance (Add n1 1 n, ConcatTuple' n1 a b, AppendTuple b b c) => ConcatTuple' n a c where
instance (Add n1 1 n, ConcatTuple' n1 a b) => ConcatTuple' n a (TAppendTuple b b) where
concatTuple' v =
let v1 :: Vector (TExp n1) a = take v
v2 :: Vector (TExp n1) a = drop v
Expand Down
2 changes: 1 addition & 1 deletion src/bluesim/bs_prim_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ static inline void wop_primExtractWide(unsigned int dst_sz,

static inline void wop_primExtractWide(unsigned int dst_sz,
unsigned int src_sz,
tUWide & src,
const tUWide & src,
unsigned int high_sz, unsigned int high,
unsigned int low_sz, unsigned int low,
tUWide &dst)
Expand Down
2 changes: 1 addition & 1 deletion src/bluesim/bs_wide_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class WideData
unsigned int extract32(unsigned int hi, unsigned int lo) const;
unsigned long long extract64(unsigned int hi, unsigned int lo) const;
WideData extractWide(unsigned int hi, unsigned int lo) const;
void wop_extractWide(unsigned int hi, unsigned int lo, WideData& result);
void wop_extractWide(unsigned int hi, unsigned int lo, WideData& result) const;
void clear(unsigned int from = 0);
void clear(unsigned int from, unsigned int to);
void set(unsigned int from = 0);
Expand Down
2 changes: 1 addition & 1 deletion src/bluesim/wide_data.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,7 @@ void wop_rem(const WideData& v1, const WideData& v2, WideData &result)
/*** function calls ***/

/* maybe useful */
void WideData::wop_extractWide(uint hi, uint lo, WideData& result)
void WideData::wop_extractWide(uint hi, uint lo, WideData& result) const
{
copy_bits_to_0(result.data, data, lo, (hi-lo+1));
clear_bits(result.data, (hi-lo+1), (result.numWords() * WORD_SIZE) - 1);
Expand Down
12 changes: 6 additions & 6 deletions src/comp/AAddScheduleDefs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ aAddScheduleDefs flags pps pkg aschedinfo =
-- The ExprMaps map from a method name (not RDY) to the expression
-- for that method's ready or enable condition.
let pre_rdy_map = M.fromList $
[ (dropReadyPrefixId (aIfaceName m), adef_expr (aif_value m))
[ (dropReadyPrefixId (aif_name m), adef_expr $ aif_value m)
| m <- ifc0
, isRdyId (aIfaceName m)
, isRdyId (aif_name m)
]
pre_en_map = M.fromList $
[ (aIfaceName m, e)
[ (aif_name m, e)
| m <- ifc0
, (Just e) <- [getMethodEnExpr m]
]
Expand Down Expand Up @@ -280,11 +280,11 @@ mkIfcWFs _ _ _ = [] -- ignore RDY methods, clocks, resets, inouts
-- Get the map from a method to its rule names (or def name, for value method)
buildRuleMap :: AIFace -> Maybe (Id, [Id])
buildRuleMap m@(AIAction {}) =
Just (aIfaceName m, map aRuleName (aIfaceRules m))
Just (aif_name m, map aRuleName (aIfaceRules m))
buildRuleMap m@(AIActionValue {}) =
Just (aIfaceName m, map aRuleName (aIfaceRules m))
Just (aif_name m, map aRuleName (aIfaceRules m))
buildRuleMap m@(AIDef { aif_name = mid }) | not (isRdyId mid) =
Just (mid, [aIfaceName m])
Just (mid, [aif_name m])
buildRuleMap _ = Nothing

-- Replace the value in a RDY method
Expand Down
2 changes: 2 additions & 0 deletions src/comp/ACheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ checkUse :: S.Set AId -> S.Set AId -> S.Set AId -> AExpr -> [AId]
checkUse ds is ps (APrim _ _ _ es) = checkUses ds is ps es
checkUse ds is ps (AMethCall _ i m es) = checkUses ds is ps es -- XXX check i and m ?
checkUse ds is ps (AMethValue _ i m) = [] -- XXX check i and m ?
checkUse ds is ps (ATuple _ es) = checkUses ds is ps es
checkUse ds is ps (ATupleSel _ e _) = checkUse ds is ps e
checkUse ds is ps (ANoInlineFunCall _ _ _ es) = checkUses ds is ps es
checkUse ds is ps (AFunCall { ae_args = es }) = checkUses ds is ps es
-- because all of the expressions used are used by the ATaskAction
Expand Down
Loading
Loading