EXOR Gate Using Concurrent Statements: RTL View
EXOR Gate Using Concurrent Statements: RTL View
EXOR Gate Using Concurrent Statements: RTL View
VHDL CODE
library ieee;
use ieee.std_logic_1164.all;
entity xor1 is
port (a,b:in std_logic; c: out std_logic);
end xor1;
architecture xyz of xor1 is
begin
c<= a xor b;
end xyz;
RTL VIEW
COMPILATION REPORT
RTL VIEW
COMPILATION REPORT
RECORDS
VHDL CODE
library ieee;
use ieee.std_logic_1164.all;
entity sum1 is
end sum1;
architecture abc of sum1 is
type data_date is record
year:integer range 1989 to 1999;
month:integer range 1 to 12;
date: integer range 1 to 31;
hour:integer range 0 to 23;
minute:integer range 0 to 59;
second:integer range 0 to 59;
end record;
signal a:data_date;
begin
a.year<=1990;
a.month<=10;
a.date<=24;
end;
FULL ADDER
VHDL CODE
library ieee;
use ieee.std_logic_1164.all;
entity full_adder is
port(a,b,cin : in std_logic; sum ,cout : out std_logic);
end full_adder;
architecture abc of full_adder is
begin
sum<=a xor b xor cin;
cout<= (a and b)or(b and cin)or(a and cin);
end abc;
RTL VIEW
COMPILATION REPORT
entity halfadder is
port( a,b : in bit; sum, carry : out bit);
end halfadder;
architecture abc of halfadder is
begin
process(a,b)
begin
if(a='0' and b='0') then
sum <='0';
carry <='0';
elsif (a='0' and b='1') then
sum <='1';
carry <= '0';
elsif(a='1' and b='0') then
sum <='1';
carry <= '0';
entity or1 is
port( in1,in2 : in bit; out1: out bit);
end or1;
architecture xyz of or1 is
begin
out1<= in1 OR in2;
end xyz;
RTL VIEW
COMPILATION REPORT
RTL VIEW
COMPILATION REPORT
RTL VIEW
COMPILATION REPORT
MATHEMATICAL OPERATIONS
VHDL CODE
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity maths is
port(a,b:in integer; c,d,e,f,g,h:out integer);
end maths;
architecture abc of maths is
begin
c <= a + b;
d<=a-b;
e<=a*b;
f<=a/b;
g<=a mod b;
h<=a rem b;
end abc;
RTL VIEW
COMPILATION REPORT
if sel="00" then
y<=a;
elsif (sel="01") then
y<=b;
elsif (sel="10") then
y<=c;
else
y<=d;
end if;
else
y<='-';
end if;
end process;
end abc;
RTL VIEW
COMPILATION REPORT
VHDL CODE
--mux using case statement
library ieee;
use ieee.std_logic_1164.all;
entity mux_case is
port(a: in bit_vector(3 downto 0); en : in bit; sel: in bit_vector(1 downto 0);
b: out bit);
end mux_case;
architecture abc of mux_case is
begin
process(en, sel)
begin
if en='1' then
case sel is
when "00" => b<= a(0);
when "01" => b<= a(1);
when "10" => b<= a(2);
when "11" => b<= a(3);
end case;
else
b<='0';
end if;
end process;
end abc;
RTL VIEW
COMPILATION REPORT
VHDL CODE
library ieee;
use ieee.std_logic_1164.all;
entity mux_conditional is
port (a,b,c,d : in std_logic ; s: in bit_vector(1 downto 0);y : out std_logic);
end mux_conditional;
architecture abc of mux_conditional is
begin
y<= a when s ="00" else
b when s ="01" else
c when s ="10" else
d ;
end abc;
RTL VIEW
COMPILATION REPORT
COMPILATION REPORT
SHIFT OPERATIONS
VHDL CODE
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.numeric_std.all;
entity operations is
port(a:in bit_vector(3 downto 0);p,q,r,s,t,u:out bit_vector(3 downto 0));
end operations;
architecture xyz of operations is
begin
p<= a sll 1;
q<= a srl 1;
r<= a sla 1;
s<= a sra 1;
t<= a rol 1;
u<= a ror 1;
end xyz;
RTL VIEW
COMPILATION REPORT
SUBTRACTOR
VHDL CODE
library ieee;
use ieee.std_logic_1164.all;
entity subtractor is
port(a : in bit_vector(1 downto 0); diff , borr : out std_logic);
end subtractor;
architecture abc of subtractor is
begin
process(a)
begin
case a is
when "00"=> diff<= '0';
when "01"=> diff<= '1';
when "10"=> diff<= '1';
when "11"=> diff<= '0';
end case;
if a="01" then
borr <='1';
else
borr <='0';
end if;
end process;
end abc;
RTL VIEW
COMPILATION REPORT
begin
process(a)
variable b : std_logic;
variable d : std_logic_vector (3 downto 0);
begin
d := a;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee. std_logic_arith.all;
entity practice is
port ( a,b: in integer; mul, div: out integer);
end practice;
architecture abc of practice is
function multiply(x,y: in integer)
return integer is
variable result: integer;
begin
result := x*y;
return result;
end multiply;
function divide(x,y: in integer)
return integer is
variable result: integer;
begin
result := x/y;
return result;
end divide;
begin
mul <= multiply(a,b);
div <= divide(a,b);
end abc;