Asynchronous Down Counter OBJECTIVE: To Design and Simulate The Asynchronous Down Counter
Asynchronous Down Counter OBJECTIVE: To Design and Simulate The Asynchronous Down Counter
Asynchronous Down Counter OBJECTIVE: To Design and Simulate The Asynchronous Down Counter
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity asyndn is
Port ( t : in STD_LOGIC;
clk : in STD_LOGIC;
q : inout STD_LOGIC_VECTOR (3 downto 0);
qbar : inout STD_LOGIC_VECTOR (3 downto 0));
end asyndn;
component tff is
Port ( t : in STD_LOGIC;
clk : in STD_LOGIC;
q : inout STD_LOGIC :='1';
qbar : inout STD_LOGIC :='0');
end component;
begin
tff1:tff port map('1',clk,q(0),qbar(0));
tff2:tff port map('1',qbar(0),q(1),qbar(1));
tff3:tff port map('1',qbar(1),q(2),qbar(2));
tff4:tff port map('1',qbar(2),q(3),qbar(3));
end Behavioral;
ASYNCHRONOUS COUNTER
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity asyn is
Port ( t : in STD_LOGIC;
clk : in STD_LOGIC;
q : inout STD_LOGIC_VECTOR (3 downto 0);
qbar : inout STD_LOGIC_VECTOR (3 downto 0));
end asyn;
component tff is
Port ( t : in STD_LOGIC;
clk : in STD_LOGIC;
q : inout STD_LOGIC :='1';
qbar : inout STD_LOGIC :='0');
end component;
begin
end Behavioral;
8.BCD TO EXCESS-3
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity bcdexcess3 is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
d : in STD_LOGIC;
x : out STD_LOGIC;
y : out STD_LOGIC;
z : out STD_LOGIC;
w : out STD_LOGIC);
end bcdexcess3;
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity bcd2gray is
Port ( b3 : in STD_LOGIC;
b2 : in STD_LOGIC;
b1 : in STD_LOGIC;
b0 : in STD_LOGIC;
g3 : out STD_LOGIC;
g2 : out STD_LOGIC;
g1 : out STD_LOGIC;
g0 : out STD_LOGIC);
end bcd2gray;
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity bit4adder is
Port ( a : in STD_LOGIC_VECTOR (3 downto 0);
b : in STD_LOGIC_VECTOR (3 downto 0);
cin : in STD_LOGIC;
sum : out STD_LOGIC_VECTOR (3 downto 0);
cout : out STD_LOGIC);
end bit4adder;
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity bit8add is
Port ( a : in STD_LOGIC_VECTOR (7 downto 0);
b : in STD_LOGIC_VECTOR (7 downto 0);
cin : in STD_LOGIC;
sum : out STD_LOGIC_VECTOR (7 downto 0);
cout : out STD_LOGIC);
end bit8add;
architecture Behavioral of bit8add is
component fa is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
s : out STD_LOGIC;
car : out STD_LOGIC);
end component;
signal c1,c2,c3,c4,c5,c6,c7:std_logic;
begin
fa1:fa port map(a(0),b(0),cin,sum(0),c1);
fa2:fa port map(a(1),b(1),c1,sum(1),c2);
fa3:fa port map(a(2),b(2),c2,sum(2),c3);
fa4:fa port map(a(3),b(3),c3,sum(3),c4);
fa5:fa port map(a(4),b(4),c4,sum(4),c5);
fa6:fa port map(a(5),b(5),c5,sum(5),c6);
fa7:fa port map(a(6),b(6),c6,sum(6),c7);
fa8:fa port map(a(7),b(7),c7,sum(7),cout);
end Behavioral;
6.3X8 DECODER
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity dec3x8 is
Port ( a : in STD_LOGIC_VECTOR (2 downto 0);
en : in STD_LOGIC;
y : out STD_LOGIC_VECTOR (7 downto 0));
end dec3x8;
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity dec4x16 is
Port ( a : in STD_LOGIC_VECTOR (2 downto 0);
enable : in STD_LOGIC;
y : out STD_LOGIC_VECTOR (15 downto 0));
end dec4x16;
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity deccounter is
Port ( j : in STD_LOGIC;
k : in STD_LOGIC;
clk : in STD_LOGIC;
q : inout STD_LOGIC_VECTOR (3 downto 0);
qbar : inout STD_LOGIC_VECTOR (3 downto 0));
end deccounter;
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity dflop is
Generic( td_reset, td_in: time:=8ns);
Port ( reset : in STD_LOGIC;
din : in STD_LOGIC;
clk : in STD_LOGIC;
qout : buffer STD_LOGIC :='0');
end dflop;
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity ha is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
s : out STD_LOGIC;
car : out STD_LOGIC);
end ha;
architecture Behavioral of ha is
begin
s<=a xor b;
car<= a and b;
end Behavioral;
JK FLIP FLOP
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mux4x1 is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
d : in STD_LOGIC;
sel : in STD_LOGIC_VECTOR (1 downto 0);
y : out STD_LOGIC);
end mux4x1;
begin
process(a,b,c,d,sel)
variable temp:std_logic;
begin
case sel is
when "00"=>temp:=a;
when "01"=>temp:=b;
when "10"=>temp:=c;
when others=>temp:=d;
end case;
y<=temp;
end process;
end Behavioral;
SYNCHRONOUS COUNTER
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity syncntr is
Port ( t : in STD_LOGIC;
clk : in STD_LOGIC;
q : inout STD_LOGIC_VECTOR (3 downto 0);
qbar : inout STD_LOGIC_VECTOR (3 downto 0));
end syncntr;
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity tff is
Port ( t : in STD_LOGIC;
clk : in STD_LOGIC;
q : inout STD_LOGIC :='1';
qbar : inout STD_LOGIC :='0');
end tff;
UP DOWN COUNTER
OBJECTIVE: To Design and Simulate the up down counter.
VHDL CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity updncntr is
Port ( t : in STD_LOGIC;
clk : in STD_LOGIC;
up:in STD_LOGIC;
dn:in STD_LOGIC;
q : inout STD_LOGIC_VECTOR (3 downto 0);
qbar : inout STD_LOGIC_VECTOR (3 downto 0));
end updncntr;
end bincount;
--//decade counter 7490
library ieee;
use ieee.std_logic_1164.all;
entity ic7490 is
port(clk,s1,s2,r1,r2:in std_logic;
q1,q2,q3,q4:out std_logic);
end ic7490;
signal se,cl,q11,q22,q33,q44:std_logic;
signal one,qb44,q55:std_logic;
begin
one <= '1';
se <= not(s1 and s2);
qb44<=not(q44);
q55<=q22 and q33;
cl <= not(r1 and r2);q1<=q11;q2<=q22;q3<=q33;q4<=q44;
u1 : jkff port map ( one,one,clk,se,cl,q11 ) ;
u2 : jkff port map ( qb44,one,q11,se,cl,q22 ) ;
u3 : jkff port map ( one,one,q22,se,cl,q33 ) ;
u4 : rsff port map ( q44,q55,q11,se,cl,q44 ) ;
end decount;
signal da,db,dc,dd,clkbar:std_logic;
signal dba,dbb,dbc,dbd,one:std_logic;
begin
one <= '1';
clkbar <= not(clbar and clk);
da<= not((sh_ld and j and not(qa))or(sh_ld and kbar and
qa)or(not(sh_ld) and a));
db<= not((sh_ld and qa)or(not(sh_ld) and b));
dc<= not((sh_ld and qb)or(not(sh_ld) and c));
dd<= not((sh_ld and qc)or(not(sh_ld) and d));
qdbar<=not(qd);dba<=not(da);dbb<=not(db);dbc<=not(dc);dbd<=not(dd);
u1 : rsff port map ( da,dba,clkbar,one,clbar,qa ) ;
u2 : rsff port map ( db,dbb,clkbar,one,clbar,qb ) ;
u3 : rsff port map ( dc,dbc,clkbar,one,clbar,qc ) ;
u4 : rsff port map ( dd,dbd,clkbar,one,clbar,qd ) ;
end unisftrg;