Skip to content

Commit

Permalink
project initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentFoulon80 committed Jun 6, 2020
0 parents commit bb00937
Show file tree
Hide file tree
Showing 20 changed files with 2,817 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
Cargo.lock
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**If you want to contribute to this project, first of all, thank you for this initiative.**

Here's a list of things you can do for contributing in this project :

+ develop new features, fix bugs, according to Issues or your own initiative
+ Help peoples having troubles installing, configuring or maintaining the project
+ Find bugs, request new features and report them into the Issues
+ Help write and correct the wiki / documentation

Every suggestion can be interesting to implement, so don't hesitate !
14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "virt-ic"
description = "virtual integrated circuits - an backend IC emulator"
version = "0.1.0"
authors = ["Vincent Foulon <[email protected]>"]
repository = "https://github.com/VincentFoulon80/virt-ic"
keywords = ["emulator","integrated-circuit", "backend"]
license = "MIT"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.7.3"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Vincent Foulon

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Virtual Integrated Circuits

[Changelog](https://github.com/VincentFoulon80/virt-ic/releases)

This library is a Integrated Circuit Emulator backend that can simulate interractions between multiple chips.

You start by creating a Board, and then you add Traces or Sockets, and then you plug Chips and link Pins together to form a virtual circuit.
You can then run the circuit to emulate the chips and links between them.

This library is a Backend emulator, it means that there is no interface (yet) to create boards. It'll only emulate chips.

## Chips

- Generator
- Buttons
- Logic Gates (And, Or, Not)
- Clocks
- Memory (RAM, ROM)
- CPU (right now there is only one fictional CPU)

# example usage

```rust
use virt_ic::chip::gates::GateAnd;
use virt_ic::chip::generators::Generator;
use virt_ic::chip::Chip;
use virt_ic::{Board,State};
use std::time::Duration;

fn main() {
// create a board
let mut board = Board::new();
// place sockets with chips on the board
let gen = board.new_socket_with(Box::new(Generator::new()));
let and_gate = board.new_socket_with(Box::new(GateAnd::new()));
// place traces
{
// VCC
let trc = board.new_trace();
trc.borrow_mut().connect(gen.borrow_mut().get_pin(Generator::VCC).unwrap());
trc.borrow_mut().connect(and_gate.borrow_mut().get_pin(GateAnd::VCC).unwrap());
}
{
// GND
let trc = board.new_trace();
trc.borrow_mut().connect(gen.borrow_mut().get_pin(Generator::GND).unwrap());
trc.borrow_mut().connect(and_gate.borrow_mut().get_pin(GateAnd::GND).unwrap());
}
{
// link pin "A&B" to pin "C"
let trc = board.new_trace();
trc.borrow_mut().connect(and_gate.borrow_mut().get_pin(GateAnd::A_AND_B).unwrap());
trc.borrow_mut().connect(and_gate.borrow_mut().get_pin(GateAnd::D).unwrap());
}
// run the board to update its state
// we simulate 1 second segmented by 100 milliseconds
board.run_during(Duration::from_secs(1), Duration::from_millis(100));
// test the chip
println!("ABC:\tA&B\tA&B&C");
let a_b = and_gate.borrow_mut().get_pin_state(GateAnd::A_AND_B).as_bool();
println!("000:\t{}\t{}", a_b, and_gate.borrow_mut().get_pin_state(GateAnd::C_AND_D).as_bool());


// set some pins manually and test the result
and_gate.borrow_mut().set_pin_state(GateAnd::A, &State::High);
and_gate.borrow_mut().set_pin_state(GateAnd::B, &State::High);
and_gate.borrow_mut().set_pin_state(GateAnd::C, &State::Low);
board.run_during(Duration::from_secs(1), Duration::from_millis(100));

let a_b = and_gate.borrow_mut().get_pin_state(GateAnd::A_AND_B).as_bool();
println!("110:\t{}\t{}", a_b, and_gate.borrow_mut().get_pin_state(GateAnd::C_AND_D).as_bool());


and_gate.borrow_mut().set_pin_state(GateAnd::C, &State::High);
board.run_during(Duration::from_secs(1), Duration::from_millis(100));

let a_b = and_gate.borrow_mut().get_pin_state(GateAnd::A_AND_B).as_bool();
println!("111:\t{}\t{}", a_b, and_gate.borrow_mut().get_pin_state(GateAnd::C_AND_D).as_bool());


and_gate.borrow_mut().set_pin_state(GateAnd::A, &State::Low);
and_gate.borrow_mut().set_pin_state(GateAnd::B, &State::Low);
and_gate.borrow_mut().set_pin_state(GateAnd::C, &State::High);
board.run_during(Duration::from_secs(1), Duration::from_millis(100));

let a_b = and_gate.borrow_mut().get_pin_state(GateAnd::A_AND_B).as_bool();
println!("001:\t{}\t{}", a_b, and_gate.borrow_mut().get_pin_state(GateAnd::C_AND_D).as_bool());
}
```

# Documentation

Take a look at the [generated documentation](https://docs.rs/virt-ic/).

# Examples

See [examples](https://github.com/VincentFoulon80/virt-ic/tree/master/examples) :
- **readme** : Same example as provided in this readme
- **ram-test** : A simple test of a RAM chip
- **cpu-test** : A simple circuit containing a minimal setup running a CPU processing factorial of 4
Loading

0 comments on commit bb00937

Please sign in to comment.