This VHDL code describes the top-level module for a lab exercise project named LabExercise3_Top
. The module is designed to debounce input signals, encode them, and control the brightness of multiple LEDs based on the encoded values and switch positions.
The LabExercise3_Top
entity has the following ports:
clk
: Input clock signal.rst
: Input reset signal.a
,b
: Input signals to be debounced and encoded.sw
: 2-bit input switch signal for selecting which LED to control.en
: Input enable signal.led
: 4-bit output signal for controlling the LEDs.
The architecture Behavioral
includes the following components and signals:
-
debounce: Debounces an input signal.
- Ports:
button
: Input signal to debounce.clk
: Clock signal.rst
: Reset signal.debounced
: Debounced output signal.
- Ports:
-
encoder: Encodes the debounced signals into a count.
- Ports:
clk
: Clock signal.rst
: Reset signal.a
: Debounced input signala
.b
: Debounced input signalb
.count
: Encoded output signal.
- Ports:
-
led_control: Controls the brightness of an LED.
- Ports:
clk
: Clock signal.rst
: Reset signal.en
: Enable signal.sel
: Selection signal for the LED.brightness
: Input signal to control brightness.led
: LED output signal.
- Ports:
clk_buff
: Buffer for clock division.clk_div
: Divided clock signal.debounced_a
,debounced_b
,debounced_en
: Debounced input signals.adjust_pwm
: Signal to adjust PWM for LED brightness.led_en_state
: Intermediate enable state for LEDs.
-
Clock Division: A process to divide the input clock signal to a lower frequency.
- If reset is active, reset the clock division.
- On the rising edge of the input clock, toggle the divided clock signal at a specific count.
-
LED Enable State: The enable state for each LED is determined by the switch positions using a
with select
statement.led_en_state
is set based on the value ofsw
.
-
Debounce and Encoder:
- Debounce the input signals
a
andb
. - Encode the debounced signals to produce the
adjust_pwm
signal.
- Debounce the input signals
-
LED Control:
- Debounce the enable signal
en
. - Control each LED based on the debounced enable signal, the switch positions, and the encoded brightness value.
- Debounce the enable signal
This code requires the components debounce
, encoder
, and led_control
to be defined elsewhere in the project.
- 0.01: Initial file creation on 05/19/2024 by Muhammad Shofuwan Anwar.
- The design assumes a 50 MHz input clock and divides it to a lower frequency for internal operations.
- Adjust the clock division and debounce logic parameters as needed for different input clock frequencies or application requirements.
To use this module, instantiate it in a higher-level design and connect the appropriate signals as defined in the entity declaration.