📄 cu_two.v
字号:
ch_stat_2 = 2'b10;
mov_2 = 2'b10;
stop_2 = 1'b0;
end
else begin
ch_stat_2 = 2'b01;
mov_2 = 2'b01;
stop_2 = 1'b1;
des_2 = 1;
req_clr_2 = 2'b01;
end
end
end
2'b11,
2'b10: begin
ch_stat_2 = 2'b10;
mov_2 = 2'b10;
stop_2 = 1'b1;
des_2 = 1;
req_clr_2 = 2'b10;
end
default:begin
ch_stat_2 = stat_2;
mov_2 = 2'b00;
stop_2= 1'b0;
end
endcase
end
default: begin
ch_stat_2 = stat_2;
mov_2 = 0;
stop_2 = 1'b0;
end
endcase
end
always @(posedge sel_1)// or stat_1 or req_1 or up_1 or down_1 or now_1) ////////////////////////////////////电梯一
begin
stop_1 = 0;
ch_stat_1 = 0;
mov_1 = 0;
req_clr_1 = 0;
des_1 = 0;
case (stat_1)
2'b00: begin //电梯处于等待状态的调度
case(req_1)
2'b00 : begin
if(up_1) begin
ch_stat_1 = 2'b01;
mov_1 = 2'b01;
stop_1 = 1'b0;
end
else begin
if(down_1)
begin
ch_stat_1 = 2'b10;
mov_1 = 2'b10;
stop_1 = 1'b0;
end
else //上下均无请求
begin
ch_stat_1 = 2'b00;
mov_1 = 2'b00;
stop_1 = 1'b0; //停 但是不开门
end
end
end
2'b11 ,
2'b01 : begin
ch_stat_1 = 2'b01;
stop_1 = 1'b1;
mov_1 = 2'b01; //只是规定了响应之后的运动方向 还应有一个开门的信号 需协调
req_clr_1 = 2'b01; //撤销所有相关请求的信号 01为撤销向上的请求
des_1 = 1;
end
2'b10 : begin
ch_stat_1 = 2'b10;
mov_1 = 2'b10; //同上
stop_1 = 1'b1;
req_clr_1 = 2'b10; //10表示撤销向下的请求
des_1 = 1;
end
default: begin
ch_stat_1 = stat_1;
mov_1 = 2'b00;
stop_1 = 1'b0; //同上
end
endcase
end
2'b01: begin //电梯处于向上状态的调度
case(req_1)
2'b00: begin //外部无请求的情况
if(now_1)//本层是目的地
begin
mov_1 = 2'b01;
ch_stat_1 = 2'b01;
stop_1 = 1'b1;
des_1 = 1;
end
else begin
if(up_1) begin
ch_stat_1 = 2'b01;
mov_1 = 2'b01;
stop_1 = 1'b0;
end
else begin
if(down_1) begin
ch_stat_1 = 2'b10;
mov_1 = 2'b10;
stop_1 = 1'b0;
end
else begin
ch_stat_1 = 2'b00;
mov_1 = 2'b00;
stop_1 = 1'b0;//都无请求 停在此层
end
end
end
end
2'b11,
2'b01: begin //外部有向上请求的情况
ch_stat_1 = 2'b01;
mov_1 = 2'b01;
stop_1 = 1'b1;// 停下响应本层
des_1 = 1;
req_clr_1 = 2'b01;
end
2'b10: begin
if(now_1)//本层是目的地
begin
if(floor_1 == 7)
begin
mov_1 = 2'b10;
ch_stat_1 = 2'b10;
stop_1 = 'b1;
des_1 = 'b1;
end
else
begin
if(up_1)
begin
mov_1 = 2'b01;
ch_stat_1 = 2'b01;
stop_1 = 1'b1;
des_1 = 1;
end
else
begin
mov_1 ='b10;
ch_stat_1 = 'b10;
stop_1 = 'b1;
des_1 = 'b1;
end
end
end
else begin
if(up_1)
begin
ch_stat_1 = 2'b01;
mov_1 = 2'b01;
stop_1 = 1'b0;
end
else begin
ch_stat_1 = 2'b10;
mov_1 = 2'b10;
stop_1 = 1'b1;
des_1 = 1;
req_clr_1 = 2'b10;
end
end
end
default:begin
ch_stat_1 = stat_1;
mov_1 = 0;
stop_1 = 1'b0;
end
endcase
end
2'b10: begin //电梯处于向下的状态
case(req_1)
2'b00: begin
if(now_1)//本层是目的地
begin
if(floor_1 == 7)
begin
if(down_1)
begin
mov_1 = 2'b10;
ch_stat_1 = 2'b10;
stop_1 = 'b1;
des_1 = 'b1;
end
else
begin
mov_1 = 'b00;
ch_stat_1 = 'b00;
stop_1 = 'b0;
des_1 = 'b1;
end
end
else
begin
mov_1 = 2'b01;
ch_stat_1 = 2'b01;
stop_1 = 1'b1;
des_1 = 1;
end
end
else begin
if(down_1)
begin
ch_stat_1 = 2'b10;
mov_1 = 2'b10;
stop_1 = 1'b0;
end
else begin
if(up_1)
begin
ch_stat_1 = 2'b01;
mov_1 = 2'b01;
stop_1 = 1'b0;
end
else begin
ch_stat_1 = 2'b00;
mov_1 = 2'b00;
stop_1 = 1'b0;
end
end
end
end
2'b01: begin
if(now_1)
begin
if(floor_1 == 0)
begin
ch_stat_1 = 2'b01;
mov_1 = 2'b01; //响应本层目的
stop_1 = 1'b1;
des_1 = 1;
end
else
begin
if(down_1)
begin
ch_stat_1 ='b10;
mov_1 = 'b10;
stop_1 = 'b1;
des_1 = 'b1;
end
else
begin
ch_stat_1 = 'b01;
mov_1 = 'b01;
stop_1 = 'b1;
des_1 = 'b1;
end
end
end
else begin
if(down_1)
begin
ch_stat_1 = 2'b10;
mov_1 = 2'b10;
stop_1 = 1'b0;
end
else begin
ch_stat_1 = 2'b01;
mov_1 = 2'b01;
stop_1 = 1'b1;
des_1 = 1;
req_clr_1 = 2'b01;
end
end
end
2'b11,
2'b10: begin
ch_stat_1 = 2'b10;
mov_1 = 2'b10;
stop_1 = 1'b1;
des_1 = 1;
req_clr_1 = 2'b10;
end
default:begin
ch_stat_1 = stat_1;
mov_1 = 2'b00;
stop_1= 1'b0;
end
endcase
end
default: begin
ch_stat_1 = stat_1;
mov_1 = 0;
stop_1 = 1'b0;
end
endcase
end
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -