New Contents
New Contents
Lab Experiment 1
Concurrent Circuit Basics
LECTURED BY :
ENGINEERING’S DEGREE
DEPARTMENT OF ELECTRICAL AND ENERGY ENGINEERING
INSTITUS
OF TECHNOLOGY OF CAMBODIA
Academy Year
2023-2024
1
Contents
CONTENTS……………………………………………..i
1. CONCURRENT CIRCUIT BASICS
1. OBJECTIVES……………………………………………………………….1
2. EQUIPMENT AND REQUIREMENTS………………………………..2
3. THEORETICAL…………………………………………………………….3
2
CONCURRENT CIRCUIT BASICS
1. OBJECTIVE
• Get familiar with VHDL code structure and syntax
• Get familiar with RTL view and simulation flow in Quartus Prime
• Build basic concurrent circuit using VHDL
• Test the circuit using Cyclone 5 development board
2. EQUIPMENT AND REQUIREMENTS
3. THEORETICAL
3.1. Introduction to multiplexer
3
Exercise A
Solution A :
a. Write VHDL code to build the multiplexer
• To write VHDL code, we need a library like the one above In addition, we also need a
package like use IEEE.STD_LOGIC_1164.all;
4
• entity mux4 is: This declares the entity named “mux4”. An entity in VHDL is like a
blueprint or interface for a digital component. It defines the inputs, outputs, and behavior
of the component.
• port (...): This section declares the ports of the entity. Ports define the interface of the
entity. In this case, the entity has six ports:
• (x0, x1, x2, x3): These are input ports of type “std_logic_vector” with a range of 7 downto
0. Each port represents an 8-bit vector.
• “Y”: This is an output port of type “std_logic_vector” with a range of 7 downto 0. It
represents the output of the multiplexer.
• “sel”: This is an input port of type “std_logic_vector” with a range of 1 downto 0. It
represents the selection input used to choose which input (x0, x1, x2, or x3) is routed to
the output “Y”.
• The entity “mux4” thus represents a 4-to-1 multiplexer with four 8-bit input vectors (x0,
x1, x2, x3), one 8-bit output vector (Y), and a 2-bit selection input (sel). Depending on the
value of “sel”, one of the input vectors is selected and routed to the output “Y”.
• Before we get started with simulation circuit with the FPGA board we must have the ALTERA
CYCLONE IV EP4CE22F17C6N board and jumper (male to female)
6
Exercise B
In this exercise, you will create a generic multiplexer by providing variables NUM_INPUTS
and NUM_BITS as generic constants, where NUM_BITS is the data width for each input and
output. Test your circuit by using NUM_INPUTS = 7 and NUM_BITS = 8
Sloution B
• Library
❖ In this VHDL code snippet, several IEEE libraries are being imported:
• IEEE.STD_LOGIC_1164: This library defines the std_logic type and provides functions
and operators for working with it.
• ieee.numeric_std: This library provides numeric types like unsigned and signed, as well
as arithmetic and comparison functions for these types.
• ieee.math_real: This library provides mathematical functions for real numbers, such as
sine, cosine, square root, etc.
➢ These libraries are commonly used in VHDL design to work with standard logic signals,
perform arithmetic operations on numeric types, and apply mathematical functions to
real numbers.
7
• Entity
❖ This VHDL entity genMux represents a generic multiplexer (MUX) module with configurable
parameters. Here's a brief explanation of its components:
• generic: This section defines generic parameters that can be configured when instantiating the
entity. In this case, there are two generic parameters:
• NUM_INPUTS: Specifies the number of input ports for the multiplexer. It has a default value of 7.
• NUM_BITS: Specifies the number of bits for each input port. It has a default value of 3.
• port: This section defines the input and output ports of the entity:
• input: An input port representing the data inputs to the multiplexer. It is a std_logic_vector with a
width calculated based on the product of NUM_INPUTS and NUM_BITS.
• sel: An input port representing the selection lines for choosing among the inputs. It is a
std_logic_vector whose width is determined by the number of selection lines required to address all
inputs, calculated as the ceiling of the logarithm base 2 of NUM_INPUTS.
• output: An output port representing the output of the multiplexer. It is a std_logic_vector with a
width equal to NUM_BITS.
➢ Overall, this entity defines a configurable multiplexer capable of handling a variable number of
inputs and selecting among them using a set of selection lines.
8
• Architecture
❖ This VHDL architecture RTL implements the functionality of the genMux entity. Here's a brief
explanation of the architecture:
• signal int_sel: This line declares an intermediate signal named int_sel. It converts the sel input
(which is a std_logic_vector) to an integer using the unsigned conversion function. This integer
represents the selected input index.
• begin: This marks the beginning of the architecture body.
• output <= input(((int_sel+1)*NUM_BITS)-1 downto int_sel*NUM_BITS): This line assigns a portion
of the input signal to the output signal based on the selected input index (int_sel). It calculates the
range of bits to be assigned based on the selected input index and the width of each input
(NUM_BITS). It essentially performs the multiplexing operation by selecting the appropriate bits from
the input signal and assigning them to the output signal.
➢ Overall, this architecture implements the multiplexing functionality of the genMux entity, selecting
the input based on the provided selection lines (sel) and outputting the corresponding bits.
9
• Introduction to Address Decoder
• Ex3
10
a).An address decoder is termed "combinational" because its output relies
solely on the present input address lines, devoid of any past history or internal
state. It operates through the following key points:
b) code VHDL
11
❖ Entity Declaration:
• The entity exerciseC is declared with one generic parameter NUM BITS, which specifies
the number of input bits.
• It has two ports: address as input, which is a vector of NUM BITS bits, and
enable as output, which is a vector of size 2**NUM BITS - 1.
12
This is a piece of VHDL code that describes a simple register transfer level (RTL) architecture for a
circuit. Let's break down what it does:
1. Signal Declaration:
• int_a is declared as an integer signal and initialized with the value of a converted to
an unsigned integer.
2. Process Statement:
• A process is defined with sensitivity to changes in signals en and a.
• Whenever either en or a changes, the process is triggered to execute.
3. Process Body:
• Inside the process, there's an if-else statement.
• If en is '1' (indicating enable is active), then:
• b is cleared (all bits set to '0').
• The bit at position int_a in b is set to '1'.
• If en is not '1' (indicating enable is not active), then:
• b is cleared (all bits set to '0').
4. End of Process:
• End of the process statement.
5. End of Architecture:
• End of the architecture description.
13
CONCLUSION
14