Giter VIP home page Giter VIP logo

emixa's Introduction

emixa: Error Modeling of IneXact Arithmetic

This repository contains a library for nearly automatic characterization of approximate arithmetic units. These units are imported from the approx and written in Chisel, with tests described in ChiselTest. In its current form, emixa only supports characterizing adders and multipliers, producing plots of their error characteristicts and/or (approximated) Python descriptions of their functionality.

The tool is invoked with the command line as follows:

python3 emixa.py [-f[unction]] [-p[lots]] [-v[erbose]] CHARACTERIZER_NAME [ARG ...]

The -f and -p flags enable outputting Python functions and plots, respectively. The -v flag puts the tool in verbose mode under which it forwards stdout outputs from the ChiselTest characterizers to the tool's stdout. CHARACTERIZER_NAME denotes the name of a characterizer class defined by the user, which is passed arguments ARG .... The tool supports range-style arguments start:stop[:by] to execute tests for, say, multiple bit-widths in one call, for example:

python3 emixa.py -p -v ApproxAdderSpec 32 8:16:2

When you use this library in a research project, please cite it as:

@misc{damsgaard2024emixa,
  title={{emixa: Error Modeling of IneXact Arithmetic}},
  author={Damsgaard, Hans Jakob},
  year={2024},
  howpublished={\url{https://github.com/aproposorg/emixa}}}

This README only contains a brief overview of the library's current functionality. For more details on the included arithmetic units, please refer to its standalone documentation. Refer to the Digital Design with Chisel book for more details on using Chisel for hardware design.


Requirements

Apart from its core components described written in Python, the library requires a suitable installation of Scala for the approx, Chisel, and ChiselTest components to compile and execute. For this purpose, we use the Scala Build Tool (sbt) for which we provide a suitable build script. To install the needed Python packages, execute the following command:

pip3 install -r ./requirements.txt

emixa does not require Verilator to be installed for pure Chisel designs, but if it is available, the tool will automatically use it to speed up simulations. Blackbox designs require an installation of Verilator. Note that only specific versions of Verilator are officially supported.

This library is tested in Ubuntu 20.04 with Python 3.8 and Verilator 4.028.


Using the library

Using emixa involves the definition of a characterizer; a test class that extends one of the two base characterizer classes emixa.AdderCharacterizer or emixa.MultiplierCharacterizer. The characterizer must define two values: sgn, denoting the signedness of the targeted arithmetic unit, and chartype, denoting the type of characterization to perform. Moreover, the characterizer must call the characterize method inherited from the aforementioned classes within its body. In the current state, the library supports three characterization styles: (1) exhaustive (for designs whose operands are 8 bits or smaller), and (2) random 2D, and (3) random 3D (both for designs whose operands are 64 bits or smaller). The different characterization styles affect which plots and/or Python functions the tool produces. As an example, consider the following signed random 2D characterizer of an imaginary approximate adder ApproxAdder:

import emixa.AdderCharacterizer
import emixa.Signedness.Signed
import emixa.Characterization.Random2D

class ApproxAdderSpec extends AdderCharacterizer {
  val sgn = Signed
  val chartype = Random2D

  characterize[ApproxAdder]()
}

emixa's infrastructure automatically handles passing arguments of the right types to instantiate the approximate arithmetic unit within the characterizer through runtime reflection. Arguments which cannot be cast to the right type give rise to runtime exceptions. Additional arguments beyond the ones needed by the basic constructor of the arithmetic unit are discarded without warnings.

Note that due to limitations in the current way of instantiating and interacting with arithmetic units internal to emixa, adders and multipliers must extend their related abstract base classes approx.addition.Adder and approx.multiplication.Multiplier. For the few designs included in approx that do not conform with this requirement, one needs to define a wrapper class.

Pure Chisel examples

The examples directory includes three simple example characterizers for the OFLOCA and HOAANED adders, and the ETM multiplier. The OFLOCA characterizer produces the following plots when invoked:

python3 emixa.py -p OFLOCASpec 8 4 2
Mean error vs exact sums Relative and cumulative error frequencies

Blackbox example

In addition to the above examples, the examples directory includes a simple example characterizer of a blackbox LOA adder. This characterizer produces the following plot when invoked:

python3 emixa.py -p LOASpec 8 2
Mean error vs exact sums

emixa's People

Contributors

hansemandse avatar

Stargazers

Amelia Dobis avatar

Forkers

mfkiwl

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.