verismith-0.6.0.2: Random verilog generation and simulator testing.

Copyright(c) 2019 Yann Herklotz
LicenseGPL-3
Maintaineryann [at] yannherklotz [dot] com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Verismith.Config

Contents

Description

TOML Configuration file format and parser.

Synopsis

TOML Configuration

Verismith supports a TOML configuration file that can be passed using the -c flag or using the parseConfig and encodeConfig functions. The configuration can then be manipulated using the lenses that are also provided in this module.

The configuration file can be used to tweak the random Verilog generation by passing different probabilities to each of the syntax nodes in the AST. It can also be used to specify which simulators to fuzz with which options. A seed for the run can also be set, to replay a previous run using the same exact generation. A default value is associated with each key in the configuration file, which means that only the options that need overriding can be added to the configuration. The defaults can be observed in defaultConfig or when running verismith config.

Configuration Sections

There are four main configuration sections in the TOML file:

probability
The probability section defines the probabilities at every node in the AST.
property
Controls different properties of the generation, such as adding a seed or the depth of the statements.
simulator
This is an array of tables containing descriptions of the different simulators that should be used. It currently only supports Icarus Verilog.
synthesiser
This is also an array of tables containing descriptions of the different synthesisers that should be used. The synthesisers that are currently supported are:

data Config Source #

Instances
Eq Config Source # 
Instance details

Defined in Verismith.Config

Methods

(==) :: Config -> Config -> Bool #

(/=) :: Config -> Config -> Bool #

Show Config Source # 
Instance details

Defined in Verismith.Config

Probabilities

data Probability Source #

[probability]: combined probabilities.

Constructors

Probability 

Fields

Instances
Eq Probability Source # 
Instance details

Defined in Verismith.Config

Show Probability Source # 
Instance details

Defined in Verismith.Config

Expression

data ProbExpr Source #

Probability of different expressions nodes.

Constructors

ProbExpr 

Fields

  • _probExprNum :: !Int

    expr.number: probability of generation a number like 4'ha. This should never be set to 0, as it is used as a fallback in case there are no viable identifiers, such as none being in scope.

  • _probExprId :: !Int

    expr.variable: probability of generating an identifier that is in scope and of the right type.

  • _probExprRangeSelect :: !Int

    expr.rangeselect: probability of generating a range selection from a port (reg1[2:0]).

  • _probExprUnOp :: !Int

    expr.unary: probability of generating a unary operator.

  • _probExprBinOp :: !Int

    expr.binary: probability of generation a binary operator.

  • _probExprCond :: !Int

    expr.ternary: probability of generating a conditional ternary operator.

  • _probExprConcat :: !Int

    expr.concatenation: probability of generating a concatenation.

  • _probExprStr :: !Int

    expr.string: probability of generating a string. This is not fully supported therefore currently cannot be set.

  • _probExprSigned :: !Int

    expr.signed: probability of generating a signed function $signed(...).

  • _probExprUnsigned :: !Int

    expr.unsigned: probability of generating an unsigned function $unsigned(...).

Instances
Eq ProbExpr Source # 
Instance details

Defined in Verismith.Config

Show ProbExpr Source # 
Instance details

Defined in Verismith.Config

Module Item

data ProbModItem Source #

Probability of generating different nodes inside a module declaration.

Constructors

ProbModItem 

Fields

Instances
Eq ProbModItem Source # 
Instance details

Defined in Verismith.Config

Show ProbModItem Source # 
Instance details

Defined in Verismith.Config

Statement

data ProbStatement Source #

Probability of generating different statements.

Constructors

ProbStatement 

Fields

  • _probStmntBlock :: !Int

    statement.blocking: probability of generating blocking assignments.

  • _probStmntNonBlock :: !Int

    statement.nonblocking: probability of generating nonblocking assignments.

  • _probStmntCond :: !Int

    statement.conditional: probability of generating conditional statements (if statements).

  • _probStmntFor :: !Int

    statement.forloop: probability of generating for loops.

ConfProperty

data ConfProperty Source #

[property]: properties for the generated Verilog file.

Constructors

ConfProperty 

Fields

  • _propSize :: !Int

    size: the size of the generated Verilog.

  • _propSeed :: !(Maybe Seed)

    seed: a possible seed that could be used to generate the same Verilog.

  • _propStmntDepth :: !Int

    statement.depth: the maximum statement depth that should be reached.

  • _propModDepth :: !Int

    module.depth: the maximium module depth that should be reached.

  • _propMaxModules :: !Int

    module.max: the maximum number of modules that are allowed to be created at each level.

  • _propSampleMethod :: !Text

    sample.method: the sampling method that should be used to generate specific distributions of random programs.

  • _propSampleSize :: !Int

    sample.size: the number of samples to take for the sampling method.

  • _propCombine :: !Bool

    output.combine: if the output should be combined into one bit or not.

  • _propNonDeterminism :: !Int

    nondeterminism: the frequency at which nondeterminism should be generated (currently a work in progress).

  • _propDeterminism :: !Int

    determinism: the frequency at which determinism should be generated (currently modules are always deterministic).

  • _propDefaultYosys :: !(Maybe Text)

    default.yosys: Default location for Yosys, which will be used for equivalence checking.

Instances
Eq ConfProperty Source # 
Instance details

Defined in Verismith.Config

Show ConfProperty Source # 
Instance details

Defined in Verismith.Config

Simulator Description

data SimDescription Source #

Description of the simulator

Constructors

SimDescription 

Fields

Synthesiser Description

data SynthDescription Source #

[[synthesiser]]: description of the synthesis tool. There can be multiple of these sections in a config file.

Constructors

SynthDescription 

Fields

  • synthName :: !Text

    name: type of the synthesis tool. Can either be yosys, quartus, quartuslight, vivado, xst.

  • synthBin :: Maybe Text

    bin: location of the synthesis tool binary.

  • synthDesc :: Maybe Text

    description: description that should be used for the synthesis tool.

  • synthOut :: Maybe Text

    output: name of the output Verilog file.

Useful Lenses