B.1 FSM (Finite State Machine) Sortir Benda
B.1 FSM (Finite State Machine) Sortir Benda
port
( clk: in std_logic;
t_start, t_reset
: in std_logic;
s_utama
: in std_logic;
s_kabin
: in std_logic;
stoper_low, stoper_med, stoper_high : in std_logic;
TIMER
: in std_logic;
s_limit
: in std_logic_vector (2 downto 0);
m_konveutama
: out std_logic_vector (1 downto
m_konvelow
: out std_logic_vector (1 downto
m_konvemed
: out std_logic_vector (1 downto
m_konvehigh
: out std_logic_vector (1 downto
m_lifter
: out std_logic_vector (1 downto
m_kabin
: out std_logic_vector (1 downto
);
end fsm_mesinsortir;
0);
0);
0);
0);
0);
0)
m_kabin<="10";
m_konvelow<="10";
m_konveutama<="00";
when state_8 => if stoper_med = '0' then
next_state <= state_9; -- benda medium
else
next_state <= state_8;
end if;
m_lifter<="10"; -- lift naik ke lt 2
m_konveutama<="00";
m_kabin<="00";
when state_9 => m_lifter<="00"; -- lift berhenti
if TIMER = '1' then -- benda medium
next_state<= state_12;
else
next_state<= state_9;
end if;
m_kabin<="10";
m_konvemed<="10";
when state_10 => if stoper_high = '0' then
next_state<= state_11; -- benda high
else
next_state<= state_10;
end if;
m_lifter<="10"; -- lift naik ke lt 3
m_konveutama<="00"
m_kabin<="00";
when state_11 => m_lifter<="00";
if TIMER = '1' then -- benda high
next_state <= state_12;
else
next_state <= state_11;
end if;
m_kabin<="10";
m_konvehigh<="10";
when state_12 => next_state <=state_0; -- end of the line
end case ;
end process ;
end behavioral ;
: in std_logic;
: out std_logic;
clockout_setengah_s
);
end clock_divider;
: out std_logic
='0') then
='0') then
='0') then
elsif
elsif
elsif
elsif
elsif
elsif
elsif
elsif
end if;
satuan
satuan
satuan
satuan
satuan
satuan
satuan
satuan
=
=
=
=
=
=
=
=
2
3
4
5
6
7
8
9
then
then
then
then
then
then
then
then
D_out_A
D_out_A
D_out_A
D_out_A
D_out_A
D_out_A
D_out_A
D_out_A
<=
<=
<=
<=
<=
<=
<=
<=
"0010";
"0011";
"0100";
"0101";
"0110";
"0111";
"1000";
"1001";
=
=
=
=
=
=
=
=
=
=
0
1
2
3
4
5
6
7
8
9
then
then
then
then
then
then
then
then
then
then
D_out_B
D_out_B
D_out_B
D_out_B
D_out_B
D_out_B
D_out_B
D_out_B
D_out_B
D_out_B
<=
<=
<=
<=
<=
<=
<=
<=
<=
<=
"0000";
"0001";
"0010";
"0011";
"0100";
"0101";
"0110";
"0111";
"1000";
"1001";
=
=
=
=
=
=
=
=
=
=
0
1
2
3
4
5
6
7
8
9
then
then
then
then
then
then
then
then
then
then
D_out_C
D_out_C
D_out_C
D_out_C
D_out_C
D_out_C
D_out_C
D_out_C
D_out_C
D_out_C
<=
<=
<=
<=
<=
<=
<=
<=
<=
<=
"0000";
"0001";
"0010";
"0011";
"0100";
"0101";
"0110";
"0111";
"1000";
"1001";
end if;
end process;
end behavioral;
: in std_logic;
: out std_logic
end if ;
end case ;
end process ;
end behavioral ;
B.6 F_DIF
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity F_DIF is
port ( clk
perdetik
Clk7seg
: in std_logic;
: out std_logic;
: out STD_LOGIC;
);
end F_DIF;
architecture behavioral of F_DIF is
signal clk1, clk2: std_logic;
signal satu_detik :std_logic_vector(24 downto 0);
signal setengah_detik :std_logic_vector(15 downto 0);
begin
process(clk, satu_detik, setengah_detik )
begin
if clk'event and clk ='1' then
satu_detik <= satu_detik + 1;
setengah_detik <= setengah_detik + 1;
end if;
clk1 <= satu_detik(24);
clk2 <= setengah_detik(15);
perdetik <= clk1;
Clk7seg <= clk2;
end process;
end behavioral;
B.7 BCD A
library ieee;
use IEEE.STD_LOGIC_1164.ALL;
entity BCD_A is
port (
D_in_A : in std_logic_vector(3 downto 0);
D_out_A
: out std_logic_vector(6 downto 0)
);
end BCD_A;
architecture behavioral of BCD_A is
begin
Process (D_in_A)
begin
if
elsif
elsif
elsif
elsif
elsif
elsif
elsif
elsif
elsif
D_in_A
D_in_A
D_in_A
D_in_A
D_in_A
D_in_A
D_in_A
D_in_A
D_in_A
D_in_A
=
=
=
=
=
=
=
=
=
=
"0000"
"0001"
"0010"
"0011"
"0100"
"0101"
"0110"
"0111"
"1000"
"1001"
then
then
then
then
then
then
then
then
then
then
D_out_A
D_out_A
D_out_A
D_out_A
D_out_A
D_out_A
D_out_A
D_out_A
D_out_A
D_out_A
<=
<=
<=
<=
<=
<=
<=
<=
<=
<=
"0000001";
"0110111";
"1000010";
"0010010";
"0110100";
"0011000";
"0001000";
"0110011";
"0000000";
"0010000";
-----------
0
1
2
3
4
5
6
7
8
9
B.8 BCD B
library ieee;
use IEEE.STD_LOGIC_1164.ALL;
entity BCD_B is
port (
D_in_B : in std_logic_vector(3 downto 0);
D_out_B
: out std_logic_vector(6 downto 0)
);
end BCD_B;
architecture behavioral of BCD_B is
begin
Process (D_in_B)
begin
if
elsif
elsif
elsif
elsif
elsif
elsif
elsif
elsif
elsif
D_in_B
D_in_B
D_in_B
D_in_B
D_in_B
D_in_B
D_in_B
D_in_B
D_in_B
D_in_B
=
=
=
=
=
=
=
=
=
=
"0000"
"0001"
"0010"
"0011"
"0100"
"0101"
"0110"
"0111"
"1000"
"1001"
then
then
then
then
then
then
then
then
then
then
D_out_B
D_out_B
D_out_B
D_out_B
D_out_B
D_out_B
D_out_B
D_out_B
D_out_B
D_out_B
B.9 BCD C
library ieee;
use IEEE.STD_LOGIC_1164.ALL;
<=
<=
<=
<=
<=
<=
<=
<=
<=
<=
"0000001";
"0110111";
"1000010";
"0010010";
"0110100";
"0011000";
"0001000";
"0110011";
"0000000";
"0010000";
-----------
0
1
2
3
4
5
6
7
8
9
entity BCD_C is
port (
D_in_C : in std_logic_vector(3 downto 0);
D_out_C
: out std_logic_vector(6 downto 0)
);
end BCD_C;
architecture behavioral of BCD_C is
begin
Process (D_in_C)
begin
if
elsif
elsif
elsif
elsif
elsif
elsif
elsif
elsif
elsif
D_in_C
D_in_C
D_in_C
D_in_C
D_in_C
D_in_C
D_in_C
D_in_C
D_in_C
D_in_C
else
end if;
end process;
end behavioral;
=
=
=
=
=
=
=
=
=
=
"0000"
"0001"
"0010"
"0011"
"0100"
"0101"
"0110"
"0111"
"1000"
"1001"
then
then
then
then
then
then
then
then
then
then
D_out_C
D_out_C
D_out_C
D_out_C
D_out_C
D_out_C
D_out_C
D_out_C
D_out_C
D_out_C
<=
<=
<=
<=
<=
<=
<=
<=
<=
<=
"0000001";
"0110111";
"1000010";
"0010010";
"0110100";
"0011000";
"0001000";
"0110011";
"0000000";
"0010000";
-----------
0
1
2
3
4
5
6
7
8
9