Professional Documents
Culture Documents
TugasLab1a - Ichsan Harun Wicaksono - 195060307111011
TugasLab1a - Ichsan Harun Wicaksono - 195060307111011
NIM : 195060307111011
Persamaan logika : 𝒎 = ( 𝒙 • 𝒔
̅) + (𝒔 • 𝒚)
Tabel kebenaran :
x y s 𝒙 • 𝒔̅ 𝒔 • 𝒚 m
0 0 0 0 0 0
0 0 1 0 0 0
1 0 0 1 0 1
1 0 1 0 0 0
0 1 0 0 0 0
0 1 1 0 1 1
Design
library IEEE;
use IEEE.std_logic_1164.all;
library IEEE;
use IEEE.std_logic_1164.all;
Test Bench
library IEEE;
use IEEE.std_logic_1164.all;
entity tb_mux is
end tb_mux;
architecture df_tb_mux of tb_mux is
component mux is port(
x, y, s : IN std_logic;
m : OUT std_logic
);
end component;
begin
process
begin
wait;
end process;
END df_tb_mux;
HASIL
ANALISIS
X y S M
0 0 0 0
1 0 0 1
0 1 0 0
0 0 1 1
1 0 1 0
0 1 1 0
1 1 0 1
1 1 1 1
Design.vhd
library IEEE;
use IEEE.std_logic_1164.all;
Testbench.vhd
library IEEE;
use IEEE.std_logic_1164.all;
entity or_gate2_tb is
end or_gate2_tb;
architecture tb of or_gate2_tb is
begin
process
begin
wait for 10 ns; x_in <= "11"; s_in <= '0'; y_in <= "10";
wait for 10 ns; x_in <= "10"; s_in <= '1'; y_in <= "01";
wait for 10 ns; x_in <= "01"; s_in <= '0'; y_in <= "00";
wait for 10 ns; x_in <= "11"; s_in <= '1'; y_in <= "00";
wait for 10 ns; x_in <= "01"; s_in <= '1'; y_in <= "11";
wait for 10 ns; x_in <= "00"; s_in <= '0'; y_in <= "10";
wait;
end process;
end tb;
HASIL
ANALISIS
Tabel keluaran
x s Y m
00 0 00 00
11 0 10 11
10 1 01 01
01 0 00 01
11 1 00 00
01 1 11 11
Design.vhd
library IEEE;
use IEEE.std_logic_1164.all;
library IEEE;
use IEEE.std_logic_1164.all;
begin
mux_1: mux_1bit port map(
a => x(0),
b => y(0),
c => s,
d => m(0)
);
mux_2: mux_1bit port map(
a=> x(1),
b=> y(1),
c=> s,
d=> m(1)
);
Testbench.vhd
library IEEE;
use IEEE.std_logic_1164.all;
Entity testbench is
end testbench;
begin
dut: muxfull PORT MAP (
x => x_int,
y => y_int,
s => s_int,
m => m_int );
process
begin
x_int <= "10"; y_int <= "01"; s_int <= '0'; wait for 10 ns;
x_int <= "11"; y_int <= "01"; s_int <= '1'; wait for 10 ns;
x_int <= "01"; y_int <= "00"; s_int <= '0'; wait for 10 ns;
x_int <= "00"; y_int <= "11"; s_int <= '1'; wait for 10 ns;
wait;
end process;
end multiplexer;
HASIL
ANALISIS
Tabel keluaran
x S Y M
10 0 01 10
11 1 01 01
01 0 00 01
00 1 11 11
Jika s = 0 maka m = x
Jika s = 1 maka m = y
Tabel kebenaran:
x_in y_in S m
0 1 0 0
0 1 1 1
Design.vhd
library ieee;
use ieee.std_logic_1164.all;
entity mux is
port( x, y, s : in std_logic;
m : out std_logic);
end mux;
architecture behavioral of mux is
begin
process (x, y, s) is
begin
if (s = '0') then
m <= x;
else
m<= y;
end if;
end process;
end architecture behavioral;
Testbench.vhd
library IEEE;
use IEEE.std_logic_1164.all;
entity testbench is
end testbench;
component mux is
port(
x: in std_logic;
y: in std_logic;
s: in std_logic;
m: out std_logic);
end component;
Process
begin
x_in <= '0'; y_in <= '1'; s_in <= '0'; wait for 15 ns;
x_in <= '0'; y_in <= '1'; s_in <= '1'; wait for 15 ns;
wait;
end process;
end behavioral;
HASIL
ANALISIS
x Y S M
0 1 0 0
0 1 1 1
Persamaan logikanya :
Jika s = 0 maka m = x
Jika s = 1 maka m = y
Tabel kebenarannya :
x_in y_in S m
00 01 0 00
11 10 1 10
Design.vhd
library IEEE;
use IEEE.std_logic_1164.all;
entity mux is port(
x : in std_logic_vector (1 downto 0);
y : in std_logic_vector (1 downto 0);
s : in std_logic;
m : out std_logic_vector (1 downto 0)
);
end mux;
Testbench.vhd
library IEEE;
use IEEE.std_logic_1164.all;
entity tb_mux is
end tb_mux;
x => x_in,
y => y_in,
s => s_in,
m => m_out
);
process
begin
x_in <= "00" ; y_in <= "00" ; s_in <= '0'; wait for 10ns;
x_in <= "01" ; y_in <= "00" ; s_in <= '0'; wait for 10ns;
x_in <= "01" ; y_in <= "01" ; s_in <= '0'; wait for 10ns;
x_in <= "10" ; y_in <= "00" ; s_in <= '0'; wait for 10ns;
x_in <= "10" ; y_in <= "10" ; s_in <= '0'; wait for 10ns;
x_in <= "11" ; y_in <= "10" ; s_in <= '0'; wait for 10ns;
x_in <= "01" ; y_in <= "00" ; s_in <= '1'; wait for 10ns;
x_in <= "00" ; y_in <= "01" ; s_in <= '1'; wait for 10ns;
x_in <= "11" ; y_in <= "10" ; s_in <= '1'; wait for 10ns;
x_in <= "11" ; y_in <= "11" ; s_in <= '1'; wait for 10ns;
wait;
end process;
end rpstb;
HASIL
ANALISIS
Tabel hasil keluaran
x Y S m
00 00 0 00
01 00 0 01
01 01 0 01
10 00 0 10
10 10 0 10
11 10 0 11
01 00 1 00
00 01 1 01
11 10 1 10
11 11 1 11
Tabel kebenaran
s0 s1 m
0 0 x
0 1 x
1 0 Y
1 0 Z
Design.vhd
library IEEE;
use IEEE.std_logic_1164.all;
library IEEE;
use IEEE.std_logic_1164.all;
entity mux3to1 is port(
x, y, z, s0, s1 : in std_logic;
m : out std_logic);
end mux3to1;
begin
mux1 : mux port map(
a=>x,
b=>y,
c=>s0,
d=>d_int);
mux2 : mux port map(
a=>d_int,
b=>z,
c=>s1,
d=>m);
end architecture rps;
Testbench.vhd
library IEEE;
use IEEE.std_logic_1164.all;
entity testbench is
end testbench;
component mux3to1 is
port(
x: in std_logic;
y: in std_logic;
z: in std_logic;
s0: in std_logic;
s1: in std_logic;
m: out std_logic);
end component;
begin
Process
begin
x_in <= '0'; y_in <= '0'; z_in <= '1'; s0_in <= '0'; s1_in <= '0';
wait for 15 ns;
x_in <= '0'; y_in <= '1'; z_in <= '0'; s0_in <= '0'; s1_in <= '1';
wait for 15 ns;
x_in <= '1'; y_in <= '0'; z_in <= '1'; s0_in <= '1'; s1_in <= '0';
wait for 15 ns;
x_in <= '1'; y_in <= '0'; z_in <= '1'; s0_in <= '1'; s1_in <= '1';
wait for 15 ns;
wait;
end process;
end behavioral;
HASIL
ANALISIS
Tabel hasil keluaran
x y z s0 s1 m
0 0 1 0 0 0
0 1 0 0 1 0
1 0 1 1 0 0
1 0 1 1 1 1