Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace toml to yaml #276

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ nitta v0.0.0.1 - tool for hard real-time CGRA processors
nitta [OPTIONS] FILE

Target system configuration:
--uarch=PATH Microarchitecture configuration file
-a --auto-uarch Use empty microarchitecture and
--march=PATH Microarchitecture configuration file
-a --auto-march Use empty microarchitecture and
allocate PUs during synthesis process.
-t --type=fxM.B Overrides data type specified in
config file
Expand Down
45 changes: 22 additions & 23 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Control.Exception
import Control.Monad (when)
import Data.ByteString.Lazy.Char8 qualified as BS
import Data.Default (def)
import Data.Foldable (forM_)
import Data.Maybe
import Data.Proxy
import Data.String.Utils qualified as S
Expand All @@ -32,15 +33,14 @@ import NITTA.Frontends
import NITTA.Intermediate.Simulation
import NITTA.Intermediate.Types
import NITTA.Model.Microarchitecture.Config
import NITTA.Model.Networks.Bus
import NITTA.Model.Networks.Bus hiding (ioSync)
import NITTA.Model.Networks.Types
import NITTA.Model.ProcessorUnits
import NITTA.Project (TestbenchReport (..), defProjectTemplates, runTestbench)
import NITTA.Synthesis (TargetSynthesis (..), mlScoreKeyPrefix, noSynthesis, stateOfTheArtSynthesisIO, synthesizeTargetSystem, topDownByScoreSynthesisIO)
import NITTA.Synthesis.MlBackend.ServerInstance
import NITTA.UIBackend
import NITTA.UIBackend.Types (BackendCtx, mlBackendGetter, nodeScores, outputPath, receivedValues, root)
import NITTA.Utils
import Paths_nitta
import System.Console.CmdArgs hiding (def)
import System.Exit
Expand All @@ -62,8 +62,8 @@ data SynthesisMethodArg
-- | Command line interface.
data Nitta = Nitta
{ filename :: FilePath
, uarch :: Maybe FilePath
, auto_uarch :: Bool
, march :: Maybe FilePath
, auto_march :: Bool
, type_ :: Maybe String
, io_sync :: Maybe IOSynchronization
, port :: Int
Expand Down Expand Up @@ -96,17 +96,17 @@ nittaArgs =
-1
&= help "Run nitta server for UI on specific port (by default - not run)"
&= groupname "Common flags"
, uarch =
, march =
Nothing
&= typ "PATH"
&= help "Microarchitecture configuration file"
&= explicit
&= name "uarch"
&= name "march"
&= groupname "Target system configuration"
, auto_uarch =
, auto_march =
False
&= help "Use empty microarchitecture and allocate PUs during synthesis process."
&= name "auto-uarch"
&= name "auto-march"
&= groupname "Target system configuration"
, type_ =
Nothing
Expand Down Expand Up @@ -199,13 +199,11 @@ nittaArgs =
getNittaArgs :: IO Nitta
getNittaArgs = cmdArgs nittaArgs

fromConf toml s = getFromTomlSection s =<< toml

main = do
( Nitta
filename
uarch
auto_uarch
march
auto_march
type_
io_sync
port
Expand All @@ -229,10 +227,11 @@ main = do
-- force line buffering (always, not just when stdout is connected to a tty),
-- it's critical for successful parsing of NITTA's stdout in python scripts
hSetBuffering stdout LineBuffering

toml <- case uarch of
conf <- case march of
Nothing -> return Nothing
Just path -> Just . getToml <$> T.readFile path
Just path -> Just <$> parseConfig path
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like parseConfig <$> path should work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parseConfig is a FilePath -> IO MicroarchitectureConf type
path is a FilePath type
<$> is a (a -> b) -> f a -> f b type

The result must be type of IO Maybe MicroarchitectureConf, so Just <$> parseConfig pathdoesn't seem to be able to be simplified.


forM_ conf $ saveConfig output_path

let exactFrontendType = identifyFrontendType filename frontend_language

Expand All @@ -241,17 +240,17 @@ main = do
let frontendResult@FrontendResult{frDataFlow, frTrace, frPrettyLog} =
translate exactFrontendType src
received = [("u#0", map (\i -> read $ show $ sin ((2 :: Double) * 3.14 * 50 * 0.001 * i)) [0 .. toEnum n])]
ioSync = fromJust $ io_sync <|> fromConf toml "ioSync" <|> Just Sync
confMa = toml >>= Just . mkMicroarchitecture ioSync
ioSync_ = fromJust $ io_sync <|> ioSync <$> conf <|> Just Sync
confMa = mkMicroarchitecture <$> conf
ma :: BusNetwork T.Text T.Text (Attr (FX m b)) Int
ma
| auto_uarch && isJust confMa =
| auto_march && isJust confMa =
error $
"auto_uarch flag means that an empty uarch with default prototypes will be used. "
<> "Remove uarch flag or specify prototypes list in config file and remove auto_uarch."
| auto_uarch = microarchWithProtos ioSync
"auto_march flag means that an empty march with default prototypes will be used. "
<> "Remove march flag or specify prototypes list in config file and remove auto_march."
| auto_march = microarchWithProtos ioSync_
| isJust confMa = fromJust confMa
| otherwise = defMicroarch ioSync
| otherwise = defMicroarch ioSync_

infoM "NITTA" $ "will trace: " <> S.join ", " (map (show . tvVar) frTrace)

Expand Down Expand Up @@ -302,7 +301,7 @@ main = do
exitSuccess
)
$ parseFX . fromJust
$ type_ <|> fromConf toml "type" <|> Just "fx32.32"
$ type_ <|> T.unpack . valueType <$> conf <|> Just "fx32.32"

parseFX input =
let typePattern = mkRegex "fx([0-9]+).([0-9]+)"
Expand Down
46 changes: 0 additions & 46 deletions examples/microarch.toml

This file was deleted.

30 changes: 30 additions & 0 deletions examples/microarch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
mock: true
ioSync: Sync
valueType: fx32.32
library:
fram{x}: # If you want a PU can be allocated only once, remove {x} from the PU name.
type: Fram
size: 32
accum{x}:
type: Accum
networks:
net1:
pus:
spi:
type: SPI
mosi: mosi
miso: miso
sclk: sclk
cs: cs
isSlave: true
bufferSize: 6
bounceFilter: 0
protos:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let move it to the top level as puLibrary.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is is about all PUs, which nitta can allocate automatically. Current -- in network. Should be -- on the top level & network.

shift{x}:
type: Shift
sRight: true
mul{x}:
type: Multiplier
div{x}:
type: Divider
pipeline: 4
9 changes: 5 additions & 4 deletions nitta.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ library
, hashable
, heap
, hslogger
, htoml
, http-api-data
, http-conduit
, hxt
Expand Down Expand Up @@ -178,6 +177,7 @@ library
, wai-app-static
, wai-cors
, warp
, yaml
default-language: Haskell2010

executable nitta
Expand Down Expand Up @@ -211,7 +211,6 @@ executable nitta
, ginger
, heap
, hslogger
, htoml
, intervals
, mtl
, nitta
Expand All @@ -223,6 +222,7 @@ executable nitta
, tostring
, unordered-containers
, wai-app-static
, yaml
default-language: Haskell2010

executable nitta-api-gen
Expand Down Expand Up @@ -259,7 +259,6 @@ executable nitta-api-gen
, ginger
, heap
, hslogger
, htoml
, intervals
, mtl
, nitta
Expand All @@ -271,6 +270,7 @@ executable nitta-api-gen
, tostring
, unordered-containers
, wai-app-static
, yaml
default-language: Haskell2010

test-suite nitta-test
Expand All @@ -285,6 +285,7 @@ test-suite nitta-test
NITTA.Intermediate.Simulation.Tests
NITTA.Intermediate.Tests.Functions
NITTA.Intermediate.Value.Tests
NITTA.Model.Config.Tests
NITTA.Model.Problems.Refactor.Accum.Tests
NITTA.Model.Problems.Refactor.ConstantFolding.Tests
NITTA.Model.Problems.Refactor.Tests
Expand Down Expand Up @@ -337,7 +338,6 @@ test-suite nitta-test
, genvalidity-property
, ginger
, heap
, htoml
, hxt
, intervals
, language-lua
Expand All @@ -359,4 +359,5 @@ test-suite nitta-test
, tostring
, unordered-containers
, wai-app-static
, yaml
default-language: Haskell2010
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies:
- data-default
- filepath
- ginger
- htoml
- yaml
- intervals
- mtl
- prettyprinter
Expand Down
Loading
Loading