AP Lab 9
AP Lab 9
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Lab 9 - 191b130</title>
<script src="callback.js"></script>
<script src="promise.js"></script>
<script src="asyawait.js"></script>
</head>
<body id="body">
</body>
</html>
Callback.js-----
selectedColor = 0;
setTimeout(async () => {
console.log(thisNum)
document.getElementById('body').style.backgroundColor = "red";
if(selectedColor > 4) {
window.alert('ended');
return;
document.getElementById('body').style.backgroundColor = colors[selectedColor++]
startCallback();
else {
}, 1500);
Promise.js------------
selectedColor1 = 0;
timeFunction.then((val)=>{
console.log(thisNum)
document.getElementById('body').style.backgroundColor = "red";
if(selectedColor > 4) {
window.alert('ended');
return;
document.getElementById('body').style.backgroundColor = colors1[selectedColor1++]
startCallback();
}
else {
}})}
Method 2:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Lab 9 - 191b130</title>
<script src="callback.js"></script>
<script src="promise.js"></script>
<script src="asyawait.js"></script>
</head>
<body id="body">
</body>
</html>
Callback.js-----
selectedColor = 0;
setTimeout(async () => {
console.log(thisNum)
document.getElementById('body').style.backgroundColor = "red";
if(selectedColor > 4) {
window.alert('ended');
return;
document.getElementById('body').style.backgroundColor = colors[selectedColor++]
startCallback();
else {
}, 1500);
Promise.js------------
selectedColor1 = 0;
timeFunction.then((val)=>{
console.log(thisNum)
document.getElementById('body').style.backgroundColor = "red";
if(selectedColor > 4) {
window.alert('ended');
return;
document.getElementById('body').style.backgroundColor = colors1[selectedColor1++]
startCallback();
}
else {
}})}
LAB5_1
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 12:40:39 04/05/2022
-- Design Name:
-- Module Name: Lab5_1 - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Lab5_1 is
generic (N: integer := 4);
Port ( r1 : in STD_LOGIC_VECTOR (N-1 downto 0);
r2 : in STD_LOGIC_VECTOR (N-1 downto 0);
r3 : in STD_LOGIC_VECTOR (N-1 downto 0);
r4 : in STD_LOGIC_VECTOR (N-1 downto 0);
s : in STD_LOGIC_VECTOR (1 downto 0);
o : out STD_LOGIC_VECTOR (N-1 downto 0));
end Lab5_1;
component fourtoone is
Port ( i0 : in STD_LOGIC;
i1 : in STD_LOGIC;
i2 : in STD_LOGIC;
i3 : in STD_LOGIC;
s0 : in STD_LOGIC;
s1 : in STD_LOGIC;
o : out STD_LOGIC);
end component;
begin
end Behavioral;
TEST BENCH
BEGIN
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
r1<="0000";
r2<="0011";
r3<="1100";
r4<="1111";
s<="00";
wait for 100 ns;
r1<="0000";
r2<="0011";
r3<="1100";
r4<="1111";
s<="01";
wait for 100 ns;
r1<="0000";
r2<="0011";
r3<="1100";
r4<="1111";
s<="10";
wait for 100 ns;
r1<="0000";
r2<="0011";
r3<="1100";
r4<="1111";
s<="11";
wait for 100 ns;
wait;
end process;
END;
Lab5_2
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 09:49:18 05/02/2022
-- Design Name:
-- Module Name: Lab5_2 - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Lab5_2 is
generic (N: integer := 4);
Port ( a : in STD_LOGIC_VECTOR (N-1 downto 0);
b : in STD_LOGIC_VECTOR (N-1 downto 0);
s : in STD_LOGIC_VECTOR (1 downto 0);
o : out STD_LOGIC_VECTOR (N-1 downto 0));
end Lab5_2;
begin
end Behavioral;
TEST BENCH
BEGIN
-- Stimulus process
stim_proc: process
begin
a<="0000";
b<="1100";
s<="00";
wait for 100 ns;
s<="01";
wait for 100 ns;
s<="10";
wait for 100 ns;
s<="11";
wait for 100 ns;
wait;
end process;
END;
Lab 5_3
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 10:15:21 05/02/2022
-- Design Name:
-- Module Name: Lab5_3 - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Lab5_3 is
generic (N: integer := 4);
Port ( a : in STD_LOGIC_VECTOR (N-1 downto 0);
b : in STD_LOGIC_VECTOR (N-1 downto 0);
s : in STD_LOGIC_VECTOR (1 downto 0);
o : out STD_LOGIC_VECTOR (N-1 downto 0));
end Lab5_3;
begin
process(a,b,s)
begin
if(s="00") then
o<= (b(n-2 downto 0) & '0');
elsif(s="01") then
o<= (a(n-1) & a(n-1 downto 1));
elsif(s="10") then
o<= (b(0) & b(n-1 downto 1));
elsif(s="11") then
o<= (a(n-2 downto 0) & a(n-1));
end if;
end process;
end Behavioral;
Test Bench
begin
a<="0011";
b<="1100";
s<="00";
wait for 100 ns;
s<="01";
wait for 100 ns;
s<="10";
wait for 100 ns;
s<="11";
wait for 100 ns;
wait;
end process;