A collection of fundamental digital logic modules implemented in Verilog/SystemVerilog, created for practicing RTL design, simulation, and verification.
The repository focuses on implementing core digital building blocks and validating their functionality using ModelSim simulation.
Simulation is performed using ModelSim FPGA Standard Edition.
Compatible tools:
- ModelSim
- QuestaSim
- GTKWave (for
.vcdwaveform viewing)
The repository follows a structured layout separating RTL design, testbench, and simulation flow.
verilog-basic
│
├ rtl/ # Synthesizable RTL modules
├ tb/ # Testbench files
├ sim/ # Simulation scripts / Makefile
├ docs/ # Documentation and waveform images
│ └ images/
│
└ README.md
| Module | Category | Description |
|---|---|---|
| half_adder | Combinational | 1-bit binary addition |
| full_adder | Combinational | Full adder with carry |
| comparator | Combinational | Magnitude comparator |
| mux | Combinational | Multiplexer circuits |
| demux | Combinational | Demultiplexer circuits |
| priority_encoder | Combinational | Priority-based encoding |
| decoder | Combinational | Binary decoder |
| d_latch | Sequential | Level-sensitive storage element |
| sr_latch | Sequential | Basic memory latch |
| d_ff | Sequential | Edge-triggered flip-flop |
| jk_ff | Sequential | JK flip-flop |
| t_ff | Sequential | Toggle flip-flop |
| shift_registers | Sequential | Serial/parallel shift registers |
| ring_counter | Counter | One-hot circular counter |
| johnson_counter | Counter | Twisted ring counter |
| mod_n_counter | Counter | Parameterized counter |
A basic combinational circuit that performs the addition of two 1-bit inputs.
- Inputs:
A,B - Outputs:
Sum,Carry
Logic
Sum = A ^ B
Carry = A & B
A combinational circuit that adds two bits and a carry input.
- Inputs:
A,B,Cin - Outputs:
Sum,Cout
Used as the building block for multi-bit adders.
Compares two input values and determines their relationship.
Outputs indicate:
- greater than
- equal
- less than
Both 1-bit and parameterized N-bit versions are implemented.
Implemented designs:
- 8-to-1 multiplexer
- 16-to-1 multiplexer
- N-bit parameterized multiplexer
- 8-to-1 multiplexer with enable
Multiplexers select one of several inputs and route it to a single output based on a select signal.
Implemented designs:
- 1-to-8 demultiplexer
- 1-to-8 demultiplexer with enable
- 1-to-16 demultiplexer
- parameterized N-bit demultiplexer
A demultiplexer routes one input signal to one of many outputs.
Encodes the highest-priority active input into a binary output value.
Often used in interrupt controllers and arbitration logic.
Implemented designs:
- 2-to-4 decoder
- 3-to-8 decoder
A decoder converts binary input signals into one-hot output lines.
A level-sensitive storage element where the output follows the input when enable is active.
A simple memory element built using Set and Reset inputs.
A clocked storage element that captures input data on the rising edge of the clock.
A flip-flop that improves the SR latch by removing the invalid state.
When both inputs are high, the output toggles.
A toggle flip-flop where the output toggles on each clock cycle when the input is active.
Implemented designs:
- SISO — Serial In Serial Out
- SIPO — Serial In Parallel Out
- PISO — Parallel In Serial Out
- PIPO — Parallel In Parallel Out
- Bidirectional Shift Register
Shift registers are used for data storage, serialization, and communication interfaces.
A circular shift register where a single '1' rotates through the register stages.
A modified ring counter where the inverted output feeds back to the input.
Produces twice the number of states compared to a ring counter.
A counter that cycles through N states before resetting.
Commonly used for clock division and timing generation.
Example simulation waveforms are shown below.
More waveform images are available in the docs/ directory.
Prerequisites:
- ModelSim
- GNU Make
Run simulation:
cd sim
make wave-half_adder
make wave-full_adder
make wave-d_ff
make wave-mux_8to1
Waveforms can be viewed using ModelSim or exported as .vcd.
- Verilog / SystemVerilog
- ModelSim
- GTKWave
- GNU Make
Additional RTL modules planned for future updates


