Code Monkey home page Code Monkey logo

sonar's Introduction

sonar

Service Master Dev
Build Build Status Master Build Status Dev
Coverage codecov Master codecov Dev
Quality Quality Gate Master Quality Gate Dev
Documentation ย  Documentation Status

sonar is a simulation/testbenching and project management infrastructure for Vivado projects.

Future Work

This was developed during my masters and as I no longer use/need it, further work on sonar is not planned. While the current test cases pass (in my limited test setup [Ubuntu 16.04, Vivado 2017.2] at least), there are certainly bugs and incomplete features should you to deviate from the examples.

Testbenching

sonar can be imported into a Python script. Then, the user can define the ports of the device-under-test (DUT) and test vectors. It will generate a .sv testbench and an associated .dat file containing the user specified test vectors. It can also optionally generate a C++ data file and testbench for use with HLS though that is not quite as sophisticated.

All generated files are placed in the specified directory. To simulate the SV file, add the TB, the .dat file and the DUT file(s) to the simulator of your choice. To simulate the C++ file, make a testbench executable using the generated TB file and run it.

sonar's project management and associated scripts show an example workflow where all these files are automatically added to the created Vivado projects.

Project Management

At present, sonar can create directories for repositories, and within these directories, create IPs through its command line interface. For IPs, a skeleton directory structure is created for the user to fill in as needed. It provides a set of scripts and a Makefile to compile HLS IPs, create sonar testbenches, and pull them all into Vivado projects. The goal with management is to provide a consistent feel to hardware projects, making them easier to navigate, build and share with others. The reach goal is to add hardware IP dependency information so sonar can go fetch dependencies from other repositories without duplicating code.

For now, this is experimental and used primarily to run the test suite.

Usage

To install, clone this repository, go to the cloned directory and run:

$ pip install .

# start a new shell or login again

# initialize with local Xilinx path
$ sonar init vivado /path/to/Xilinx/directory
# then use "sonar activate vivado_{version}" to change versions
$ sonar activate vivado_2017.2
# for now, this should print "sourced file" if successful

The best example for usage can be found in docs/projects/hello_world. This example shows a sample C++ source code and an associated testbench (hello_world.py). This testbench file shows the syntax and some of the features that the sonar testbenches can have.

# to use the testbench, import sonar in python e.g.
from sonar.testbench import Testbench, Module, TestVector, Thread

The test_hello_world.sh script in tests/shell is part of the sonar's internal testing. It shows an example of sonar's command line interface and the commands used to create a new repository, add an IP to it and simulate it.

Dependencies

Testbench

Installing the package is sufficient. It is recommended to install and setup argcomplete to autocomplete sonar's CLI commands. If the package exists, sonar will use it.

Pytest

pytest and coverage is used for internal testing.

Development

For development, it is HIGHLY recommended to use a virtual env such as conda or docker. sonar uses the pre-commit package to enforce style checks for every commit. Conda instructions to set up the development environment are below:

# install sonar as editable
$ pip install -e .

# install optional but RECOMMENDED packages
conda install argcomplete

# install testing dependencies
$ conda install pytest coverage

# install pre-commit and pre-commit hooks
$ conda install pylint
$ conda install -c conda-forge pre-commit cpplint cppcheck shellcheck
$ conda install -c sarcasm clang-format

# activate argcomplete globally for your user if it's not otherwise activated
# note: make sure user bash completion scripts are picked up by .bashrc!
$ activate-global-python-argcomplete --user

# install pre-commit if not installed for this repository
$ pre-commit install

sonar's People

Contributors

sharm294 avatar tarafdar avatar

Stargazers

Sean Wu avatar ZhaoYankang avatar  avatar Quinn Smith avatar Graham Sider avatar Sean Nijjar avatar

Watchers

Sean Nijjar avatar  avatar  avatar

sonar's Issues

When an AXIS transaction has tkeep of 0, get "Unhandled case: Packet count" error

This happens because, on line 134 of axis.py, an if statement checks if tkeep is zero. If so, the line in the .dat file that would normally issue an AXIS transaction is simply not written. However, in the .dat file, this causes the generated Packet Count statement to be incorrectly larger than the true number of lines. In other words, when the main driver in the generated .sv file is reading the packets for a Thread, it prematurely reads the Packet Count statement for the next Thread.

It so happens that I encountered this because I specifically needed to do a testbench where tkeep was 0. I was able to run my testbench by simply unindenting the if statement body and removing the condition. However, I don't expect many other people to need this functionality, so maybe it would be better to simply raise an error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.