GNN4CIRCUITS

GNN4CIRCUITS is a platform designed for applying Graph Neural Networks (GNNs) to circuit analysis and design. This repository includes the necessary files and instructions to set up and use the platform.

Table of Contents

Installation

Prerequisites

Setup Instructions

  1. Clone the repository:

    git clone https://github.com/hanasel/GNN4CIRCUITS.git
    cd GNN4CIRCUITS
  2. Create the conda environment:

    conda env create -f gnn4circuits.yml
  3. Activate the environment:

    conda activate gnn4circuits

Usage

Use Case 1: Converting a hardware design into a graph

In this case, we demonstrate the usage of GNN4CIRCUITS to convert hardware design files into graphs and dump into files which can be read by GNN4CIRUITS to train models. The platform is very customizable, offering the input of a technology library so as to accept more formats of files, as well as offering the ability to create large feature vectors for the nodes of the graph which will help in the training process.

To parse and analyze Verilog files, use the parse command with the appropriate options:

python GNN4CIRCUITS.py parse -ver <path-to-verilog-file> -hw <hardware-type> [-lib <path-to-library>] [optional-parameters]

Example

python GNN4CIRCUITS.py parse -ver /path/to/verilog/file.v -hw GL -lib /path/to/library.v -id -od -iod -mdi -mdo -pi -po -gt

Use Case 2: Graph Classification

In this case, we demonstrate the usage of GNN4CIRCUITS for graph classification. After the dataset has been prepared by Use Case 1, the dumped files must be provided by the user for training. The training process is very customizable, offering 3 types of models: GCN, GIN and PNA, as well as allowing the user to determine the hidden dimensions number. Furthermore, it is only necessary for the user to provide a training dataset, in which case there is a default split of 70% training, 10% validation and 20% testing of the dataset. Optionally, the user could provide separate testing and/or validation datasets which must be of the same format and have been generated by GNN4CIRCUITS. The dataset contains a node features file, a graph edges file and a graph properties file.

To train and evaluate GNN models, use the graph command with the appropriate options:

python GNN4CIRCUITS.py graph -model <model-type> -hdim <hidden-dimensions> -train <node-features-file> <edges-file> <properties-file> [-test <node-features-file> <edges-file> <properties-file>] [-val <node-features-file> <edges-file> <properties-file>]

Example

python GNN4CIRCUITS.py graph -model GCN -hdim GL -train node_features.csv graph_edges.csv graph_properties.csv

Arguments

Parse Command Options

  • -ver, --verilog: Path to Verilog file.
  • -hw, --hardware: Hardware type (GL for gate-level, RTL for register-transfer level).
  • -lib, --library: Path to library (required for GL hardware type).
  • -id, --input_degree: Include input degree feature.
  • -od, --output_degree: Include output degree feature.
  • -iod, --io_degree: Include I/O degree feature.
  • -mdi, --min_dist_input: Include minimum distance to input feature.
  • -mdo, --min_dist_output: Include minimum distance to output feature.
  • -pi, --primary_input: Include primary input feature.
  • -po, --primary_output: Include primary output feature.
  • -ki, --key_string: Key string for security features.
  • -gt, --gate_type: Include gate type feature (only applicable if hardware is GL).

Graph Command Options

  • -model: Model type (default: GCN).
  • -hdim: Hidden dimensions.
  • -train: Files for training: node features, edges, and properties.
  • -test: Files for testing: node features, edges, and properties.
  • -val: Files for validation: node features, edges, and properties.