Code Monkey home page Code Monkey logo

silo's Introduction

logo

Simulated Logic

Launch Nuget Build Status codecov License FOSSA Status

Silo (Simulated Logic) is a C# framework which allows you to simulate logic systems in code. Silo has many built-in components like gates, ALU's, displays, etc. that will make simulating complex logic systems easier.

Samples

Sample AND gate

using Silo.Components;
using Silo.Gates;

var a = new Switch();
var b = new Switch();

var andGate = new AndGate();

a.AttachTo(andGate, 0);
b.AttachTo(andGate, 1);

a.State = true;
b.State = true;

Console.WriteLine(andGate);

8 bit input

using Silo.Components;

var input = new EightBitInput();

input.State = 200;

Console.WriteLine(input);

8 bit adder

using Silo.Components;
using Silo.Devices;

var inputA = new EightBitInput();
var inputB = new EightBitInput();

var adder = new EightBitAdder();

inputA.AttachTo(adder);
inputB.AttachTo(adder, 8);

inputA.State = 10;
inputB.State = 5;

Console.WriteLine(adder);

var display = new EightBitDisplay();
adder.AttachToAll(display);
Console.WriteLine(display);

D Flip-Flop with clock

using Silo.Components;
using Silo.Memory;
using Silo.Util;

var flipFlop = new DFlipFlop();
var val = new Switch();
var clk = new Clock(Frequency.Parse("1 Hz"));

clk.AttachTo(flipFlop, 1);

val.State = true;
Console.WriteLine(flipFlop);
Thread.Sleep(2000);
Console.WriteLine(flipFlop);

val.State = false;
Console.WriteLine(flipFlop);
Thread.Sleep(2000);
Console.WriteLine(flipFlop);

Counter with clock

using Silo.Components;
using Silo.Memory;
using Silo.Util;

var ctr = new Counter();

var reset = new Button();
var loadOrCount = new Switch();
var upOrDown = new Switch();
var countToggle = new Switch();
var clock = new Clock(1.kHz());
var input = new EightBitInput();

var display = new EightBitDisplay();

reset.AttachTo(ctr, 0);
loadOrCount.AttachTo(ctr, 1);
upOrDown.AttachTo(ctr, 2);
countToggle.AttachTo(ctr, 3);
clock.AttachTo(ctr, 4);
input.AttachTo(ctr, 5);

ctr.AttachRange(display, 1, 8);

loadOrCount.State = true;
input.State = 50;
Thread.Sleep(100); //Wait for clock to cycle
//Ctr output is now 50

loadOrCount.State = false;
upOrDown.State = true;
countToggle.State = true;
Thread.Sleep(100);
//Ctr output is now ~53

upOrDown.State = false;
Thread.Sleep(100);
//Ctr output is now 50

License

FOSSA Status

silo's People

Contributors

andreashae avatar azer0s avatar fossabot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.