This repository contains a collection of tasks and modules related to computer arithmetic, digital design, and implementations inspired by various textbooks, courses, and scientific papers.
- Testing:
- Supports SystemVerilog-based testbenches.
- Supports Python-based cocotb testbenches for flexible and reusable testing.
- Simulators:
- Successfully tested with Icarus Verilog 12.0 and Verilator 5.030.
hdl/
: Contains the hardware description files:- Solution file: A completed implementation of the described task.
- Empty template file: Includes I/O definitions for custom logic implementation.
- To test your custom implementation, replace the top module for the DUT in the testbench and run tests from the
tb
folder.
- To test your custom implementation, replace the top module for the DUT in the testbench and run tests from the
tb/
: Contains testbenches for verifying designs.venv_cocotb/
: Virtual environment folder (auto-generated by Python).- Includes scripts, installed libraries, and configuration files for the virtual environment.
- Navigate to the folder of the module you are interested in.
- To run tests, go to the
tb
folder and execute the appropriate testing command.
Follow these steps to set up and activate a Python virtual environment for the project:
-
Ensure Python is installed: Verify Python 3 installation with:
python3 --version
If not installed, download it from python.org.
-
Create a Virtual Environment: Run the following command in the root directory of your project:
python3 -m venv venv_cocotb
-
Activate the Virtual Environment: Use the following command to activate the virtual environment:
source venv_cocotb/bin/activate
Once activated, the terminal prompt will display
(venv_cocotb)
. -
Install Dependencies: With the virtual environment activated, install the required Python libraries from the
requirements.txt
file:pip install -r requirements.txt
-
To deactivate the virtual environment, simply run:
deactivate
-
Fixing Issues with the Virtual Environment: If you encounter issues with the virtual environment (e.g., incorrect Python version or broken configuration):
- Delete the
venv_cocotb
folder:rm -rf venv_cocotb
- Repeat the steps above to recreate and configure the virtual environment.
-
Install Dependencies:
- Icarus Verilog:
sudo apt install iverilog # For Linux brew install icarus-verilog # For macOS
- Icarus Verilog:
-
Run the Test: In the
tb
folder, execute:make SIM=icarus
-
Install Verilator:
sudo apt install verilator # For Linux brew install verilator # For macOS
-
Run the Test: In the
tb
folder, execute:make SIM=verilator
- Always activate the virtual environment before running tests or project-related Python commands.
- Modify the
tb
folder's testbench as needed to use custom DUT implementations from thehdl
folder.
-
iverilog: Version 12.0 or higher. Install via:
- macOS:
brew install icarus-verilog
- Linux:
sudo apt install iverilog
- macOS:
-
verilator: Version 5.030 or higher. Install via:
- macOS:
If you need to install a specific version of Verilator (e.g., 5.030), refer to this guide: Installing a Custom Verilator Version on macOS.
brew install verilator
- Linux:
If you need to install a custom version of Verilator (e.g., 5.030), follow the instructions provided in the official guide: Installing Verilator on Linux.
sudo apt install verilator
- macOS: