Ex 2
Ex 2
2
Combinational Circuits
Course Code: CPE 402
Program: BSCPE
Course Title: Advanced Logic Circuit
Date Performed: Dec. 6, 2016
Section: CPE42FB1
Date Submitted: Dec. 13, 2016
Members: Cahapon, Mamaril, Rabino,
Rodriguez, Sotto
1. Objective(s):
The activity aims to Implement and simulate different kinds of Combinational Circuit in
the FPGA Board.
2. Intended Learning Outcomes (ILOs)
2.1 To describe the concept of active - low and active-high logic signals.
2.2 Analyze the behavior of each Combinational Circuit.
2.3 Test and download the codes in the FPGA Board.
3. Discussion:
Combinational circuits are the class of digital circuits where the outputs of the circuit are
dependent only on the current inputs. In other words, a combinational circuit is able to
produce an output simply from knowing what the current input values are.
Design of a combinational circuit begins with a behavioral specication and selection of
the implementation technique. These are then followed by simplication, hardware
synthesis, and verication.
Some examples of Combinational Circuit are Decoder, Encoder, Multiplexer and
Demultiplexer.
The Basic function of multiplexer is used very frequently in the digital circuit technology.
With the help of multiplexer a purposeful selected input is passed to the output. This
selection is made by using the required select signals. The reverse procedure takes
place with the use of Demultiplexer. In Demultiplexer the input is passed to the
selected output depending on the select signals.
A decoder is a combinational circuit that converts coded inputs to other coded outputs.
The famous examples of decoders are binary n-to-2 n decoders and seven-segment
decoders.
4. Resources:
4.1 A personal computer with installed Xilinx Software
4.2 Internet connection (recommended but not required)
4.3 FPGA BOARD
4.4 AC Adaptors
4.5 USB cable
5. Procedure:
Creating a New Project
Create a new ISE project which will target the FPGA device on Spartan 6 SP601
Evaluation Board.
5.1.1
5.1.2
5.1.3
5.1.4
5.1.5
In the File> New Project > to open the New Project Wizard.
In the Project Name field type Encoder.
Verify that HDL is selected from the Top-Level Source Type list
Click Next to move to the device properties page.
Fill in the properties in the tables as show below:
5.1.6 Click Next to proceed to Project Summary Window in the New Project
Wizard.
5.1.7 Click Finish.
The Encoder project will appear in Design panel on the left.
Creating VHDL Source
In this section, you will create VHDL source code for OR gate.
5.2.1
5.2.2
5.2.3
5.2.4
5.2.5
Double click the Port name field and declare ports for Encoder.
How to Create VHDL Test Bench
Design Simulation
Verifying functionality using Behavioral Simulation
Once the syntax is checked add a VHDL Test Bench file to the file to run simulation.
5.3.1 In the Project menu select New Source
5.3.2 In the New Source Wizard Select VHDL Test Bench for the source type
and enter testbench name for the file.
Multiplexer
Entity name: Mux
Architecture name: behv1
Demultiplexer
Entity name: ent_mux_demux
Architecture name: arch_mux_demux
5.5.4 Locate the Performance Summary table near the bottom of the
Design Summary.
5.5.5 Click the All Constraints Met link in the Timing Constraints field
to view the Timing
Constraints report. Verify that the design meets the specified timing
requirements
5.5.6 Close the Design Summary.
Download Design to the Spartan -3
This is the last step in the design verification process. This section provides
simple instructions for downloading the counter design to the Spartan-3.
5.6.1 Connect the 5V DC power cable to the power input on the demo
board.
5.6.2 Connect the download cable between the PC and FPGA board
(JTAG).
5.6.3 Select Implementation from the drop-down list in the Sources
window.
5.6.4 Select [file] in the Sources window.
5.6.5 In the Process window, double-click the Configure Target Device
process.
The Xilinx WebTalk Dialog box may open during this process. Click
Decline.
iMPACT opens and the Configure Devices dialog box is displayed.
6. Activity
6.1 Test and Simulate the VHDL codes below.
Encoder VHDL CODE
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity encod42 is
Port ( a : in STD_LOGIC_vector(3 downto 0);
y : out STD_LOGIC_vector(1 downto 0));
end encod42;
architecture encod42_df of encod42 is
begin
with a select
y <= "00" when "0001",
"01" when "0010",
"10" when "0100",
"11" when "1000",
"00" when others;
end encod42_df;
--Inputs
signal a : std_logic_vector(3 downto 0);
--Outputs
signal y : std_logic_vector(1 downto 0);
BEGIN
uut: encod42 PORT MAP (
a => a,
y => y
);
process
begin
a <= "0001";
wait for 100 ns;
a <= "0010";
wait for 100 ns;
a <= "0100";
wait for 100 ns;
a <= "1000";
wait for 100 ns;
end process;
END ;
BEGIN
uut: decod24 PORT MAP (
a => a,
y => y
);
process
begin
a <= "00";
wait for 100 ns;
a <= "01";
wait for 100 ns;
a <= "10";
wait for 100 ns;
a <= "11";
wait for 100 ns;
end process;
END;
Multiplexer VHDL CODE
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Mux is
port(
I3:
I2:
I1:
I0:
S:
O:
);
end Mux;
begin
process(I3,I2,I1,I0,S)
begin
U_Mux: Mux port map (T_I3, T_I2, T_I1, T_I0, T_S, T_O);
process
variable err_cnt: integer :=0;
begin
T_I3 <= "001";
T_I2 <= "010";
T_I1 <= "101";
T_I0 <= "111";
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Demux is
Port ( out_0 : out STD_LOGIC;
out_1 : out STD_LOGIC;
out_2 : out STD_LOGIC;
out_3 : out STD_LOGIC;
selector : in STD_LOGIC_vector(1 downto 0);
bit_in : in STD_LOGIC);
end Demux;
BEGIN
-- Instantiate the Unit Under Test (UUT)
Number of Slices:
____1___
____1___
____6___
b. Decoder
Number of Slices:
___2____
__2_____
___6____
c. Multiplexer
Number of Slices:
___2____
___2____
___17___
d. Demultiplexer
Number of Slices:
__2_____
__2_____
___7____
Course: CPE402
Experiment No.: 2
Group No.:
Section: CPE42FB1