Coder Social home page Coder Social logo

osc-mini-hack's Introduction

Functional Computation Kernel

FuCK: Functional Computation kernel.

The functional computation kernel is a custom computer chip designed to accelerate GEMV (general matrix-vector multiplication) in neural networks. It is implemented in VHDL hardware description language and can be executed on low-cost Altera Max 10 FPGA devices. In addition, the project includes a custom assembler and emulator for compiling and testing programs written for the chip.

Background

Neural network inference consists of a series of matrix-vector multiplication operations. A sum is computed of the product of input/neuron activation values and each of their respective weight values. FuCK is a custom embedded device for accelerating the computation of these sums. It is a circuit, written in VHDL, which may be compiled and uploaded to an Altera Max 10 device. It achieves this by integrating with the Altera Max 10s embedded multiplier gates, which allow it to perform multiple multiplications simultaneously. The chip also handles DDR (double data rate) transmissions, allowing users to write values to its memory at both low and high clock signals. A GEMV involving 5 weights and 5 multiplicands can hence be computed in 2 clock cycles.

FuCK enables neural network inference on small, inexpensive, low-power devices. It can be integrated with a Raspberry Pi, arduino, or other microprocessor to implement simple neural networks. In addition to the chip, this repository includes an assembler and emulator. The assembly language consists of the following operations: RST, LOAD, EXEC, RPRT. RST resets all internal memory, LOAD loads up to 5 weights, EXEC multiplies the in-memory weights by an additional 5 multiplicands, and RPRT is a virtual instruction (only recognized by the emulator) for returning the latest output. An example is illustrated below:

RST;
LOAD -1 2 -3 4 -5;
EXEC 5 -4 3 -2 1;
RPRT;

The LOAD and EXEC instructions expect 5 integer operands. All operations must be terminated with a semicolon ;.

Install

This project requires a python interpreter for running the compiler and assembler. If you wish to compile the VHDL code, you may use Quartus Lite or an implementation of ModelSim.

Begin by cloning the repository:

git clone https://github.com/zeim839/osc-mini-hack.git

Install required python dependencies:

python -m pip install numpy

If you wish to run the python demo, you'll also require TensorFlow:

python -m pip install tensorflow

Usage

First, ensure you're in the root project directory:

cd osc-mini-hack

To compile an assembly source file, run:

python kernel compile myFile.asm

Which will produce a binary file called program.bin. The contents of the file may be loaded into a physical implementation of the chip, or alternatively executed on the emulator.

To execute a program on the emulator, run:

python kernel exec program.bin

For instructions on writing programs, see the Background section.

Demo

The demo folder includes a demonstration of the assembler/emulator. It covers compiling a program, as well as implementing a simple neural network on the circuit. See the demo README for instructions.

License

MIT

Copyright (C) 2024 Michail Zeipekki

osc-mini-hack's People

Contributors

zeim839 avatar

Stargazers

Yehan Wasura avatar

Watchers

 avatar

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.