Skip to content

Fast and space-efficient C library for combinational Boolean circuits built from logic gates

License

Notifications You must be signed in to change notification settings

Iteron-dev/logic-gates-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logic gates library

Overview

A fast and space-efficient C library for handling combinational Boolean circuits composed of the following types of gates:

  • NAND, AND, OR, NOR, XOR, XNOR

Gate implementation details

  • A gate has a non-negative integer number of fan-ins (inputs) and one fan-out (output).
  • A gate with no fan-ins always outputs a signal with the value false.
  • For a positive n, the fan-ins of an n-input gate are numbered from 0 to n - 1.
  • A Boolean signal with values false or true can be supplied to the fan-ins of a gate.
  • The fan-out signal from a gate can be connected to multiple fan-ins of other gates.
  • Each fan-in of a gate can have only one signal source connected to it.

API Reference

You can find the API reference for this library at the following link: API Reference.

Building and Running

Prerequisites:

To build and use this library, you need:

  • CMake version 3.12 or higher.
  • A supported compiler, such as GCC or Clang, with support for the C17 standard.

Compilation

  1. Download or clone the repository.

  2. Build the library and example program by executing the following commands in the root of the repository:

cmake -B build/
make -C build/

This will create two binaries in build/ directory:

  • libgate.so - the shared library file.
  • example - an example program demonstrating the usage of the library.

You can now link libgate.so to your own program.

Release Build

For potentially better performance, build in Release mode to enable -O3 and -march=native:

cmake -B build/ -DCMAKE_BUILD_TYPE=Release
make -C build/

Example

For demonstration purposes, you can refer to and modify the example.c file. It showcases a sample usage of this library.

Gate from example.c:

image info

License

This project is licensed under the GNU General Public License v3.0.
See LICENSE for the full terms.

About

Fast and space-efficient C library for combinational Boolean circuits built from logic gates

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published