Professional Documents
Culture Documents
Expt No.:1 Batch: B4 Roll No.:404B070
Expt No.:1 Batch: B4 Roll No.:404B070
Expt No.:1
Batch: B4
Roll No.:404B070
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity alu_4bit is
Port ( a,b : in std_logic_vector(3 downto 0);
m : in std_logic_vector(2 downto 0);
z : out std_logic_vector(3 downto 0);
c : out std_logic );
end alu_4bit;
begin
process(a,b,m)
variable t : std_logic_vector(4 downto 0);
begin
end Behavioral;
=================================USR=============================
Expt No.:2
Batch: B4
Roll No.:404B070
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity universal_sr is
Port ( clk,rst : in std_logic;
s : in std_logic_vector(3 downto 0);
m : in std_logic_vector(1 downto 0);
y : out std_logic_vector(3 downto 0));
end universal_sr;
process(clk,rst)
begin
if rst='1' then
y <= "0000";
elsif clk'event and clk ='1' then
case(m) is
when "00" => --SISO
t(3) <= s(0);
t(2) <= t(3);
t(1) <= t(2);
t(0) <= t(1);
y(0) <= t(0);
end case;
end if;
end process;
end Behavioral;
============================LCD=============================
Expt No.:3
Batch: B4
Roll No.:404B070
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity lcd_fsm is
Port ( clk,rst : in std_logic;
data : out std_logic_vector(7 downto 0);
rw,rs,en : out std_logic);
end lcd_fsm;
char0_1,char1_1,char0_2,char1_2,char0_3,char1_3,char0_4,char1_4);
signal pstate,nstate : tstate;
begin
clk_div: process(clk,rst)
begin
if rst = '1' then
cntr <= (others => '0');
elsif clk'event and clk = '1' then
cntr <= cntr + '1';
end if;
end process;
mem_element: process(cntr(19),rst)
begin
if rst = '1' then
pstate <=res_state;
elsif cntr(19)'event and cntr(19) = '1' then
pstate <= nstate;
end if;
end process;
next_st: process(pstate)
begin
case pstate is
when res_state =>
rw <= '0';
rs <= '0';
en <= '0';
nstate <= cwd0_1;
data <= "00111100";
when cwd0_1 =>
rw <= '0';
rs <= '0';
en <= '1'; ---- enable high
nstate <= cwd1_1;
data <= "00111100"; ----3CH first line first char
end case;
end process;
end Behavioral;
============================keypad============================
Expt No.:4
Batch: B4
Roll No.:404B070
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity keypad is
Port ( clk,rst : in std_logic;
row,sw : in std_logic_vector(3 downto 0);
col,seg_ctrl : out std_logic_vector(3 downto 0);
display : out std_logic_vector(6 downto 0));
end keypad;
begin
P1: process(clk,rst)
begin
if rst='1' then
count <= (others => '0');
elsif (clk'event and clk='1') then
count <= count+1;
end if;
end process;
clk1 <= count(10);
P2: process(clk1,rst)
begin
if rst='0' then
display <= "0000000";
elsif clk1'event and clk1='1' then
temp <= temp+1;
seg_ctrl <= sw;
case temp is
when "000" => col <="1110";
end Behavioral;