using the code below provide the circuit design and system justification for a 4-story building elevator system
Fantastic news! We've Found the answer you've been seeking!
Question:
using the code below provide the circuit design and system justification for a 4-story building elevator system
module Elevator(request_floor, in_current_floor, clk, reset, complete, direction, out_current_floor); //input pins input [3:0] request_floor; //4 bit input floor request input [3:0] in_current_floor; //4 bit input request floor; input clk; input reset; //1 bit input reset //output pins output [3:0] out_current_floor; //4 bit output showing current floor output direction; //1 bit output indicates if elevator is going up or down output complete; //1 bit output indicates if elevator is stopped or running //parameters set for register reg r_direction; //1 bit reg connected to direction reg r_complete; //1 bit connected to complete; reg [3:0] r_out_current_floor; //4 bit reg connected to out_current_floor //register for clock generator reg [6:0] clk_count; reg clk_100; reg clk_trigger; //match pins and registers assign direction = r_direction; assign complete = r_complete; assign out_current_floor = r_out_current_floor; //starting up always @ (negedge reset) //will only run when reset = 0, reset CLK_100, CLK_count, and CLK_trigger to 0 begin clk_100 = 1'b0; clk_count = 0; clk_trigger = 1'b0; //reset the clock registers r_complete= 1'b0; end //clock generator block always @ (posedge clk) begin if (clk_trigger) begin clk_count = clk_count +1; end if (clk_count == 5000) begin clk_100 =~ clk_100; clk_count = 0; end end //floor the user requested always @ (request_floor) begin clk_trigger =1 ; clk_100 =~ clk_100; //generator for trigger clock r_out_current_floor <= in_current_floor; end //different cases for elevator always @ (posedge clk) begin if (!reset) begin if (request_floor > r_out_current_floor) begin r_direction = 1'b1; r_out_current_floor <= r_out_current_floor << 1; end else if (request_floor < r_out_current_floor) begin r_direction = 1'b0; r_out_current_floor = r_out_current_floor >> 1; end else if (request_floor == r_out_current_floor) begin r_complete = 1; r_direction = 0; end end end endmodule
Related Book For
Posted Date: