Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rashed Al-Lahaseh
Automated Laundry System
Commits
80f433ef
Commit
80f433ef
authored
Jul 27, 2021
by
Rashed Al-Lahaseh
Browse files
Add high level entity
Automated Laundry System Entity
parent
efa53bc8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Project/e_automated_laundry_system.vhd
0 → 100644
View file @
80f433ef
library
ieee
;
use
ieee
.
std_logic_1164
.
all
;
use
ieee
.
numeric_std
.
all
;
entity
e_automated_laundry_system
is
port
(
CLOCK_50
,
reset
:
in
std_logic
;
nearby_person_sensor
,
washing_machine_done_sensor
:
in
std_logic
;
push_password_button
,
push_address_button
:
in
std_logic
;
coin_in
:
in
std_logic_vector
(
3
downto
0
);
-- "1 Euro, 50cents, 20cents, 10cents" -- "1111"
password_in
,
washing_machine_address_in
:
in
std_logic_vector
(
3
downto
0
);
green_led
,
red_led
:
out
std_logic
;
start_button
:
out
std_logic
;
hex_0
,
hex_1
,
hex_2
,
hex_3
,
hex_4
,
hex_5
:
out
std_logic_vector
(
6
downto
0
);
coin_out
:
out
std_logic_vector
(
3
downto
0
)
-- "1 Euro, 50cents, 20cents, 10cents" -- "1111"
);
end
e_automated_laundry_system
;
architecture
a_automated_laundry_system
of
e_automated_laundry_system
is
constant
c_password
:
std_logic_vector
(
3
downto
0
)
:
=
"0000"
;
constant
c_laundry_room_capacity
:
integer
:
=
9
;
signal
sl_password_button_last_state
:
std_logic
:
=
'0'
;
signal
sl_address_button_last_state
:
std_logic
:
=
'0'
;
signal
sl_working_washing_machines_count
:
integer
range
0
to
9
;
signal
sl_state_choice
:
integer
range
0
to
9
;
signal
sl_word_choice
:
integer
range
0
to
6
;
signal
sl_paid
:
boolean
:
=
false
;
signal
sl_washing_machine_address_available
:
boolean
;
signal
sl_word_s
:
std_logic
;
signal
sl_payment
:
integer
range
0
to
290
;
signal
sl_memory_enable
:
std_logic
:
=
'1'
;
-- active low
------------------------------------- Procedures -----------------------------------------------
procedure
procedure_toggle_green_led
(
signal
green_led
:
out
std_logic
;
signal
start_button
:
out
std_logic
)
is
begin
start_button
<=
'1'
;
-- enable the start button
green_led
<=
'1'
;
-- green light on
-- wait 1 ns cycles for the process to reset
start_button
<=
'0'
;
-- disable the start button
green_led
<=
'0'
;
-- green light off
end
procedure_toggle_green_led
;
------------------------------------- Components ----------------------------------------------
component
e_laundry_fsm
generic
(
n
:
integer
:
=
8
);
port
(
CLOCK_50
,
reset
:
in
std_logic
;
nearby_person_sensor
,
washing_machine_done_sensor
:
in
std_logic
;
push_password_button
,
push_address_button
:
in
std_logic
;
washing_machine_available
,
paid
:
in
boolean
;
password_in
,
washing_machine_address_in
:
in
std_logic_vector
(
3
downto
0
);
working_washing_machines_count
:
out
integer
range
0
to
9
;
state_choice
:
out
integer
range
0
to
9
);
end
component
;
component
e_7seg_display
generic
(
n
:
integer
:
=
8
);
port
(
CLOCK_50
,
word_s
:
in
std_logic
;
word_choice
:
in
integer
range
0
to
5
;
payment
:
in
integer
range
0
to
290
;
hex_1
,
hex_2
,
hex_3
,
hex_4
,
hex_5
:
out
std_logic_vector
(
6
downto
0
)
);
end
component
;
component
e_7seg_bcd_decoder
generic
(
n
:
integer
:
=
8
);
port
(
count
:
in
integer
range
0
to
9
;
hex_0
:
out
std_logic_vector
(
6
downto
0
)
);
end
component
;
component
e_memory
is
generic
(
n
:
integer
:
=
8
);
port
(
enable
,
reset
:
in
std_logic
;
washing_machine_address
:
in
std_logic_vector
(
n
-5
downto
0
);
washing_machine_address_available
:
out
boolean
);
end
component
;
component
e_payment_fsm
is
generic
(
n
:
integer
:
=
16
);
port
(
coin_in
:
in
std_logic_vector
(
n
-13
downto
0
);
-- "1 Euro, 50cents, 20cents, 10cents" -- "1111"
coin_out
:
out
std_logic_vector
(
n
-13
downto
0
);
-- "1 Euro, 50cents, 20cents, 10cents" -- "1111"
payment
:
out
integer
range
0
to
290
;
paid
:
out
boolean
);
end
component
;
------------------------------------- architecture begins -------------------------------------
begin
-- state_choice
-- 0: no_action_state,
-- 1: user_detect_state
-- 2: verification_state
-- 3: availability_state
-- 4: payment_state
-- 5: process_state
-- 6: finished_processing_state
-- 7: hold_state
-- 8: start_state
-- 9: full_state
-- word_choice
-- 0 => turned off
-- 1 => addr
-- 2 => pay
-- 3 => procs
-- 4 => hold
-- 5 => full
-- 6 => start
i_e_memory
:
e_memory
generic
map
(
n
=>
8
)
port
map
(
sl_memory_enable
,
reset
,
washing_machine_address_in
,
sl_washing_machine_address_available
);
i_e_laundry_fsm
:
e_laundry_fsm
generic
map
(
n
=>
8
)
port
map
(
CLOCK_50
,
reset
,
nearby_person_sensor
,
washing_machine_done_sensor
,
push_password_button
,
push_address_button
,
sl_washing_machine_address_available
,
sl_paid
,
password_in
,
washing_machine_address_in
,
sl_working_washing_machines_count
,
sl_state_choice
);
i_e_payment_fsm
:
e_payment_fsm
generic
map
(
n
=>
16
)
port
map
(
coin_in
,
coin_out
,
sl_payment
,
sl_paid
);
process
(
sl_state_choice
)
begin
case
sl_state_choice
is
when
2
=>
-- verification_state (password entered correctly, now for the availability)
sl_word_choice
<=
1
;
-- displaying the word 'Addr', since we can not draw 'Machine Number' through 7seg display
sl_memory_enable
<=
'0'
;
-- enable memory for availability_state (next state)
when
3
=>
-- availability_state
if
(
sl_washing_machine_address_available
)
then
red_led
<=
'0'
;
else
red_led
<=
'1'
;
end
if
;
when
4
=>
-- payment_state
sl_word_choice
<=
2
;
-- displaying the word 'Pay'
when
5
=>
-- process_state
sl_word_choice
<=
3
;
-- displaying the word 'Procs'
procedure_toggle_green_led
(
green_led
,
start_button
);
-- Enabling start button
when
6
=>
-- finished_processing_state
sl_word_choice
<=
6
;
-- displaying the word 'Start'
procedure_toggle_green_led
(
green_led
,
start_button
);
-- Disabling start button
when
7
=>
-- hold_state
sl_word_choice
<=
4
;
-- displaying the word hold
when
9
=>
-- full_state
sl_word_choice
<=
5
;
-- displaying the word 'Full'
when
others
=>
sl_word_choice
<=
0
;
-- displaying the word 'Turned Off'
end
case
;
end
process
;
with
sl_state_choice
select
sl_word_s
<=
'1'
when
4
,
-- displaying coins only in paying_state
'0'
when
others
;
i_e_7seg_display
:
e_7seg_display
generic
map
(
n
=>
8
)
port
map
(
CLOCK_50
,
sl_word_s
,
sl_word_choice
,
sl_payment
,
hex_1
,
hex_2
,
hex_3
,
hex_4
,
hex_5
);
i_e_7seg_bcd_decoder
:
e_7seg_bcd_decoder
generic
map
(
n
=>
8
)
port
map
(
sl_working_washing_machines_count
,
hex_0
);
end
a_automated_laundry_system
;
\ No newline at end of file
Project/e_automated_laundry_system.vhd.bak
0 → 100644
View file @
80f433ef
library ieee;
use ieee.std_logic_1164.all;
entity e_payment_fsm is
generic(n:integer:= 16);
port(
coin_in: in std_logic_vector(n-13 downto 0); -- "1 Euro, 50cents, 20cents, 10cents" -- "1111"
coin_out: out std_logic_vector(n-13 downto 0); -- "1 Euro, 50cents, 20cents, 10cents" -- "1111"
payment: out integer range 0 to 290;
paid: out boolean
);
end e_payment_fsm;
architecture a_payment_fsm of e_payment_fsm is
type payment_states is (zero_cent, ten_cents, twenty_cents, thirty_cents, fourty_cents, fifty_cents, sixty_cents,
seventy_cents, eighty_cents, ninety_cents, one_euro, one_euro_ten_cents,
one_euro_twenty_cents, one_euro_thirty_cents, one_euro_fourty_cents, one_euro_fifty_cents, one_euro_sixty_cents,
one_euro_seventy_cents, one_euro_eighty_cents, one_euro_ninty_cents,two_euro, two_euro_ten_cents, two_euro_twenty_cents,
two_euro_thirty_cents, two_euro_fourty_cents, two_euro_fifty_cents, two_euro_sixty_cents, two_euro_seventy_cents,
two_euro_eighty_cents, two_euro_ninty_cents);
signal sl_coin_state: payment_states := zero_cent;
------------------------------------- architecture begins -------------------------------------
begin
process(coin_in) begin
case sl_coin_state is
when zero_cent =>
if (coin_in = "0001") then sl_coin_state <= ten_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= twenty_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= fifty_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= one_euro; --+100
else sl_coin_state <= zero_cent;-- +0
end if;
coin_out <= "0000";
payment <= 0;
when ten_cents =>
if (coin_in = "0001") then sl_coin_state <= twenty_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= thirty_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= sixty_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= one_euro_ten_cents; --+100
else sl_coin_state <= ten_cents;-- +0
end if;
coin_out <= "0000";
payment <= 10;
when twenty_cents =>
if (coin_in = "0001") then sl_coin_state <= thirty_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= fourty_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= seventy_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= one_euro_twenty_cents; --+100
else sl_coin_state <= twenty_cents;-- +0
end if;
coin_out <= "0000";
payment <= 20;
when thirty_cents =>
if (coin_in = "0001") then sl_coin_state <= fourty_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= fifty_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= eighty_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= one_euro_thirty_cents; --+100
else sl_coin_state <= thirty_cents;-- +0
end if;
coin_out <= "0000";
payment <= 30;
when fourty_cents =>
if (coin_in = "0001") then sl_coin_state <= fifty_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= sixty_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= ninety_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= one_euro_fourty_cents; --+100
else sl_coin_state <= fourty_cents;-- +0
end if;
coin_out <= "0000";
payment <= 40;
when fifty_cents =>
if (coin_in = "0001") then sl_coin_state <= sixty_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= seventy_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= one_euro;-- +50
elsif(coin_in = "1000") then sl_coin_state <= one_euro_fifty_cents; --+100
else sl_coin_state <= fifty_cents;-- +0
end if;
coin_out <= "0000";
payment <= 50;
when sixty_cents =>
if (coin_in = "0001") then sl_coin_state <= seventy_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= eighty_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= one_euro_ten_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= one_euro_sixty_cents; --+100
else sl_coin_state <= sixty_cents;-- +0
end if;
coin_out <= "0000";
payment <= 60;
when seventy_cents =>
if (coin_in = "0001") then sl_coin_state <= eighty_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= ninety_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= one_euro_twenty_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= one_euro_seventy_cents; --+100
else sl_coin_state <= seventy_cents;-- +0
end if;
coin_out <= "0000";
payment <= 70;
when eighty_cents =>
if (coin_in = "0001") then sl_coin_state <= ninety_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= one_euro;-- +20
elsif(coin_in = "0100") then sl_coin_state <= one_euro_thirty_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= one_euro_eighty_cents; --+100
else sl_coin_state <= eighty_cents;-- +0
end if;
coin_out <= "0000";
payment <= 80;
when ninety_cents =>
if (coin_in = "0001") then sl_coin_state <= one_euro;-- +10
elsif(coin_in = "0010") then sl_coin_state <= one_euro_ten_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= one_euro_fourty_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= one_euro_ninty_cents; --+100
else sl_coin_state <= ninety_cents;-- +0
end if;
coin_out <= "0000";
payment <= 90;
when one_euro =>
if (coin_in = "0001") then sl_coin_state <= one_euro_ten_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= one_euro_twenty_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= one_euro_fifty_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= two_euro; --+100
else sl_coin_state <= one_euro;-- +0
end if;
coin_out <= "0000";
payment <= 100;
when one_euro_ten_cents =>
if (coin_in = "0001") then sl_coin_state <= one_euro_twenty_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= one_euro_thirty_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= one_euro_sixty_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= two_euro_ten_cents; --+100
else sl_coin_state <= one_euro_ten_cents;-- +0
end if;
coin_out <= "0000";
payment <= 110;
when one_euro_twenty_cents =>
if (coin_in = "0001") then sl_coin_state <= one_euro_thirty_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= one_euro_fourty_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= one_euro_seventy_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= two_euro_twenty_cents; --+100
else sl_coin_state <= one_euro_twenty_cents;-- +0
end if;
coin_out <= "0000";
payment <= 120;
when one_euro_thirty_cents =>
if (coin_in = "0001") then sl_coin_state <= one_euro_fourty_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= one_euro_fifty_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= one_euro_eighty_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= two_euro_thirty_cents; --+100
else sl_coin_state <= one_euro_thirty_cents;-- +0
end if;
coin_out <= "0000";
payment <= 130;
when one_euro_fourty_cents =>
if (coin_in = "0001") then sl_coin_state <= one_euro_fifty_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= one_euro_sixty_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= one_euro_ninety_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= two_euro_fourty_cents; --+100
else sl_coin_state <= one_euro_fourty_cents;-- +0
end if;
coin_out <= "0000";
payment <= 140;
when one_euro_fifty_cents =>
if (coin_in = "0001") then sl_coin_state <= one_euro_sixty_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= one_euro_seventy_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= two_euro;-- +50
elsif(coin_in = "1000") then sl_coin_state <= two_euro_fifty_cents; --+100
else sl_coin_state <= one_euro_fifty_cents;-- +0
end if;
coin_out <= "0000";
payment <= 150;
when one_euro_sixty_cents =>
if (coin_in = "0001") then sl_coin_state <= one_euro_seventy_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= one_euro_eighty_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= two_euro_ten_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= two_euro_sixty_cents; --+100
else sl_coin_state <= one_euro_sixty_cents;-- +0
end if;
coin_out <= "0000";
payment <= 160;
when one_euro_seventy_cents =>
if (coin_in = "0001") then sl_coin_state <= one_euro_eighty_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= one_euro_ninety_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= two_euro_twenty_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= two_euro_seventy_cents; --+100
else sl_coin_state <= seventy_cents;-- +0
end if;
coin_out <= "0000";
payment <= 170;
when one_euro_eighty_cents =>
if (coin_in = "0001") then sl_coin_state <= one_euro_ninety_cents;-- +10
elsif(coin_in = "0010") then sl_coin_state <= two_euro;-- +20
elsif(coin_in = "0100") then sl_coin_state <= two_euro_thirty_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= two_euro_eighty_cents; --+100
else sl_coin_state <= one_euro_eighty_cents;-- +0
end if;
coin_out <= "0000";
payment <= 180;
when one_euro_ninety_cents =>
if (coin_in = "0001") then sl_coin_state <= two_euro;-- +10
elsif(coin_in = "0010") then sl_coin_state <= two_euro_ten_cents;-- +20
elsif(coin_in = "0100") then sl_coin_state <= two_euro_fourty_cents;-- +50
elsif(coin_in = "1000") then sl_coin_state <= two_euro_ninty_cents; --+100
else sl_coin_state <= one_euro_ninety_cents;-- +0
end if;
coin_out <= "0000";
payment <= 190;
when two_euro =>
coin_out <= "0000";
paid <= true;
payment <= 200;
when two_euro_ten_cents =>
coin_out <= "0001"; -- give back 10
paid <= true;
payment <= 210;
when two_euro_twenty_cents =>
coin_out <= "0010"; -- give back 20
paid <= true;
payment <= 220;
when two_euro_thirty_cents =>
coin_out <= "0011"; -- give back 10, 20
paid <= true;
payment <= 230;
when two_euro_fourty_cents =>
coin_out <= "0011"; -- give back 10, 20
sl_coin_state <= two_euro_ten_cents; -- to give back the remaining 10 cents
payment <= 240;
when two_euro_fifty_cents =>
coin_out <= "0100"; -- give back 50
paid <= true;
payment <= 250;
when two_euro_sixty_cents =>
coin_out <= "0101"; -- give back 50, 10
paid <= true;
payment <= 260;
when two_euro_seventy_cents =>
coin_out <= "0110"; -- give back 50, 20
paid <= true;
payment <= 270;
when two_euro_eighty_cents =>
coin_out <= "0111"; -- give back 50, 20, 10
paid <= true;
payment <= 280;
when two_euro_ninety_cents =>
coin_out <= "0111"; -- give back 50, 20, 10
sl_coin_state <= two_euro_ten_cents; -- to give back the remaining 10 cents
payment <= 290;
end case;
end process;
end architecture;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment