Skip to content

Commit

Permalink
Organize
Browse files Browse the repository at this point in the history
  • Loading branch information
dopamane committed Jun 12, 2024
1 parent 99770d2 commit 316b41d
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions lib/Bayeux/Rtlil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module Bayeux.Rtlil
Wire(..)
, WireStmt(..)
, WireId(..)
, freshWireId
, WireOption(..)
, -- ** Memories
Memory(..)
Expand All @@ -44,6 +45,7 @@ module Bayeux.Rtlil
Cell(..)
, CellStmt(..)
, CellId(..)
, freshCellId
, CellType(..)
, CellBodyStmt(..)
, CellEndStmt(..)
Expand Down Expand Up @@ -94,6 +96,7 @@ module Bayeux.Rtlil
, -- ** Processes
Process(..)
, ProcStmt(..)
, freshProcStmt
, ProcessBody(..)
, AssignStmt(..)
, DestSigSpec(..)
Expand All @@ -113,10 +116,6 @@ module Bayeux.Rtlil
, SyncStmt(..)
, SyncType(..)
, UpdateStmt(..)
, -- * Identifier generation
freshCellId
, freshProcStmt
, freshWireId
) where

import Control.Monad.State
Expand Down Expand Up @@ -329,6 +328,9 @@ instance Pretty WireStmt where
newtype WireId = WireId Ident
deriving (Eq, IsString, Monoid, Pretty, Read, Semigroup, Show)

freshWireId :: MonadState Integer m => m WireId
freshWireId = ("\\wire" <>) . fromString . show <$> fresh

data WireOption = WireOptionWidth Integer
| WireOptionOffset Integer
| WireOptionInput Integer
Expand Down Expand Up @@ -394,6 +396,9 @@ instance Pretty CellStmt where
newtype CellId = CellId Ident
deriving (Eq, IsString, Monoid, Pretty, Read, Semigroup, Show)

freshCellId :: MonadState Integer m => m CellId
freshCellId = ("$cell" <>) . fromString . show <$> fresh

newtype CellType = CellType Ident
deriving (Eq, IsString, Pretty, Read, Show)

Expand Down Expand Up @@ -611,6 +616,9 @@ newtype ProcStmt = ProcStmt Ident
instance Pretty ProcStmt where
pretty (ProcStmt i) = "process" <+> pretty i

freshProcStmt :: MonadState Integer m => m ProcStmt
freshProcStmt = ("$proc" <>) . fromString . show <$> fresh

data ProcessBody = ProcessBody [AssignStmt] (Maybe Switch) [AssignStmt] [Sync]
deriving (Eq, Read, Show)

Expand Down Expand Up @@ -750,12 +758,3 @@ fresh = do
i <- get
modify (+ 1)
return i

freshWireId :: MonadState Integer m => m WireId
freshWireId = ("\\wire" <>) . fromString . show <$> fresh

freshCellId :: MonadState Integer m => m CellId
freshCellId = ("$cell" <>) . fromString . show <$> fresh

freshProcStmt :: MonadState Integer m => m ProcStmt
freshProcStmt = ("$proc" <>) . fromString . show <$> fresh

0 comments on commit 316b41d

Please sign in to comment.