Home

Awesome

<div align="center"> <img width="150" alt="Naja Logo" src="./docs/images/Naja-Logo.png"><h1>Naja</h1> </div>

Ubuntu Build MacOS Build Codacy Badge codecov License REUSE status

Introduction

Naja is an Electronic Design Automation (EDA) project that provides open source data structures and APIs for the development of post logic synthesis EDA algorithms such as: netlist simplification (constant and dead logic propagation), logic replication, netlist partitioning, ASIC and FPGA place and route, …

Naja best starting point is netlist optimization and ECO (Engineering Change Order) tool: naja-edit with Python scripts gallery.

Acknowledgement

<img src="https://nlnet.nl/logo/banner.png" width=100> <img src="https://nlnet.nl/image/logos/NGI0Entrust_tag.svg" width=100>

This project is supported and funded by NLNet through the NGI0 Entrust Fund.

naja_edit

naja_edit, located in the $NAJA_INSTALL/bin directory, is a tool designed for optimizing, editing and translating netlists.

:tv: We presented naja_edit’s latest features and results at ORConf 2024. You can watch the full presentation here.

Workflow Overview

The workflow for naja_edit is outlined in the schema below. It's important to note that the only mandatory step in the process is the initial loading of the input netlist.

Naja-Edit

Workflow Details

#translation from verilog to SNL
naja_edit -f verilog -t snl -i input.v -o output.snl
#translation from verilog to SNL with intermediate editing
naja_edit -f verilog -t snl -i input.v -o output.snl -e script.py
# -1: Load input netlist from SNL format.
# -2: Apply pre_edit.py script on the netlist
# -3: Apply Dead Logic Optimization
# -4: Apply post_edit.py on the resulting netlist
# -5: Save netlist in SNL format to output.snl
naja_edit -f snl -t snl -i input.snl -o output.snl -a dle \ 
          -e pre_script.py -z post_edit.py

πŸ‘‰πŸ This page provides a collection of example Python scripts for using the naja_edit API.

naja_edit editing script examples are also available here.

The Naja Regress repository features a collection of examples showcasing extensive use of naja_edit.

<div align="right">[ <a href="#Introduction">↑ Back to top ↑</a> ]</div>

Naja

Naja contains three primary API components:

  1. SNL (Structured Netlist) API housed in this repository.
  2. DNL (Dissolved Netlist) API associated to SNL also in this repository.
  3. naja-verilog, a data structure independent structural verilog parser.

Why Naja ?

Enhanced Fidelity in Data Representation

In most EDA flows, data exchange is done by using standard netlist formats (Verilog, LEF/DEF, EDIF, …) which were not designed to represent data structures content with high fidelity. To address this problem, SNL relies on Cap'n Proto open source interchange format.

DNL provides a uniquified view of SNL, specifically designed for efficient multi-threaded traversal and analysis of netlist data. Key features of DNL include:

Together, SNL and DNL enhance the fidelity, performance, and efficiency of netlist data handling in EDA workflows.

Optimized for Parallelization and Cloud Computing

SNL is engineered with a focus on parallelization, particularly for cloud computing applications. It features a robust object identification mechanism that streamlines the partitioning and merging of data across networks, facilitating efficient EDA applications.

SNL is summarized in below's image.

SNL

:information_desk_person: If you have any questions, please Contact Us

:star: If you find Naja interesting, and would like to stay up-to-date, consider starring this repo to help spread the word.

Documentation

:eyeglasses: Naja's extended and API documentation is available online.

Compilation

Getting sources

# First clone the repository and go inside it
git clone --recurse-submodules https://github.com/najaeda/naja.git

Dependencies

Mandatory dependencies:

  1. Boost
  2. cmake: at least 3.22 version. For system-specific cmake installation options, please refer to this link.
  3. Python3: for building the SNL Python3 interface. This interface is used to load primitive cells (associated to Verilog parsing) and their associated characteristics (for instance: ressource count, timing characteristics, ...).

Optional dependencies:

  1. Doxygen: for the documentation generation.

Embedded dependencies, through git sub modules:

  1. naja-verilog: for verilog parsing.
  2. google test for unit testing.

On Ubuntu:

sudo apt-get install g++ libboost-dev python3.9-dev capnproto libcapnp-dev libtbb-dev pkg-config bison flex doxygen

Using nix-shell:

nix-shell -p cmake boost python3 doxygen capnproto bison flex pkg-config tbb_2021_8

On macOS, using Homebrew:

brew install cmake doxygen capnp tbb bison flex boost

Ensure the versions of bison and flex installed via Homebrew take precedence over the macOS defaults by modifying your $PATH environment variable as follows:

export PATH="/opt/homebrew/opt/flex/bin:/opt/homebrew/opt/bison/bin:$PATH"

Building and Installing

#First define an env variable that points to the directory where you want naja to be installed:
export NAJA_INSTALL=<path_to_installation_dir>
# Create a build dir and go inside it
mkdir build
cd build
cmake <path_to_naja_sources_dir> -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$NAJA_INSTALL
#For instance: cmake ~/srcs/naja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$NAJA_INSTALL
make
make test
make install

Building and Installing Documentation

#make sure that doxygen was available when launching the cmake command
cd build
make docs
make install

Documentation will be installed in $NAJA_INSTALL/doc directory. Starting file to open in browser is: $NAJA_INSTALL/doc/html/index.html.

<div align="right">[ <a href="#Introduction">↑ Back to top ↑</a> ]</div>

Use

Environment

After building and installing, start by setting up a runtime environment.

export NAJA_INSTALL=<path_to_installation_dir>
#For Naja python interface and in particular primitives loading
export PYTHONPATH=$PYTHONPATH:$NAJA_INSTALL/lib/python

Inputs/Outputs

SNL Interchange Format

SNL relies on Cap'n Proto for data serialization and streaming. Schema files and C++ implementation can be found here.

Files composing the dump are created in a directory usually named "snl", composed of the following files:

SNL files can be examined using the capnp tool.

capnp decode --packed snl_interface.capnp DBInterface < snl/db_interface.snl > interface.txt
capnp decode --packed snl_implementation.capnp DBImplementation < snl/db_implementation.snl > implementation.txt
Verilog

For Verilog parsing, Naja relies on naja-verilog submodule. Leaf primitives are loaded through the Python primitive loader: SNLPrimitivesLoader. An application snippet can be found here and examples of primitive libraries described using the Python interface can be found in the primitives directory.

A Verilog dumper is included in SNL API. See here.

<div align="right">[ <a href="#Introduction">↑ Back to top ↑</a> ]</div>

Snippets

c++

This snippet shows various SNL API netlist construction, manipulation and browsing examples.

Python

This snippet shows an equivalent example using Python interface.

Application snippet

An application snippet can be found here.

This "app" directory and its contents can be copied to start a new application.

<div align="right">[ <a href="#Introduction">↑ Back to top ↑</a> ]</div>

Issues / Bugs

Please use GitHub Issues to create and track requests and bugs.

<div align="right">[ <a href="#Introduction">↑ Back to top ↑</a> ]</div>