Skip to main content

A tool for converting finite state machine to verilog code

Project description

fsmlog

Upload Python Package

A tool for converting finite state machine to verilog code

Embedded Systems Course Optional Assignment - Spring 2023

Parsa Mohammadian - 98102284

Table of Contents

Installation

From pypi:

pip install fsmlog

From source:

make install

Usage

You can use --help to get more information about the usage of each command.

The tool consists of two commands: validate and convert.

Validate

The validate command is used to validate the input file. It will check if the input file is a valid finite state machine according to the tool's specifications. It takes one argument: the path to the input file.

Convert

The convert command is used to convert the input file to verilog code. It takes two arguments: the path to the input file and the path to the output file. If the output file is not specified, the output will be printed to the console.

Specifications

The input file must be a valid json file with the following structure:

{
    "inputs": [],
    "outputs": [],
    "states": [],
    "initial_state": "",
}

The inputs and outputs fields are lists of registers. Each register has the following structure:

{
    "name": "",
    "length": 0
}

The states field is a list of states. Each state has the following structure:

{
    "name": "",
    "transitions": [],
    "outputs": {}
}

The outputs field is just key-value pairs of the output registers. The transitions field is a list of transitions. Each transition has the following structure:

{
    "destination": "",
    "condition": ""
}

The condition field must be a valid verilog boolean expression.

Valid input file examples can be found in the example directory.

Technical Details

The tool uses jinja2 to generate the verilog code. The template.v file can be found in the src directory. This template can be populated with the FiniteStateMachine object named fsm. The FiniteStateMachine object is created from the input file using the FiniteStateMachine.from_json method. The FiniteStateMachine class has similar attributes to the input file's structure. The FiniteStateMachine class can be found in the src/model/fsm.py file.

Example

Consider the following finite state machine: air-conditioning

We can encode this finite state machine as specified in specifications. The encoded file can be found in the example directory. The file is named air-conditioning.json.

The following command will validate the input file:

fsmlog validate example/air-conditioning.json
FSM example/air-conditioning.json is valid

Now we can convert the input file to verilog code:

fsmlog convert example/air-conditioning.json --output example/air-conditioning.v

The generated verilog code can be found in the example directory. The file is named air-conditioning.v.

The resulting verilog code can be both simulated and synthesized.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fsmlog-1.0.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fsmlog-1.0.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file fsmlog-1.0.0.tar.gz.

File metadata

  • Download URL: fsmlog-1.0.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for fsmlog-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3f767c3ab61a8b8720a7434ab84fbeee844a67897ca2b88b4b93bf9138836c41
MD5 e5a047f479545f03a9574a3a824890cb
BLAKE2b-256 b931ff22c8b87c60f2ddb7251b2e323b64961750f637ae651cbb0ccfbf495899

See more details on using hashes here.

File details

Details for the file fsmlog-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fsmlog-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for fsmlog-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7acb9abd10e6371893d2e7e760b2d54272bbb0eed403ea974023c2b588b8f4f
MD5 cb6241c396ea2709ee15c389bb7e4fb7
BLAKE2b-256 87ede0066e7fb647aeee32bad99b1efae677b74ac1e0e7075290a4558bf8812b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page