Skip to content

Commit

Permalink
Merge Refactor module with Steps module
Browse files Browse the repository at this point in the history
related #155
  • Loading branch information
BasicEC committed Jun 12, 2022
1 parent deb0c07 commit b38d7a9
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 57 deletions.
1 change: 0 additions & 1 deletion nitta.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ library
NITTA.Synthesis.Steps.ConstantFolding
NITTA.Synthesis.Steps.Dataflow
NITTA.Synthesis.Steps.OptimizeAccum
NITTA.Synthesis.Steps.Refactor
NITTA.Synthesis.Steps.ResolveDeadlock
NITTA.Synthesis.Types
NITTA.UIBackend
Expand Down
2 changes: 0 additions & 2 deletions src/NITTA/Model/Microarchitecture/Builder.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PartialTypeSignatures #-}

{- |
Expand Down
18 changes: 6 additions & 12 deletions src/NITTA/Model/Networks/Bus.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
Expand Down Expand Up @@ -208,6 +204,10 @@ instance (UnitTag tag, VarValTime v x t) => DataflowProblem (BusNetwork tag v x
instance (UnitTag tag, VarValTime v x t) => ProcessorUnit (BusNetwork tag v x t) v x t where
tryBind f net@BusNetwork{bnRemains, bnPus, bnPUPrototypes}
| any (allowToProcess f) (M.elems bnPus) = Right net{bnRemains = f : bnRemains}
-- TODO
-- There are several issues that need to be addressed: see https://github.com/ryukzak/nitta/pull/195#discussion_r853486450
-- 1) Now the binding of functions to the network is hardcoded, that prevents use of an empty uarch at the start
-- 2) If Allocation options are independent of the bnRemains, then they are present in all synthesis states, which means no leaves in the synthesis tree
| any (\PUPrototype{pProto} -> allowToProcess f pProto) (M.elems bnPUPrototypes) = Right net{bnRemains = f : bnRemains}
tryBind f BusNetwork{bnPus} =
Left [i|All sub process units reject the functional block: #{ f }; rejects: #{ rejects }|]
Expand Down Expand Up @@ -861,10 +861,7 @@ addCustom tag pu ioPorts = do
st
{ signalBusWidth = signalBusWidth + usedPortsLen
, availSignals = drop usedPortsLen availSignals
, pus =
if M.member tag pus
then error "every PU must has uniq tag"
else M.insert tag pu' pus
, pus = M.insertWith (\_ _ -> error "every PU must has uniq tag") tag pu' pus
}

-- |Add PU with the default initial state. Type specify by IOPorts.
Expand All @@ -877,10 +874,7 @@ addCustomPrototype tag pu ioports
st@BuilderSt{prototypes} <- get
put
st
{ prototypes =
if M.member tag prototypes
then error "every prototype must has uniq tag"
else M.insert tag (PUPrototype tag pu ioports) prototypes
{ prototypes = M.insertWith (\_ _ -> error "every prototype must has uniq tag") tag (PUPrototype tag pu ioports) prototypes
}

-- |Add PU to prototypes with the default initial state. Type specify by IOPorts.
Expand Down
4 changes: 0 additions & 4 deletions src/NITTA/Model/Problems/Allocation.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE UndecidableInstances #-}

Expand Down
21 changes: 19 additions & 2 deletions src/NITTA/Synthesis/Steps.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,27 @@ module NITTA.Synthesis.Steps (
module NITTA.Synthesis.Steps.Allocation,
module NITTA.Synthesis.Steps.Bind,
module NITTA.Synthesis.Steps.Dataflow,
module NITTA.Synthesis.Steps.Refactor,
module NITTA.Synthesis.Steps.BreakLoop,
module NITTA.Synthesis.Steps.OptimizeAccum,
module NITTA.Synthesis.Steps.ResolveDeadlock,
module NITTA.Synthesis.Steps.ConstantFolding,
isRefactor,
) where

import Data.Maybe (isJust)
import Data.Typeable (cast)
import NITTA.Synthesis.Steps.Allocation
import NITTA.Synthesis.Steps.Bind
import NITTA.Synthesis.Steps.BreakLoop
import NITTA.Synthesis.Steps.ConstantFolding
import NITTA.Synthesis.Steps.Dataflow
import NITTA.Synthesis.Steps.Refactor
import NITTA.Synthesis.Steps.OptimizeAccum
import NITTA.Synthesis.Steps.ResolveDeadlock
import NITTA.Synthesis.Types (SynthesisDecision (SynthesisDecision, metrics))

isRefactor SynthesisDecision{metrics}
| isJust (cast metrics :: Maybe BreakLoopMetrics) = True
| isJust (cast metrics :: Maybe OptimizeAccumMetrics) = True
| isJust (cast metrics :: Maybe ResolveDeadlockMetrics) = True
| isJust (cast metrics :: Maybe ConstantFoldingMetrics) = True
isRefactor _ = False
4 changes: 0 additions & 4 deletions src/NITTA/Synthesis/Steps/Allocation.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoMonomorphismRestriction #-}

Expand Down
32 changes: 0 additions & 32 deletions src/NITTA/Synthesis/Steps/Refactor.hs

This file was deleted.

0 comments on commit b38d7a9

Please sign in to comment.