ECAD Lab 2015-2016
ECAD Lab 2015-2016
ECAD Lab 2015-2016
Getting Started
For Windows users, start ISE from the Start menu by selecting:
1. Start _ Programs _ Xilinx ISE 14.5 _ Project Navigator
2. The ISE Project Navigator opens. The Project Navigator lets you manage the sources
and processes in your ISE project.
3. All of the tasks in the Quick Start Tutorial are managed from within Project
Navigator.
1. This simple AND Gate design has two inputs: a and b. This design has one output
called c
2. Click New Source in the New Project Wizard to add one new source to your project.
3. Select VHDL Module as the source type in the New Source dialog box.
4. Type the file name (and gate) in that file name column.
5. Verify that the Add to project checkbox is selected.
6. Click Next.
7. Define the ports for your VHDL source.
In the Port Name column, type the port names on three separate rows: a, b and c.
In the Direction column, indicate whether each port is an input, output, or inout.
For a, b select in from the list. For c select out from the list.
Caution! You must correct any errors found in your source files. If you continue without
valid syntax, you will not be able to simulate or synthesize your design.
• Click on the Project from menu bar and select “new source”.
• Then below mentioned table will appear in that select a Test Bench and
click on next.
Then Test bench program windows will appear. In that we have to remove the below
mentioned program line for no clock generation programs like Logic gates, decoders and
encoders, multiplexers, de-multiplexers.
Constant <clock>_period: Time: = 10 ns;
After removing the clock process definition and constant clock period we have to write a
below mentioned small logic in a process to generate the time wave forms for given input
variables.
We have to give just assign the input values in the test bench as we mentioned in the VLSI
code. No need to rewrite the logic once again in the test bench.
i. After that we have to double click on the “Behavioral Check Syntax” for checking
any errors in test bench program.
ii. If there are no errors in the program then it shows a Tick mark (√) in green colour.
iii. If there are any errors in the program then it shows a cross mark(X) with red colour.
iv. Then we have to check the where the errors are placed in the program and correct it.
v. After completion check syntax we have to double click on the Simulate Behavior
Model then the output wave form will generated
vi. Then a new window will appear in that output wave forms are appearing.
vii. To view the full wave forms then click on the zoom to full view option as shown in
the picture below.
1.2 Apparatus:-
1. Personal computer
2. Xilinx ISE Simulator
1.3 Theory:-
1.3.1 AND Gate:
A Logic AND Gate is a type of digital logic gate that has an output which is normally
at logic level "0" and only goes "HIGH" to a logic level "1" when ALL of its inputs
are at logic level "1".
The output of a Logic AND Gate only returns "LOW" again when ANY of its inputs
are at a logic level "0".
The logic or Boolean expression given for a logic AND gate is that for Logical
Multiplication which is denoted by a single dot or full stop symbol, (.) giving us the
Boolean expression of: C =A.B
1.3.2 OR Gate:
A Logic OR Gate or Inclusive-OR gate is a type of digital logic gate that has an
output which is normally at logic level "0" and only goes "HIGH" to a logic level "1"
when one or more of its inputs are at logic level "1".
The output, of a Logic OR Gate only returns "LOW" again when ALL of its inputs
are at a logic level "0".
The logic or Boolean expression given for a logic OR gate is that for Logical Addition
which is denoted by a plus sign, (+) giving us the Boolean expression of: C = A+B .
and n1(and_gate,a,b);
or n2(or_gate,a,b);
not n3(not_gate,a);
nand n4(nand_gate,a,b);
nor n5(nor_gate,a,b);
xor n6(xor_gate,a,b);
xnor n7(xnor_gate,a,b);
endmodule
1.8 Verilog HDL Code for All Logic Gates using assign:-
endmodule
// Inputs
reg a;
reg b;
// Outputs
wire and_gate;
wire or_gate;
wire not_gate;
wire nand_gate;
wire nor_gate;
wire xor_gate;
wire xnor_gate;
// Instantiate the Unit Under Test (UUT)
logic_gates_assign uut (
.a(a),
.b(b),
.and_gate(and_gate),
.or_gate(or_gate),
.not_gate(not_gate),
.nand_gate(nand_gate),
.nor_gate(nor_gate),
.xor_gate(xor_gate),
.xnor_gate(xnor_gate)
);
initial begin
#100 a = 1'b0;b = 1'b0;
#100 a = 1'b0;b = 1'b1;
#100 a = 1'b1;b = 1'b0;
#100 a = 1'b1;b = 1'b1;
end
endmodule
2.2 Apparatus:-
1. Personal computer - 1 no
2. Xilinx ISE Simulator - Ver.14.5
2.3 Theory:-
The 74138 is commercially available 3-to-8 decoder.\
It accepts three binary inputs (A, B, C) and when enabled, provides 8 individual
active low outputs (Y0-Y7).
The device has 3-enable inputs: two active low (G2A, G2B) and one active high (G1).
Here 3 inputs are decoded into outputs, when enabled.
Each output represent one of the minterms of the 3-input variables.
1 0 X X X X X 11111111
2 1 1 X X X X 11111111
3 1 X 1 X X X 11111111
4 1 0 0 0 0 0 01111111
5 1 0 0 0 0 1 10111111
6 1 0 0 0 1 0 11011111
7 1 0 0 0 1 1 11101111
8 1 0 0 1 0 0 11110111
9 1 0 0 1 0 1 11111011
10 1 0 0 1 1 0 11111101
11 1 0 0 1 1 1 11111110
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity decoder3X8 is
port (g1, g2a_1, g2b_1 : in STD_LOGIC;
a : in STD_LOGIC_VECTOR (2 downto 0);
y_l : out STD_LOGIC_VECTOR (0 to 7));
end decoder3X8;
architecture behavioral of decoder3X8 is
begin
process (a,g1,g2a_1,g2b_1)
begin
if (g1 and not g2a_1 and not g2b_1)='1'then
if a <= "000"then y_l<= "01111111";
elsif a <= "001"then y_l <= "10111111";
elsif a <= "010"then y_l<= "11011111";
elsif a <= "011"then y_l <= "11101111";
elsif a <= "100"then y_l <= "11110111";
entity decoder_test is
end decoder_test;
--outputs
signal y : std_logic_vector(0 to 7);
begin
-- instantiate the unit under test (uut)
uut: decoder_prg port map (
a => a,
g1 => g1,
g2a=> g2a,
g2b=> g2b,
y => y);
-- stimulus process
stim_proc: process
begin
g1<='1';g2a<='1';g2b<='1';
wait for 100ns;
g1<='1';g2a<='0';g2b<='0';
VHDL code for 3 to 8 decoder 74138 in behavioral style is written and simulated
using Xilinx 14.5 version and output is observed
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mux151 is
port (I :in STD_LOGIC_VECTOR (7 downto 0);
S :in STD_LOGIC_VECTOR (2 downto 0);
en_l:in STD_LOGIC;
y :inout STD_LOGIC;
ybar :out STD_LOGIC);
end mux151;
library ieee;
use ieee.std_logic_1164.all;
entity mux8x1_tb is
end mux8x1_tb;
component mux151
port( d : in std_logic_vector(7 downto 0);
s : in std_logic_vector(2 downto 0);
en : in std_logic;
y : inout std_logic;
w : out std_logic);
end component;
--inputs
signal d:std_logic_vector(7 downto 0):=(others=>'0');
signal s:std_logic_vector(2 downto 0):=(others=>'0');
signal en : std_logic := '1';
--bidirs
signal y : std_logic;
--outputs
signal w : std_logic;
begin
-- instantiate the unit under test (uut)
uut: mux151 port map (
d => d,
s => s,
en => en,
y => y,
w => w);
VHDL code for 8x1 multiplexer 74151 in behavioral style is written and simulated
using Xilinx 14.5 version and output is observed
3.2.2 Apparatus:-
1. Personal computer - 1 no
2. Xilinx ISE Simulator - Ver.14.5
3.2.3 Theory:-
The 74155 is dual 1-line-to-4-line de-multiplexers with individual strobes.
When both sections are enabled by the strobes, the common binary address inputs
sequentially select and route associated input data to the appropriate output of each
section.
The individual strobes permit activating or inhibiting each of the 4-bit sections is
desired.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity demux is
port( c1, c2: in std_logic;
g1_l, g2_l: in std_logic;
sel: in std_logic_vector(1 downto 0);
y1, y2: out std_logic_vector(3 downto 0));
end demux;
architecture demux of demux is
begin
process( c1, c2, g1_l, g2_l, sel)
begin
y1 <= "1111"; y2<= "1111";
if( g1_l = '0') then
case sel is
when "00" => y1(0) <= c1;
when "01" => y1(1) <= c1;
when "10" => y1(2) <= c1;
when "11" => y1(3) <= c1;
library ieee;
use ieee.std_logic_1164.all;
entity demux_tb is
end demux_tb;
--inputs
signal c1 : std_logic := '0';
signal c2 : std_logic := '1';
signal g1_l : std_logic := '0';
signal g2_l : std_logic := '1';
signal sel :std_logic_vector(1 downto 0):= (others => '0');
--outputs
signal y1 : std_logic_vector(3 downto 0);
signal y2 : std_logic_vector(3 downto 0);
begin
-- stimulus process
stim_proc: process
begin
c1<='1';c2<='0';
g1_l<='1';g2_l<='0';
wait for 500 ns;
c1<='0';c2<='1';
g1_l<='0';g2_l<='1';
wait for 500 ns;
end process;
sel_pro: process
begin
sel<="00";
wait for 100 ns;
sel<="01";
wait for 100 ns;
sel<="10";
wait for 100 ns;
sel<="11";
wait for 100 ns;
end process;
end;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity comp is
port (altbin: in STD_LOGIC;
aeqbin: in STD_LOGIC;
agtbin: in STD_LOGIC;
a,b:in STD_LOGIC_VECTOR(3downto 0);
agtbout: out STD_LOGIC;
aeqbout: out STD_LOGIC;
altbout: out STD_LOGIC);
end comp;
architecture comp of comp is
begin
process(a,b,agtbin,aeqbin,altbin)
library ieee;
use ieee.std_logic_1164.all;
entity compr_tb is
end compr_tb;
component comp
port( altbin : in std_logic;
aeqbin : in std_logic;
agtbin : in std_logic;
a : in std_logic_vector(3 downto 0);
b : in std_logic_vector(3 downto 0);
agtbout : out std_logic;
aeqbout : out std_logic;
altbout : out std_logic);
end component;
--inputs
signal altbin : std_logic := '1';
signal aeqbin : std_logic := '1';
signal agtbin : std_logic := '1';
signal a :std_logic_vector (3 downto 0):= (others => '0');
signal b : std_logic_vector(3 downto 0) := (others => '0');
--outputs
signal agtbout : std_logic;
signal aeqbout : std_logic;
signal altbout : std_logic;
4.10 Result:-
VHDL code for 4bit comparator 74x85 in behavioral style is written and simulated
using Xilinx 14.5 version and output is observed
entity dff7474 is
Port (clk1,clk2: in STD_LOGIC;
clr_l1,clr_l2: in STD_LOGIC;
pr_l1,pr_l2: in STD_LOGIC;
d1,d2: in STD_LOGIC;
q1,qbar1: out STD_LOGIC;
q2,qbar2 : out STD_LOGIC);
end dff7474;
architecture Behavioral of dff7474 is
begin
p1: process (clk1, clr_l1, pr_l1, d1)
begin
if (pr_l1 ='0' and clr_l1 ='0') then
q1<= '1'; qbar1 <= '1';
elsif (pr_l1 = '0') then
q1<= '1'; qbar1 <= '0';
elsif (clr_l1 = '0') then
entity tb_2 is
end tb_2;
--inputs
--outputs
signal q1 : std_logic;
signal qbar1 : std_logic;
signal q2 : std_logic;
signal qbar2 : std_logic;
begin
clk2_process :process
begin
clk2 <= '1';
wait for clk2_period/2;
-- stimulus process
data_proc: process
begin
d1<='1','0' after 500 ns;
wait for 500 ns;
d2<='1','0' after 500 ns;
wait for 500 ns;
end process;
clear_proc: process
begin
clr_l1<='1','0' after 250 ns;
wait for 250 ns;
clr_l2<='1','0' after 250 ns;
wait for 250 ns;
end process;
preset_proc: process
begin
pr_l1<='1','0' after 250 ns;
wait for 250 ns;
pr_l2<='1','0' after 250 ns;
wait for 250 ns;
end process;
end;
5.10 Result:-
VHDL code for D-flip flop- 7474 in behavioral style is written and simulated using
Xilinx 14.5 version and output is observed
6.2 Apparatus:-
1. Personal computer - 1 no
2. Xilinx ISE Simulator - Ver.14.5
6.3 Theory:
Each of these monolithic counters contains four master slave flip-flops and additional
gating to provide a divide-by two counter and a three-stage binary counter for which
the count cycle length is divide-by-five for the DM74LS90.
All of these counters have a gated zero reset and the DM74LS90 also has gated set-to-
nine inputs for use in BCD nine’s complement applications.
To use their maximum count length (decade or four bit binary), the B input is
connected to the QA output.
The input count pulses are applied to input A and the outputs are as described in the
appropriate truth table.
A symmetrical divide-by-ten count can be obtained from the DM74LS90 counters by
connecting the QD output to the A input and applying the input count to the B input
which gives a divide-by-ten square wave at output QA.
entity tb is
end tb;
architecture behavior of tb is
--inputs
signal clk : std_logic := '1';
signal r0_1 : std_logic := '1';
signal r0_2 : std_logic := '0';
signal r9_1 : std_logic := '1';
signal r9_2 : std_logic := '0';
--outputs
signal q : std_logic_vector(3 downto 0);
begin
-- stimulus process
stim_proc: process
begin
r0_1<='0';r0_2<='0';r9_1<='1';r9_2<='1';
wait for 100 ns;
r0_1<='1';r0_2<='1';r9_1<='0';r9_2<='0';
wait for 100 ns;
r0_1<='0';r0_2<='1';r9_1<='0';r9_2<='0';
wait ;
end process;
end;
6.9 Output Waveform:-
The counter contains four master slave flip-flops and additional gating to provide a
divide-by two counter and a three-stage binary counter for which the count cycle
length is divide-by-eight for the 93A.
All of these counters have a gated zero reset.
To use their maximum count length (decade or four-bit binary), the B input is
connected to the QA output.
The input count pulses are applied to input A and the outputs are as described in the
appropriate truth table.
A symmetrical divide-by-ten count can be obtained from the 90A counters by
connecting the QD output to the A input and applying the input count to the B input
which gives a divide-by-ten square wave at output QA.
entity counter is
Port ( r0_1,r0_2,clk : in STD_LOGIC;
q : out STD_LOGIC_VECTOR (3 downto 0));
end counter;
entity tb is
end tb;
architecture behavior of tb is
component counter
port( r0_1 : in std_logic;
r0_2 : in std_logic;
clk : in std_logic;
q : out std_logic_vector(3 downto 0));
end component;
--inputs
signal r0_1 : std_logic := '1';
signal r0_2 : std_logic := '1';
signal clk : std_logic := '0';
--outputs
signal q : std_logic_vector(3 downto 0);
--clock period definitions
constant clk_period : time := 50 ns;
begin
-- instantiate the unit under test (uut)
uut: counter
port map (r0_1 => r0_1,
r0_2 => r0_2,
clk => clk,
q => q);
-- clock process definitions
clk_process :process
-- stimulus process
stim_proc: process
begin
wait for 100 ns;
r0_1 <= '0';r0_2 <= '0';
wait ;
end process;end;
7.10 Result:-
VHDL code for 4-Bit binary counter (IC7493) in behavioral style is written and
simulated using Xilinx 14.5 version and output is observed
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity shift_register_7495 is
Port ( clk1,clk2 : in STD_LOGIC;
m_s,sd : in STD_LOGIC;
d : in STD_LOGIC_VECTOR (3 downto 0);
q : inout STD_LOGIC_VECTOR (3 downto 0));
end shift_register_7495;
library ieee;
use ieee.std_logic_1164.all;
entity shift_register_tb is
end shift_register_tb;
--inputs
signal clk1 : std_logic := '0';
signal clk2 : std_logic := '0';
signal m_s : std_logic := '0';
signal sd : std_logic := '0';
signal d : std_logic_vector(3 downto 0):=(others => '0');
--bidirs
signal q : std_logic_vector(3 downto 0);
-- clock period definitions
constant clk1_period : time := 50 ns;
constant clk2_period : time := 50 ns;
begin
-- instantiate the unit under test (uut)
uut: shift_register_7495 port map (
clk1 => clk1,
clk2 => clk2,
m_s => m_s,
sd => sd,
8.10 Result:-
VHDL code for Shift Register (IC7495) in behavioral style is written and simulated
using Xilinx 14.5 version and output is observed
9.2 Apparatus:-
1. Personal computer - 1 no
2. Xilinx ISE Simulator - Ver.14.5
9.3 Theory:-
The 74194 is a bi-directional shift registers contains parallel inputs, parallel outputs,
right-shift and left-shift serial inputs, operating mode control inputs and a direct
overriding clear line.
The register has 4-distict mode of operations.
i. Inhibit Clock (do nothing)
ii. Shift Right (in the direction QA toward QD)
iii. Shift Left (in the direction QD toward QA)
iv. Parallel (broad side) load
Parallel Load is accomplished by applying the 4-bits of data and taking both mode
control inputs (S0, S1) high. The data are loaded in to the associated flip flops and
appear at the output after positive transition of the clock inputs. During loading, serial
data flow is inhibited.
Shift right is accomplished with the raising edge of the clock pulse when S0 I s high
and S1 is low. Serial data for this mode is entered at the shift –right data input. When
S0 is low and S1 is high, at shifts left and new data is entered at the shift-left serial
input.
Clocking of the Shift Register is inhibited when both modes control inputs are low.
The mode controls of 74194 should be changed while the clock input is high.
library IEEE;
use IEEE.std_logic_1164.all;
entity shift194 is
port (clk : in STD_LOGIC;
dsr,dsl : in STD_LOGIC;
clr_l : in STD_LOGIC;
S:in STD_LOGIC_VECTOR(1 downto 0);
d: in STD_LOGIC_VECTOR (3 downto 0);
q: inout STD_LOGIC_VECTOR (3 downto 0));
end shift194;
entity shift194_tb is
end shift194_tb;
component shift194
port(clk : in std_logic;
dsr : in std_logic;
dsl : in std_logic;
clr_l : in std_logic;
s : in std_logic_vector(1 downto 0);
d : in std_logic_vector(3 downto 0);
q : inout std_logic_vector(3 downto 0));
end component;
--inputs
signal clk : std_logic := '0';
signal dsr : std_logic := '0';
signal dsl : std_logic := '0';
signal clr_l : std_logic := '0';
signal s: std_logic_vector(1 downto 0):= (others => '1');
signal d : std_logic_vector(3 downto 0) := (others => '1');
--bidirs
signal q : std_logic_vector(3 downto 0);
sel_proc: process
begin
s<="00";wait for 250 ns;
s<="01";wait for 250 ns;
s<="10";wait for 250 ns;
s<="11";wait for 250 ns;
end process;
data_proc: process
begin
wait for 200 ns;
d<="1101";clr_l<='1';dsr<='1';dsl<='1';
wait for 200 ns;
d<="1001";clr_l<='1';dsr<='0';dsl<='1';
wait for 200 ns;
d<="0101";clr_l<='1';dsr<='1';dsl<='0';
wait for 200 ns;
d<="0111";clr_l<='1';dsr<='0';dsl<='0';
wait for 200 ns;
end process;
end;
9.10 Result:-
VHDL code for Universal shift register in behavioral style is written and simulated
using Xilinx 14.5 version and output is observed
10.2 Apparatus:-
1. Personal computer - 1 no
2. Xilinx ISE Simulator - Ver.14.5
10.3 Theory:
The behavior of the 74189 circuit is controlled by just two active-low control lines,
namely the chip select and read/write inputs:
CS=1: the data outputs are tri-stated and the clock signal for the latches in the
memory matrix is disabled.
CS=0, Read/nWrite=1: the data outputs are enabled and driven with the contents of
the currently addressed memory word. When the address input is changed, the
contents of the newly selected memory word will appear on the data outputs, delayed
by the memory access time.
CS=0, Read/nWrite=0: the clock signal of the currently addressed memory latches is
enabled, so that the values on the data input bus is copied into the selected memory
word (transparent latches). Also, the data outputs are enabled. Switch the Read/nWrite
signal back to the high (1) state to store the data.
10.7 VHDL Code for RAM (74189) Read & Write Operation:-
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity dm74189 is
port (a: in std_logic_vector (3 downto 0);
d: in std_logic_vector (3 downto 0);
cs_bar : in std_logic;
we_bar : in std_logic;
q: out std_logic_vector (3 downto 0));
end dm74189;
write: process(cs_bar,we_bar,a,d)
begin
library ieee;
use ieee.std_logic_1164.all;
entity ram_tb is
end ram_tb;
component dm74189
port(a : in std_logic_vector(3 downto 0);
d : in std_logic_vector(3 downto 0);
cs_bar : in std_logic;
we_bar : in std_logic;
q : out std_logic_vector(3 downto 0));
end component;
--inputs
signal a : std_logic_vector(3 downto 0) := (others => '0');
signal d : std_logic_vector(3 downto 0) := (others => '0');
signal cs_bar : std_logic := '0';
signal we_bar : std_logic := '0';
--outputs
signal q : std_logic_vector(3 downto 0);
begin
-- stimulus process
data_proc: process
begin
wait for 100 ns;
a<="1010";d<="1111";
wait for 100 ns;
a<="1110";d<="1001";
wait for 100 ns;
a<="1011";d<="1000";
wait for 100 ns;
end process;
read_write_proc: process
begin
wait for 500 ns;
we_bar<='1';
wait;
end process;
end;
10.10 Result:-
VHDL code for Read and Write operation of RAM is written and simulated using Xilinx
14.5 version and output is observed
1. Personal computer - 1 no
2. Xilinx ISE Simulator - Ver.14.5
11.3 ALU Operation:-
The 'F381 performs three arithmetic and three logic operations on two 4-bit
words, A and B. Two additional select input codes force the function outputs LOW or HIGH.
Carry propagate and generate outputs are provided for use with the 'F182 carry look ahead
generator for high-speed expansion to longer word lengths.
Features
Low input loading minimizes drive requirements
Performs six arithmetic and logic functions
Selectable LOW (clear) and HIGH (preset) functions
Carry generate and propagate outputs for use with carry.
library ieee;
use ieee.std_logic_1164.all;
entity alu_tb is
end alu_tb;
component ic74381
port(a : in std_logic_vector(3 downto 0);
b : in std_logic_vector(3 downto 0);
s : in std_logic_vector(2 downto 0);
cin : in std_logic;
f : out std_logic_vector(3 downto 0));
end component;
--inputs
signal a : std_logic_vector(3 downto 0) := (others => '0');
signal b : std_logic_vector(3 downto 0) := (others => '0');
signal s : std_logic_vector(2 downto 0) := (others => '0');
signal cin : std_logic := '0';
--outputs
signal f : std_logic_vector(3 downto 0);
begin
-- instantiate the unit under test (uut)
uut: ic74381 port map ( a => a,
b => b,
s => s,
cin => cin,
f => f );
-- stimulus process
input_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
a<="0000";b<="0001";cin<='1';
wait for 100 ns;
a<="0010";b<="0101";cin<='0';
wait for 100 ns;
a<="1001";b<="1001";cin<='1';
wait for 100 ns;
a<="1110";b<="1111";cin<='1';
wait for 100 ns;
end process;
11.10 Result:-
VHDL code for ALU in behavioral style is written and simulated using Xilinx 14.5
version and output is observed