-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffb13d6
commit dd9f068
Showing
47 changed files
with
821 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Arithmetic Logic Unit (ALU) Simulation | ||
|
||
## Overview | ||
|
||
The `Arithmetic-Logic-Unit` directory contains a set of SystemVerilog files designed to model and simulate the operations of an Arithmetic Logic Unit (ALU). This ALU is capable of performing various arithmetic and logic operations, depending on the selected function code. The design is modular, with a focus on scalability and ease of testing. | ||
|
||
## Contents | ||
|
||
This directory includes the following SystemVerilog files: | ||
|
||
- **`alu_slice.sv`**: Defines a single slice of the ALU, capable of performing one bit of arithmetic or logic operation based on the input function code. It uses a ripple-carry adder slice as a fundamental building block. | ||
|
||
- **`gen_alu.sv`**: A parametrizable ALU module that generates a complete ALU of `N` bits by instantiating `N` `alu_slice` modules. It supports scalable arithmetic and logic operations across the specified bit width. | ||
|
||
- **`testbench_4.sv`**: Provides a comprehensive testbench for verifying the functionality of the ALU with 4-bit and 8-bit wide operations. It automates the testing process by cycling through test vectors defined in an external file, `test_vectors.txt`, not included in the directory but required for the testbench to function. | ||
|
||
## Getting Started | ||
|
||
### Prerequisites | ||
|
||
- SystemVerilog-compatible simulation environment (e.g., ModelSim, VCS, or Vivado Simulator). | ||
- Basic understanding of digital logic and SystemVerilog. | ||
|
||
### Running Simulations | ||
|
||
1. **Setup**: Ensure that your simulation tool is installed and configured correctly. | ||
|
||
2. **Compile**: Compile the ALU and testbench SystemVerilog files. Include all files in the compilation process since they are interdependent. | ||
|
||
3. **Run**: Execute the testbench. This process will automatically load the test vectors from `test_vectors.txt` and cycle through them to validate the ALU's functionality. | ||
|
||
4. **Observe**: Monitor the simulation's output. The testbench is designed to display the input and output values for each operation, making it easy to verify correct behavior. | ||
|
||
### Understanding the Testbench Output | ||
|
||
The testbench output is structured to provide a clear and concise view of each test case. It shows the current simulation time, the inputs to the ALU (`A`, `B`, and function code `f`), and the resulting outputs (`S` for sum/result and `CO` for carry-out), for both 4-bit and 8-bit operations. | ||
|
||
## Contributing | ||
|
||
Contributions to improve or extend the ALU's functionality and test coverage are welcome. Please feel free to fork the repository, make your changes, and submit a pull request with a clear explanation of your modifications or additions. | ||
|
||
## License | ||
|
||
This project is released under the MIT License. See the LICENSE file in the repository for more details. | ||
|
||
--- |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Carry-Lookahead Adder (CLA) Simulation | ||
|
||
## Overview | ||
|
||
This directory contains SystemVerilog implementation and testbench for a Carry-Lookahead Adder (CLA), a fast digital circuit to perform addition. CLAs are known for their ability to calculate carry bits quickly, reducing the addition time compared to simple ripple-carry adders, especially for wider bit-widths. | ||
|
||
## Files Description | ||
|
||
- **`cla-adder.sv`**: The main module defines a parametrizable CLA capable of adding two N-bit numbers along with an input carry bit. The module calculates the sum and the output carry bit, showcasing the CLA's efficiency in handling carry propagation. | ||
|
||
- **`testbench_5.sv`**: Provides a testbench to simulate and verify the functionality of the CLA module with different bit widths (e.g., 2-bit and 8-bit). It dynamically changes input values to test various addition scenarios and monitor the correctness of the sum and carry-out outputs. | ||
|
||
## Simulation Setup | ||
|
||
### Prerequisites | ||
|
||
- A SystemVerilog-compatible simulator (e.g., ModelSim, VCS, Vivado Simulator). | ||
- Basic understanding of digital circuits and SystemVerilog syntax. | ||
|
||
### Running the Simulation | ||
|
||
1. **Compile** the `cla-adder.sv` and `testbench_5.sv` files using your simulator's compilation command or IDE. | ||
|
||
2. **Execute** the simulation by running the compiled testbench. Make sure both the CLA module and the testbench are correctly loaded and compiled. | ||
|
||
3. **Observe** the outputs (sum and carry-out) for correctness. The testbench will automatically cycle through a range of input values for both `a` and `b` inputs, along with a fixed `c_in` value, to ensure comprehensive testing of the CLA module. | ||
|
||
## Understanding the CLA Module | ||
|
||
The CLA module utilizes the concept of generate and propagate to quickly determine carry bits for each bit position. This approach significantly speeds up addition by reducing the dependency on the calculation of previous carry bits: | ||
|
||
- **Generate (g)**: Indicates if a carry will be generated by the two adding bits regardless of the carry-in. | ||
- **Propagate (p)**: Indicates if a carry-in will be propagated as carry-out by the two adding bits. | ||
|
||
The module calculates these terms for each bit position and uses them to efficiently compute the carry for the entire adder. | ||
|
||
## Contributing | ||
|
||
Contributions to this CLA simulation are welcomed, including optimizations, additional features, or improved test coverage. Please feel free to fork this repository, commit your changes, and submit a pull request with a clear description of your modifications or enhancements. | ||
|
||
## License | ||
|
||
This project is provided for educational and non-commercial use. Redistribution and use, with or without modification, are permitted provided that the original author is credited. | ||
|
||
--- |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Up/Down Counter Simulation | ||
|
||
## Overview | ||
|
||
The `Counter` directory includes SystemVerilog modules for simulating a parameterizable up/down counter. This counter supports loading initial values, counting up or down based on the input signal, and indicating when a roll-over or roll-under condition occurs. | ||
|
||
## Files Description | ||
|
||
- **`up_down_counter.sv`**: The main module defines the logic for a parameterizable N-bit up/down counter. It features enable, load, and up/down controls along with an N-bit load input and output. The module also provides a roll-over/under output indication (`rco_b`). | ||
|
||
- **`testbench_7.sv`**: A testbench module that instantiates the up/down counter with different parameter sizes (4-bit and 5-bit) and applies various test scenarios to verify its functionality. It systematically changes the counter's mode of operation and initial load values to test all functionalities. | ||
|
||
## Simulation Setup | ||
|
||
### Prerequisites | ||
|
||
- A SystemVerilog-compatible simulator (e.g., ModelSim, VCS, or Vivado Simulator). | ||
- Familiarity with digital logic and SystemVerilog simulation environments. | ||
|
||
### Running the Simulation | ||
|
||
1. **Compile** both `up_down_counter.sv` and `testbench_7.sv` in your simulation environment. | ||
2. **Execute** the `testbench_7` to initiate the simulation. | ||
3. **Monitor** the simulation output for changes in the counter values (`q4`, `q5`), and the roll-over/under indicators (`rco4_b`, `rco5_b`) as the testbench applies different inputs. | ||
|
||
## Key Features | ||
|
||
- **Parameterizable Width**: The counter's bit-width is customizable through a module parameter, allowing for flexibility in design and application. | ||
- **Up/Down Counting**: Controlled by a single input signal, the counter can either increment or decrement, demonstrating versatility in counting operations. | ||
- **Load Capability**: Enables the counter to be initialized with a specific value at any point during operation, useful for dynamic counting applications. | ||
- **Roll-over/Under Indication**: Provides an output signal to indicate when the counter has rolled over (in up mode) or rolled under (in down mode), essential for detecting boundary conditions. | ||
|
||
## Example Usage | ||
|
||
The testbench demonstrates several operational scenarios including: | ||
- Initializing the counter with specific values and enabling up/down counting. | ||
- Dynamically switching between up and down modes to observe counting behavior. | ||
- Utilizing the roll-over/under indication to detect when the counter has completed a full cycle. | ||
|
||
## Example Test Output | ||
|
||
![Test Output](test_output.PNG) | ||
|
||
## Contributing | ||
|
||
Contributions to enhance or extend the functionality of the up/down counter are welcome. This could include adding features, improving efficiency, or expanding the testbench to cover more scenarios. Please fork the repository, commit your changes, and submit a pull request with a detailed description of your contributions. | ||
|
||
## License | ||
|
||
This project is provided for educational and non-commercial use. It is freely available for modification and distribution with proper attribution to the original author(s). | ||
|
||
--- |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.