Project

BLADE’s project module drives the workflow for generating a DesignFormat description of the design from the raw YAML input. The workflow is broken down into 8 separate stages, each performing a specific transformation of the input data:

  1. Every file and folder provided by the user is searched to identify every available YAML file.

  2. The YAML description is passed through the preprocessor, starting from a specified top-level document.

  3. Output of the preprocessor is parsed into YAML tags, each of which is linked back to its source file.

  4. Definition of intrinsic types such as clock and reset are injected into the tag list.

  5. Every tag (including intrinsics) are validated to check that they are correct in terms of the schema (i.e. which tags can be attached as a child of another, what type an attribute can be, etc).

  6. Elaboration is performed for every tag described in the top-level YAML file, all contributing to a single DFProject instance.

  7. Automatic checks are executed against the DFProject instance produced by the elaboration stage.

Usage

While BLADE comes with a command line interface which should meet most needs, it may be necessary to wrap the core within another tool. To enable this, the project module exposes the build_project which drives the workflow described above. The example below shows how to call the workflow:

from blade import build_project
import json

dep_array = []

(df_project, violations) = build_project(
    top_file = '/path/to/my/top.yaml', # Path to the file to start elaboration from
    includes = [
        '/path/to/my/dependencies',    # Folders can be added to the search path...
        '/path/to/specific/file.yaml'  # along with specific files
    ],
    defines = {
        'MY_VAL' : 123,                # Integers, booleans, and strings can be
        'MY_BOOL': True,               # passed into the workflow. These are then
        'MY_STR' : 'hello!'            # exposed to the preprocessor.
    },
    max_depth  = None,                 # Controls depth of the elaboration (None means unlimited)
    en_convert = False,                # Enable conversions between tag types
    quiet      = False,                # Disables verbose messages and progress bars
    run_checks = True,                 # Enables rule checking on the elaborated design
    waivers    = [],                   # List of paths to waiver files for rule violations
    deps       = dep_array,            # Dependencies of the generated project can be recorded into a provided array
    profile    = False                 # Switches on execution time recording of each phase
)

if len(violations) > 0:
    print("WARNING: %i rule violations were raised" % len(violations))

with open('output.df_blob', 'w') as fh:
    fh.write(json.dumps(df_project.dumpObject()))

API

blade.project.build_project(top_file, includes=None, defines=None, max_depth=None, run_checks=False, waivers=None, quiet=False, deps=None, profile=False)

Parse and elaborate the YAML description into a DesignFormat project.

Drive the pipeline of operations to go from raw Phhidle YAML files through to an elaborated design returned as a DFProject object. This can either perform a deep elaboration, where all layers of the hierarchy are expanded and all interconnections are resolved, or a shallow elaboration where only a limited number of layers are expanded.

Parameters
  • top_file – The top module declaration file begin elaborating from

  • includes – A list of files or folders to include (optional)

  • defines – Defined values to pass to different phases (optional)

  • max_depth – The maximum depth to elaborate to (optional, by default : performs a full depth elaboration - max_depth=None)

  • run_checks – Enable rule checkers (default: False)

  • waivers – List of waiver files to provide to the checking stage

  • quiet – Disable status messages and progress bars (default: False)

  • deps – An array can be provided to store the list of YAML files that : the top object depends on.

  • profile – Measure and print execution times of each phase (default: False)

Returns

The generated DesignFormat project and a list of rule violations.

Return type

tuple

blade.project.delta(start)

Measure the delta between start and the current time

Parameters

start – The point to measure the delta from

Returns

Formatted delta in seconds to two decimal places.

Return type

str

blade.project.iterate(iterable, quiet=False, **tqdm_args)

Wrap an iterable with TQDM if quiet mode disabled.

Parameters
  • iterable – The iterable (array, set, etc) to wrap

  • quiet – Whether we are running quietly (default: False)

  • tqdm_args – Arguments to TQDM

#