ECEN 468 – ADVANCED DIGITAL SYSTEM DESIGN HOME WORK - 2 NAME: SRINIVAS AMBATI AMBATI VENKATESH UIN: 923008575
Date: Facut!:
02/02/2015 D"# $%a&' Hu
Gas Station !o"#$%& SC_MODULE(gas_station){ sc_event request1, request2, tank_full; SC_CTOR(gas_station){ SC_METHOD(attendant); sensitive << request1 << request2 ( 'ont(initia#i)$)*( 'ont(initia#i)$ )*( SC_THREAD(customer1); sensitive << tank_full; SC_THREAD(customer2); } void attendant(); void customer1(); void customer2(); }; void gas_station::customer1(){ while ( true true ) { wait ( S (SC_ZERO_TIME C_ZERO_TIME ); tank1 = 0; do { request1 noti! (); (); wait (); (); !! "se static sensiti#it$ } while ( tank1 == 0 ); } } void gas_station::attendant(){ i (%&lling) { &lling = true; ne"t_tri##er ('_*+); ('_*+); } else { SC_ZERO_TIME ); tank_fullnoti! ( ( SC_ZERO_TIME &lling = alse; } } *+ ,o! t$ .!o/$ss o0 /1sto%$!* 3 .#$as$ 'is/1ss 5at %it "$ 'i7$!$nt 'i7$!$nt on t$ t$ si%1#ation !$s1#ts "$t5$$n 1sin an' 5ito1t 1sin 1 sin t$ 5aitSC(9ERO(TIME3:+
•
•
So#1tion& S%&ce +e ,a-e u.e &t%&%t%a%e)* 4" t,e atte&a&t At t%6e t0 t,e cu.t6e"1)* "ce.. .ta"t.# Wait stat$%$nt in #in$ ;&
.e&.%t%-%t! %.t %. t"%''e"e# I& t,%. ca.e %t %. t,e e-e&t tank_full# S%&ce t,e atte&a&t "ce.. ,a. &t .ta"te t,e"e %. & +a! customer1() "ce.. ca& "cee 4u"t,e"# He&ce <t, t,e "ce.. +%
& ,e& t,e atte&a&t "ce.. %. %& eecut%& cu.t6e"1)* %. %& +a%t .tate a& t,e"e %. & t,e" "ce.. "u&&%&'# S a4te" t,e atte&a&t "ce.. %. t"%''e"e a'a%& +,e& t,e ta&= %. 4u %t +% .e& ta&=4u &t%cat%& t cu.t6e"1# S u.%&' e%t,e" 4 t,e &t%4! .tate6e&t. +% not %a?$ an= 'i7$!$n/$ %& .%6uat%& "e.ut.# ;+ #$as$ 5!it$ a .i$/$ o0 S=st$%C /o'$ 0o! t$ .!o/$ss o0 /1sto%$!2 3+ #$as$ not$ tat t$!$ is no stati/ s$nsiti@it= 0o! /1sto%$!2 3+ So#1tion& Be+ %. t,e ce 4" cu.t6e"2 u.%&' a t,"ea "ce.. +%t,ut a&! .tat%c .e&.%t%-%t!# A %&&%te +,%e %. u.e ?u.t %=e a&! t,e" t,"ea "ce..# I4 t,e atte&a&t %.
T,e "ce.. 4" atte&a&t %. &t %&%t%a%e %& t,e c&.t"uct"# S%&ce atte&a&t ca&&t .ta"t %&' +%t,ut a&! "[email protected] 4"6 t,e cu.t6e"# T,e atte&a&t +a%t. 4" "[email protected] " "[email protected] &ce ,e 'et. a "[email protected] a& %4 ,e &t