diff --git a/.github/workflows/rust_ci.yml b/.github/workflows/rust_ci.yml
new file mode 100644
index 0000000..ee280ee
--- /dev/null
+++ b/.github/workflows/rust_ci.yml
@@ -0,0 +1,130 @@
+# This CI (Continuous Integration) file will automatically check your Rust code for errors.
+# It runs using GitHub Actions: https://docs.github.com/en/actions
+# It will check the code compiles, run tests, run lints, and check for security issues.
+# CI will help you standardise your code style and to detect issues with your code easily and early.
+# It makes it easier to integrate different branches once they're finished.
+# adapted from https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md and https://gist.github.com/LukeMathWalker/5ae1107432ce283310c3e601fac915f3
+
+name: Rust CI
+
+on:
+ push:
+ # branches:
+ # - main
+ release:
+ types: [published]
+ pull_request:
+
+env:
+ CARGO_TERM_COLOR: always
+
+jobs:
+ check:
+ name: Check code compiles
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install apt dependencies
+ uses: awalsh128/cache-apt-pkgs-action@latest
+ with:
+ packages: build-essential gettext git libcairo2-dev libgtk-4-dev meson ninja-build sassc valac
+ version: latest
+ - name: Clone libadwaita git repo
+ run: git clone https://gitlab.gnome.org/GNOME/libadwaita.git -b libadwaita-1-2 --depth=1
+ - name: Build libadwaita with Meson
+ run: |
+ cd libadwaita
+ meson . _build -Dgtk_doc=false -Dtests=false -Dexamples=false
+ - name: Install libadwaita with Ninja
+ run: |
+ cd libadwaita
+ sudo ninja -C _build install
+
+ - uses: dtolnay/rust-toolchain@nightly
+ - name: Run cargo check
+ run: cargo check
+
+ test:
+ name: Run tests
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install apt dependencies
+ uses: awalsh128/cache-apt-pkgs-action@latest
+ with:
+ packages: build-essential gettext git libcairo2-dev libgtk-4-dev meson ninja-build sassc valac
+ version: latest
+ - name: Clone libadwaita git repo
+ run: git clone https://gitlab.gnome.org/GNOME/libadwaita.git -b libadwaita-1-2 --depth=1
+ - name: Build libadwaita with Meson
+ run: |
+ cd libadwaita
+ meson . _build -Dgtk_doc=false -Dtests=false -Dexamples=false
+ - name: Install libadwaita with Ninja
+ run: |
+ cd libadwaita
+ sudo ninja -C _build install
+
+ - uses: dtolnay/rust-toolchain@nightly
+ - name: Run cargo test
+ run: cargo test
+
+ fmt:
+ name: Lint with rustfmt
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@nightly
+ with:
+ components: rustfmt
+ - name: Run rustfmt checks
+ run: cargo fmt --check
+
+ clippy:
+ name: Lint with clippy
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install apt dependencies
+ uses: awalsh128/cache-apt-pkgs-action@latest
+ with:
+ packages: build-essential gettext git libcairo2-dev libgtk-4-dev meson ninja-build sassc valac
+ version: latest
+ - name: Clone libadwaita git repo
+ run: git clone https://gitlab.gnome.org/GNOME/libadwaita.git -b libadwaita-1-2 --depth=1
+ - name: Build libadwaita with Meson
+ run: |
+ cd libadwaita
+ meson . _build -Dgtk_doc=false -Dtests=false -Dexamples=false
+ - name: Install libadwaita with Ninja
+ run: |
+ cd libadwaita
+ sudo ninja -C _build install
+
+ - uses: dtolnay/rust-toolchain@nightly
+ with:
+ components: clippy
+ - name: Run cargo clippy checks
+ run: cargo clippy -- -D warnings
+
+ cargo-deny:
+ name: Security scan with cargo deny
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v4
+ - name: Run "cargo deny" to check for vulnerabilities
+ uses: EmbarkStudios/cargo-deny-action@v1
+
+ cargo-audit:
+ name: Security scan with cargo audit
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@nightly
+ - name: Install cargo audit
+ run: cargo install cargo-audit
+ - name: Run "cargo audit" to check for vulnerabilities
+ run: cargo audit
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..0751bfb
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,85 @@
+
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, caste, color, religion, or sexual identity
+and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+* Demonstrating empathy and kindness toward other people
+* Being respectful of differing opinions, viewpoints, and experiences
+* Giving and gracefully accepting constructive feedback
+* Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+* Focusing on what is best not just for us as individuals, but for the
+ overall community
+
+Examples of unacceptable behavior include:
+
+* The use of sexualized language or imagery, and sexual attention or
+ advances of any kind
+* Trolling, insulting or derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or email
+ address, without their explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders 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, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official e-mail address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement at [@Spydr_06](@Spydr_06).
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.0, available at
+[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
+
+
diff --git a/Cargo.toml b/Cargo.toml
index 687856a..97895f6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "logicrs"
-version = "0.1.1"
+version = "0.1.2"
edition = "2021"
description = "An easy-to-use simulator for logical circuits"
readme = "./README.md"
diff --git a/DOCS.md b/DOCS.md
index f529e5b..7a4ee0f 100644
--- a/DOCS.md
+++ b/DOCS.md
@@ -16,7 +16,9 @@
- [Basic Modules](#basic-modules)
- [Input/Output Modules](#inputoutput-modules)
- [Gate Modules](#gate-modules)
+ - [Combinational Modules](#combinational-modules)
- [Latch Modules](#latch-modules)
+ - [Flip Flops](#flip-flops)
- [3. Custom Modules](#3-custom-modules)
- [Creating a new module](#creating-a-new-module)
- [Exporting Modules](#exporting-modules)
@@ -104,41 +106,41 @@ LogicRs features several builtin modules available for every project. Here is a
- | A | B | Output |
- |---|---|--------|
- | 0 | 0 | 0 |
- | 0 | 1 | 0 |
- | 1 | 0 | 0 |
- | 1 | 1 | 1 |
+ | A | B | Output |
+ | --- | --- | ------ |
+ | 0 | 0 | 0 |
+ | 0 | 1 | 0 |
+ | 1 | 0 | 0 |
+ | 1 | 1 | 1 |
- **`Nand`**: inverse of `And`:
- | A | B | Output |
- |---|---|--------|
- | 0 | 0 | 1 |
- | 0 | 1 | 1 |
- | 1 | 0 | 1 |
- | 1 | 1 | 0 |
+ | A | B | Output |
+ | --- | --- | ------ |
+ | 0 | 0 | 1 |
+ | 0 | 1 | 1 |
+ | 1 | 0 | 1 |
+ | 1 | 1 | 0 |
- **`Nor`**: inverse of `Or`:
- | A | B | Output |
- |---|---|--------|
- | 0 | 0 | 1 |
- | 0 | 1 | 0 |
- | 1 | 0 | 0 |
- | 1 | 1 | 0 |
+ | A | B | Output |
+ | --- | --- | ------ |
+ | 0 | 0 | 1 |
+ | 0 | 1 | 0 |
+ | 1 | 0 | 0 |
+ | 1 | 1 | 0 |
- **`Not`**: outputs the inverse of the input signal:
| Input | Output |
- |-------|--------|
+ | ----- | ------ |
| 0 | 1 |
| 1 | 0 |
@@ -146,34 +148,54 @@ LogicRs features several builtin modules available for every project. Here is a
- | A | B | Output |
- |---|---|--------|
- | 0 | 0 | 0 |
- | 0 | 1 | 1 |
- | 1 | 0 | 1 |
- | 1 | 1 | 1 |
+ | A | B | Output |
+ | --- | --- | ------ |
+ | 0 | 0 | 0 |
+ | 0 | 1 | 1 |
+ | 1 | 0 | 1 |
+ | 1 | 1 | 1 |
- **`Xnor`**: inverse of `Xor`:
- | A | B | Output |
- |---|---|--------|
- | 0 | 0 | 1 |
- | 0 | 1 | 0 |
- | 1 | 0 | 0 |
- | 1 | 1 | 1 |
+ | A | B | Output |
+ | --- | --- | ------ |
+ | 0 | 0 | 1 |
+ | 0 | 1 | 0 |
+ | 1 | 0 | 0 |
+ | 1 | 1 | 1 |
- **`Xor`**: outputs `1` if either the A *or* (strictly) B input is `1`:
- | A | B | Output |
- |---|---|--------|
- | 0 | 0 | 0 |
- | 0 | 1 | 1 |
- | 1 | 0 | 1 |
- | 1 | 1 | 0 |
+ | A | B | Output |
+ | --- | --- | ------ |
+ | 0 | 0 | 0 |
+ | 0 | 1 | 1 |
+ | 1 | 0 | 1 |
+ | 1 | 1 | 0 |
+
+### Combinational Modules
+
+- **`Mux`**: A 2:1 multiplexer, selecting either the A or B input based on the S input:
+
+
+
+ | S | Output |
+ | --- | ------ |
+ | 0 | A |
+ | 1 | B |
+
+- **`Demux`**: A 1:2 demultiplexer, selecting either the O0 or O1 output based on the S input:
+
+
+
+ | S | O1 | O0 |
+ | --- | --- | --- |
+ | 0 | 0 | A |
+ | 1 | A | 0 |
### Latch Modules
@@ -181,34 +203,59 @@ LogicRs features several builtin modules available for every project. Here is a
- | A | B | Action |
- |---|---|-----------|
- | 0 | 0 | No change |
- | 0 | 1 | Reset |
- | 1 | 0 | Set |
- | 1 | 1 | Toggle |
+ | A | B | Action |
+ | --- | --- | --------- |
+ | 0 | 0 | No change |
+ | 0 | 1 | Reset |
+ | 1 | 0 | Set |
+ | 1 | 1 | Toggle |
- **`SR Latch`**: Latch used to store a value:
- | A | B | Action |
- |---|---|-------------|
- | 0 | 0 | No change |
- | 0 | 1 | Reset |
- | 1 | 0 | Set |
- | 1 | 1 | Not allowed |
+ | A | B | Action |
+ | --- | --- | ----------- |
+ | 0 | 0 | No change |
+ | 0 | 1 | Reset |
+ | 1 | 0 | Set |
+ | 1 | 1 | Not allowed |
- **`SR Nand Latch`**:
- | A | B | Action |
- |---|---|-------------|
- | 0 | 0 | Not allowed |
- | 0 | 1 | Store 1 |
- | 1 | 0 | Store 0 |
- | 1 | 1 | No change |
+ | A | B | Action |
+ | --- | --- | ----------- |
+ | 0 | 0 | Not allowed |
+ | 0 | 1 | Store 1 |
+ | 1 | 0 | Store 0 |
+ | 1 | 1 | No change |
+
+
+### Flip Flops
+
+- **`D Flip Flop`**: A positive edge triggered flip flop storing D value:
+
+
+
+ | D | Q(t) | Q(t+1) |
+ | --- | ---- | ------ |
+ | 0 | 0 | 0 |
+ | 0 | 1 | 0 |
+ | 1 | 0 | 1 |
+ | 1 | 1 | 1 |
+
+- **`T Flip Flop`**: A positive edge triggered flip flop toggeling its value:
+
+
+
+ | T | Q(t) | Q(t+1) |
+ | --- | ---- | ------ |
+ | 0 | 0 | 0 |
+ | 0 | 1 | 1 |
+ | 1 | 0 | 1 |
+ | 1 | 1 | 0 |
> **Note**
> Feel free to submit pull-requests for more module implementations
diff --git a/INSTALL.md b/INSTALL.md
index 0c0e42f..8efbc77 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -15,7 +15,7 @@ Building is and installation is done via Cargo from source.
**Supported Operating Systems:**
- [x] Linux
- [x] Windows 10/11
-- [ ] MacOS (untested)
+- [x] MacOS
## Obtaining LogicRs
@@ -35,6 +35,44 @@ Prebuilt Binaries can be found on the `releases` section of this repository.
On UNIX, these dependencies mostly will be taken care of by Cargo and your distribution's package manager.
On Windows, you will need to install an unix-like environment like MSYS64/MINGW64 and take care of the dependencies yourself.
+**Linux**
+
+For rpm-based distributions (Fedora, Red Hat, etc.):
+
+```bash
+$ sudo dnf install gtk4-devel cairo-devel libadwaita-devel
+```
+
+For Ubuntu/Debian-based distributions (requires Ubuntu 23.04 or newer):
+
+```bash
+$ sudo apt install build-essential libadwaita-1-dev libcairo2-dev libgtk-4-dev
+```
+
+For Ubuntu/Debian-based distributions that do not ship with `libadwaita` version `1.2` yet (22.10 and below):
+
+```bash
+$ sudo apt install build-essential git libcairo2-dev libgtk-4-dev meson valac sassc gettext
+$ git clone https://gitlab.gnome.org/GNOME/libadwaita.git -b libadwaita-1-2 --depth=1
+$ cd libadwaita
+$ meson . _build -Dgtk_doc=false -Dtests=false -Dexamples=false
+```
+
+then, execute with root permission:
+```console
+# ninja -C _build install
+```
+
+**MacOS**
+
+On MacOS, use brew to install these dependencies.
+
+```zsh
+$ brew install cairo
+$ brew install gtk4
+$ brew install libadwaita
+```
+
## Building
Building LogicRs is very easy by just running one command in the main directory of this repository:
@@ -56,4 +94,4 @@ Or, if you don't want to clone this repository:
```console
$ cargo install --git https://github.com/Spydr06/logicrs
-```
\ No newline at end of file
+```
diff --git a/README.md b/README.md
index da87fa4..db0ec70 100644
--- a/README.md
+++ b/README.md
@@ -22,9 +22,9 @@
-**LogicRs** is an easy-to-use, free and open-source simulator for logical circuits/diagrams written in rust.
+**LogicRs** is an easy-to-use, free and open-source simulator for logical circuits/diagrams written in Rust.
-This program is meant for students, who want learn about [boolean algebra](https://en.wikipedia.org/wiki/Boolean_algebra) and visualize their equations as well as for developers simulating and debugging conditional expressions found everywhere in programming.
+This program is meant for students, who want to learn about [boolean algebra](https://en.wikipedia.org/wiki/Boolean_algebra) and visualize their equations as well as for developers simulating and debugging conditional expressions found everywhere in programming.
![random screenshot](./assets/random-screenshot.png)
@@ -36,7 +36,7 @@ LogicRs can be downloaded as a prebuilt package from the [releases](https://gith
- `.zip` portable installation (Windows)
Alternatively, you can download this repository and build LogicRs from source.
-Please refer to [INSTALL.md](./INSTALL.md) for build instructions and information about compatability
+Please refer to [INSTALL.md](./INSTALL.md) for build instructions and information about compatibility
## Documentation
diff --git a/assets/modules/d-flip-flop.png b/assets/modules/d-flip-flop.png
new file mode 100644
index 0000000..f60e0cf
Binary files /dev/null and b/assets/modules/d-flip-flop.png differ
diff --git a/assets/modules/demux.png b/assets/modules/demux.png
new file mode 100644
index 0000000..c8aea79
Binary files /dev/null and b/assets/modules/demux.png differ
diff --git a/assets/modules/mux.png b/assets/modules/mux.png
new file mode 100644
index 0000000..88d341b
Binary files /dev/null and b/assets/modules/mux.png differ
diff --git a/assets/modules/t-flip-flop.png b/assets/modules/t-flip-flop.png
index e418be3..21ab9ae 100644
Binary files a/assets/modules/t-flip-flop.png and b/assets/modules/t-flip-flop.png differ
diff --git a/content/module-list.ui b/content/module-list.ui
index cc5a2d2..2387629 100644
--- a/content/module-list.ui
+++ b/content/module-list.ui
@@ -103,6 +103,23 @@
+
+
+
+
+
+