diff --git a/ps3/ps02q/traffic_light_controler.v b/ps3/ps02q/traffic_light_controler.v index 90bf36d..54a3088 100644 --- a/ps3/ps02q/traffic_light_controler.v +++ b/ps3/ps02q/traffic_light_controler.v @@ -47,7 +47,7 @@ /////////////////////////////////////////////////////////////////// module smart_tl_ctl #( parameter - PARAMETER = 45, + PARAMETER = 45, MR_GREEN_TIME = 30, SR_GREEN_TIME = 10, YELLOW_TIME = 3 @@ -105,10 +105,14 @@ always@(posedge clk) begin r_cnt = 0; r_next = MR_GREEN_1; end - else if (r_cnt >= MR_GREEN_TIME) & (MR_cars != 0) begin + else if (r_cnt >= MR_GREEN_TIME) & (MR_cars < PARAMETER) begin r_cnt = 0; r_next = MR_GREEN_2; end + else if (r_cnt >= MR_GREEN_TIME) & (MR_cars >= PARAMETER) begin + r_cnt = 0; + r_next = MR_YELLOW; + end end MR_GREEN_2: begin r_MR_ctl = 'b11;