|
楼主 |
发表于 2015-6-9 12:25:42
|
显示全部楼层
5.1 分频模块
module frequence_div(cp_50M,cp_1);
input cp_50M;//板子提供的最高时钟
output cp_1;//要求得到的秒脉冲
reg [27:0] counter_1;//计数器
reg cp_1;//类型声明
always@(posedge cp_50M)
begin
if(counter_1==28'h17D7840)//50M的一半到了,秒脉冲翻转
begin
cp_1<=~cp_1;//翻转
counter_1<=28'h0000000;
end
else
counter_1<=counter_1+1'b1;//否则加1
end
endmodule
5.2 智能电梯主控制器模块
module elevator_controller(//input ports:
cp_50M,clk,reset,forbid,
call_up_1, call_up_2, call_up_3,
call_up_4, call_up_5,
call_down_2, call_down_3, call_down_4,
call_down_5,call_down_6,
request_1, request_2, request_3,
request_4, request_5, request_6,
//output ports:
out,LiftState,over_alarm,count_out,count
);
//output ports:
output [6:0]out;//输出楼层
output [6:0] LiftState;//输出电梯状态
output over_alarm;//出错
output [6:0]count_out;//计数器输出,便于我控制开关门的状态显示
output [2:0]count;//计数器
//input ports:
input cp_50M;
input clk,reset,call_up_1,call_up_2,call_up_3,call_up_4,call_up_5,call_down_2,call_down_3,call_down_4,call_down_5,call_down_6,request_1,request_2,request_3,request_4,request_5,request_6;
input forbid;
//pos与Posout的关系:当前状态一改变,pos立即作相应改变,而PosOut则是当前状态在要变到下一状态的瞬间
//,将PosOut作相应改变。如从WAIT切换到第一个UP时,pos立即加一,而PosOut则要等到第一个UP
//即将切换到第二个UP时,才加一。
//这个说的简单一点,就是移位寄存器,便于对电梯状态的实时的控制
wire over_alarm;
wire [6:0]out;
wire [6:0]count_out;
reg [5:0]pos,PosOut;
reg [2:0] count;//门开后要持续5个时钟周期,用count来计数
reg DoorFlag;
reg [1:0] UpDnFlag;
reg [6:0] LiftState,NextState;//分别表示电梯的当前状态和下一状态
wire real_clk;
//up_all,down_all,request_all分别用来合并向上请求的各信号,向下请求的各信号和停靠请求的各信号
//以便判断电梯在状态间如何转移时更简洁
reg [5:0] up_all,down_all,request_all;
//定义电梯7种状态的符号常量
parameter WAIT=7'b0000001, UP=7'b0000010, DOWN=7'b0000100, UPSTOP=7'b0001000
, DOWNSTOP=7'b0010000, OPENDOOR=7'b0100000, CLOSEDOOR=7'b1000000;
//定义楼层的符号常量
parameter FLOOR1=6'b000001, FLOOR2=6'b000010, FLOOR3=6'b000100, FLOOR4=6'b001000, FLOOR5=6'b010000, FLOOR6=6'b100000;
parameter TRUE=1'b1, FALSE=1'b0;
//定义门打开和门关闭的符号常量
parameter OPEN=1'b1, CLOSED=1'b0;
//定义电梯上升,下降和静止的符号常量
parameter UPFLAG=2'b01,DNFLAG=2'b10,STATIC=2'b00;
assign real_clk=(clk&(~forbid));
//采用屏蔽时钟的方法来实现“电梯强制禁止运行”。方法虽然违反了“同步电路最好
//没有时钟门控”的要求,但是在此只要“负面影响”不是很大还是可以接受的。
//将各上升请求信号实时地合并(6楼为顶层,无上升请求,考虑到通用性,将第4位填零)
always @(call_up_1 or call_up_2 or call_up_3 or call_up_4 or call_up_5)
up_all={1'b0, call_up_5, call_up_4, call_up_3, call_up_2, call_up_1};
//将各下降请求信号实时地合并(1楼为底层,无下降请求,考虑到通用性,将第1位填零)
always @(call_down_2 or call_down_3 or call_down_4 or call_down_5 or call_down_6)
down_all={call_down_6, call_down_5, call_down_4, call_down_3, call_down_2, 1'b0};
//将各停靠请求信号实时地合并
always @(request_1 or request_2 or request_3 or request_4 or request_5 or request_6)
request_all={request_6, request_5, request_4, request_3, request_2, request_1};
always @(posedge real_clk or posedge reset)
if(reset)
count<=0;
else if((NextState==OPENDOOR)&&(count<5))//or else if(NextState==OPENDOOR)
count<=count+1;//如果计数不到5且下一状态为OPENDOOR的话,继续计数
else
count<=0;//清零,以备下次计数
//display which floor the elevator is....
display_decode h1(cp_50M,PosOut,out,over_alarm);
display_decode_count h2(cp_50M,count,count_out);
// finite state machine in the style of three segments ,三段式
//1st StateShift always block,sequential state transition,有限状态机第一段
always @(posedge real_clk or posedge reset)
if(reset)
begin
LiftState<=WAIT;
end
else
LiftState<=NextState;
//2nd StateShift always block,combinational condition judgement,有限状态机第二段
always @(LiftState or up_all or down_all or request_all or pos or count or UpDnFlag)
case(LiftState)
WAIT:
begin
if(request_all>0)//有停靠请求否
begin
if((request_all&pos)>0)//停靠请求中有当前楼层停靠请求否
NextState=OPENDOOR;//有当前楼层请求,则下一状态转开门
else if(request_all>pos)//有当前楼层之上的停靠请求否(优先向上的请求)
NextState=UP;//有则,下一状态转上升
else
NextState=DOWN;//只有当前楼层之下的停靠请求,下一状态转下降
end
else if((up_all&pos)||(down_all&pos))//上下请求中有当前楼层请求否
begin
NextState=OPENDOOR;
end
else if((up_all>pos)||(down_all>pos))//上下请求中有当前楼层之上的请求否
NextState=UP;
else if(up_all||down_all)//上下请求中有当前楼层之下的请求否
NextState=DOWN;
else
NextState=WAIT;//无任何请求,继续处于WAIT模式
end
UP:
begin
if((request_all&pos)||(up_all&pos))//停靠或上升请求中有当前楼层的请求否
NextState=UPSTOP;//有,下一状态转为UPSTOP(停靠后要1s才开门,UPSTOP即为这1s的过渡期)
else if((request_all>pos)||(up_all>pos))//停靠或上升请求中有当前楼层之上的请求否
NextState=UP;
else if(down_all>0)//有下降请求否
begin
if((down_all>pos)&&((down_all^pos)>pos))//下降请求中有当前楼层的请求否
NextState=UP;
else if((down_all&pos)||(pos<FLOOR6)) //其实这样做意义不大,只是使上下标志提前变化
NextState=UPSTOP;
else if((down_all&pos)&&(pos==FLOOR6))//事实上不满足第一条件的话,电梯根本不会到达第四层
NextState=DOWNSTOP;
else//下降请求中只有当前楼层之下的请求
NextState=DOWN;
end
else if(request_all||up_all)//只有当前楼层之上的停靠或上升请求否
NextState=DOWN;
else
NextState=WAIT;//无任何请求,转为WAIT模式
end
//DOWN的状态转移请参见UP的状态转移
DOWN:
begin
if((request_all&pos)||(down_all&pos))
NextState=DOWNSTOP;
else if(((request_all&FLOOR1)<pos&&(request_all&FLOOR1))||((request_all&FLOOR2)<pos&&(request_all&FLOOR2))||((request_all&FLOOR3)<pos&&(request_all&FLOOR3))||((request_all&FLOOR4)<pos&&(request_all&FLOOR4))||((request_all&FLOOR5)<pos&&(request_all&FLOOR5))||((request_all&FLOOR6)<pos&&(request_all&FLOOR6)))
NextState=DOWN;
else if(((down_all&FLOOR1)<pos&&(down_all&FLOOR1))||((down_all&FLOOR2)<pos&&(down_all&FLOOR2))||((down_all&FLOOR3)<pos&&(down_all&FLOOR3))||((down_all&FLOOR4)<pos&&(down_all&FLOOR4))||((down_all&FLOOR5)<pos&&(down_all&FLOOR5))||((down_all&FLOOR6)<pos&&(down_all&FLOOR6)))
NextState=DOWN;
else if(up_all>0)
begin
if(((up_all&FLOOR1)<pos&&(up_all&FLOOR1))||((up_all&FLOOR2)<pos&&(up_all&FLOOR2))||((up_all&FLOOR3)<pos&&(up_all&FLOOR3))||((up_all&FLOOR4)<pos&&(up_all&FLOOR4))||((up_all&FLOOR5)<pos&&(up_all&FLOOR5))||((up_all&FLOOR6)<pos&&(up_all&FLOOR6)))
NextState=DOWN;
else if((up_all&pos)&&(pos>FLOOR1))
NextState=DOWNSTOP;
else if((up_all&pos)&&(pos==FLOOR1))
NextState=UPSTOP;
else
NextState=UP;
end
else if(request_all||down_all)
NextState=UP;
else
NextState=WAIT;
end
UPSTOP:
begin
NextState=OPENDOOR;//停靠1时钟周期后开门
end
DOWNSTOP:
begin
NextState=OPENDOOR;//停靠1时钟周期后开门
end
OPENDOOR:
begin
if(count<5)//开门不足5周期,则继续转移到开门状态
NextState=OPENDOOR;
else
NextState=CLOSEDOOR;//开门5周期后,关门
end
CLOSEDOOR:
begin
if(UpDnFlag==UPFLAG)//开门关门前电梯是处于上升状态吗
begin
if((request_all&pos)||(up_all&pos))//上升或停靠请求中有当前楼层的请求否,有可能关门的瞬间又有新的请求
NextState=OPENDOOR;
else if((request_all>pos)||(up_all>pos))//上升或停靠请求中有当前楼层之上的请求否
NextState=UP;
else if(down_all>0)//有下降请求否
begin
if((down_all>pos)&&((down_all^pos)>pos))
NextState=UP;//有当前楼层之上的下降请求,则下一状态转移上升
else if((down_all&pos)>0)//有当前楼层的下降请求信号,且更上层无下降请求
NextState=OPENDOOR;
else//只有低于当前层的下降请求
NextState=DOWN;
end
else if(request_all||up_all)//上升和停靠请求中有当前层的请求且只有当前层下的请求
NextState=DOWN;
else
NextState=WAIT;//无任何请求,转为WAIT模式
end
//请参考UpDnFlag=UPFLAG的注释
else if(UpDnFlag==DNFLAG)
begin
if((request_all&pos)||(down_all&pos))
NextState=OPENDOOR;
else if(((request_all&FLOOR1)<pos&&(request_all&FLOOR1))||((request_all&FLOOR2)<pos&&(request_all&FLOOR2))||((request_all&FLOOR3)<pos&&(request_all&FLOOR3))||((request_all&FLOOR4)<pos&&(request_all&FLOOR4))||((request_all&FLOOR5)<pos&&(request_all&FLOOR5))||((request_all&FLOOR6)<pos&&(request_all&FLOOR6)))
NextState=DOWN;
else if(((down_all&FLOOR1)<pos&&(down_all&FLOOR1))||((down_all&FLOOR2)<pos&&(down_all&FLOOR2))||((down_all&FLOOR3)<pos&&(down_all&FLOOR3))||((down_all&FLOOR4)<pos&&(down_all&FLOOR4))||((down_all&FLOOR5)<pos&&(down_all&FLOOR5))||((down_all&FLOOR6)<pos&&(down_all&FLOOR6)))
NextState=DOWN;
else if(up_all>0)
begin
if(((up_all&FLOOR1)<pos&&(up_all&FLOOR1))||((up_all&FLOOR2)<pos&&(up_all&FLOOR2))||((up_all&FLOOR3)<pos&&(up_all&FLOOR3))||((up_all&FLOOR4)<pos&&(up_all&FLOOR4))||((up_all&FLOOR5)<pos&&(up_all&FLOOR5))||((up_all&FLOOR6)<pos&&(up_all&FLOOR6)))
NextState=DOWN;
else if((up_all&pos)>0)
NextState=OPENDOOR;
else
NextState=UP;//
end
else if(request_all||down_all)
NextState=UP;
else
NextState=WAIT;//
end
//请参考WAIT模式的注释
else
begin
if(request_all>0)
begin
if((request_all&pos)>0)
NextState=OPENDOOR;
else if(request_all>pos)
NextState=UP;
else
NextState=DOWN;
end
else if((up_all&pos)||(down_all&pos))
begin
NextState=OPENDOOR;
end
else if((up_all>pos)||(down_all>pos))
NextState=UP;
else if(up_all||down_all)
NextState=DOWN;
else
begin
NextState=WAIT;
end
end
end
default:
NextState=WAIT;
endcase
//3rd StateShift always block,the sequential FSM output,有限状态机第三段
always @(posedge real_clk or posedge reset)//output
if(reset)
//复位后初始化当前楼层为第一层,门是关闭的,电梯是静止的
begin
pos<=FLOOR1;
DoorFlag<=CLOSED;
UpDnFlag<=STATIC;
end
else
begin
PosOut<=pos;//PosOut的输出慢pos一个时钟周期
case(NextState)
WAIT:
//状态为WAIT时,楼层不变,门是关闭的,电梯是静止的,其他模式的情况请大家自己推导
begin
pos<=pos;
DoorFlag<=CLOSED;
UpDnFlag<=STATIC;
end
UP:
begin
pos<=pos<<1;
DoorFlag<=CLOSED;
UpDnFlag<=UPFLAG;
end
DOWN:
begin
pos<=pos>>1;
DoorFlag<=CLOSED;
UpDnFlag<=DNFLAG;
end
UPSTOP:
begin
pos<=pos;
DoorFlag<=CLOSED;
UpDnFlag<=UPFLAG;
end
DOWNSTOP:
begin
pos<=pos;
DoorFlag<=CLOSED;
UpDnFlag<=DNFLAG;
end
OPENDOOR:
begin
pos<=pos;
DoorFlag<=OPEN;
UpDnFlag<=UpDnFlag;
end
CLOSEDOOR:
begin
pos<=pos;
DoorFlag<=CLOSED;
UpDnFlag<=UpDnFlag;
end
default:
//默认情况
begin
pos<=FLOOR1;
DoorFlag<=CLOSED;
UpDnFlag<=STATIC;
end
endcase
end
endmodule
5.3 数码管译码模块
module display_decode(cp_50M,in,out,over_alarm);
input [5:0]in;
input cp_50M;
output [6:0]out;
output over_alarm;
reg [6:0]out;
reg over_alarm;
always@(posedge cp_50M)
begin
case(in)
6'b000000ut<=7'b100_0000;//0
6'b000001ut<=7'b111_1001;//1
6'b000010ut<=7'b010_0100;//2
6'b000100:out<=7'b011_0000;//3
6'b001000:out<=7'b001_1001;//4
6'b010000:out<=7'b001_0010;//5
6'b100000:out<=7'b000_0010;//6
default:over_alarm<=1;
endcase
end
endmodule
5.4 数码管时间译码模块
module display_decode_count(cp_50M,in,count_out);
input [2:0]in;
input cp_50M;
output [6:0] count_out;
reg [6:0] count_out;
always@(posedge cp_50M)
begin
case(in)
3'b000:count_out<=7'b100_0000;//0
3'b001:count_out<=7'b111_1001;//1
3'b010:count_out<=7'b010_0100;//2
3'b011:count_out<=7'b011_0000;//3
3'b100:count_out<=7'b001_1001;//4
3'b101:count_out<=7'b001_0010;//5
3'b110:count_out<=7'b000_0010;//6
default:
;
endcase
end
endmodule
note:由于以上两个模块都比较的简单,故不作详细的注释,而且我在前面也提到了设计思想,应该不是很难理解。
5.5 LCD仲裁器
module arbitrator(elevator_state,count_in,open_enable,stop_enable,up_enable,down_enable,close_enable);
input [6:0]elevator_state;//电梯状态
input [2:0]count_in;//计数器输出
output open_enable,stop_enable,up_enable,down_enable,close_enable;//输出LCD驱动命令信号
assign open_enable=(count_in!=0);//当这在计数时,电梯应该是开门的
assign close_enable=(elevator_state==7'b1000000);//电梯关门
assign stop_enable=((elevator_state==7'b0000001)||(elevator_state==7'b0001000)||(elevator_state==7'b0010000));//只要满足一种情况电梯都应是处于停止等待状态
assign up_enable=(elevator_state==7'b0000010); //上升
assign down_enable=(elevator_state==7'b0000100);//下降
endmodule
5.6 LCD驱动模块
module DE2_Default
(
//////////////////// Clock Input ////////////////////
open_enable,stop_enable,up_enable,down_enable,close_enable,
CLOCK_50, // 50 MHz
KEY,
//////////////////// LCD Module 16X2 ////////////////
LCD_ON, // LCD Power ON/OFF
LCD_BLON, // LCD Back Light ON/OFF
LCD_RW, // LCD Read/Write Select, 0 = Write, 1 = Read
LCD_EN, // LCD Enable
LCD_RS, // LCD Command/Data Select, 0 = Command, 1 = Data
LCD_DATA // LCD Data bus 8 bits
);
//////////////////////// Clock Input ////////////////////////
input open_enable,stop_enable,up_enable,down_enable,close_enable;
input CLOCK_50; // 50 MHz
input KEY;
//////////////////// LCD Module 16X2 ////////////////////////////
inout [7:0] LCD_DATA; // LCD Data bus 8 bits
output LCD_ON; // LCD Power ON/OFF
output LCD_BLON; // LCD Back Light ON/OFF
output LCD_RW; // LCD Read/Write Select, 0 = Write, 1 = Read
output LCD_EN; // LCD Enable
output LCD_RS; // LCD Command/Data Select, 0 = Command, 1 = Data
// LCD ON
assign LCD_ON = 1'b1;
assign LCD_BLON = 1'b1;
reg [31:0] Cont;
wire DLY_RST;
always@(posedge CLOCK_50 or negedge KEY)
begin
if(!KEY)
Cont <= 0;
else
Cont <= Cont+1;
end
Reset_Delay r0 ( .iCLK(CLOCK_50),.oRESET(DLY_RST) );
LCD_TEST u5 ( // Host Side
.iCLK(CLOCK_50),
.iRST_N(DLY_RST),
.iup_enable(up_enable),
.idown_enable(down_enable),
.iclose_enable(close_enable),
.iopen_enable(open_enable),
.istop_enable(stop_enable),
// LCD Side
.LCD_DATA(LCD_DATA),
.LCD_RW(LCD_RW),
.LCD_EN(LCD_EN),
.LCD_RS(LCD_RS) );
endmodule
5.7 LCD控制模块
module LCD_Controller ( // Host Side
iDATA,iRS,
iStart,oDone,
iCLK,iRST_N,
// LCD Interface
LCD_DATA,
LCD_RW,
LCD_EN,
LCD_RS );
// CLK
parameter CLK_Divide = 16;
// Host Side
input [7:0] iDATA;
input iRS,iStart;
input iCLK,iRST_N;
output reg oDone;
// LCD Interface
output [7:0] LCD_DATA;
output reg LCD_EN;
output LCD_RW;
output LCD_RS;
// Internal Register
reg [4:0] Cont;
reg [1:0] ST;
reg preStart,mStart;
/////////////////////////////////////////////
// Only write to LCD, bypass iRS to LCD_RS
assign LCD_DATA = iDATA;
assign LCD_RW = 1'b0;
assign LCD_RS = iRS;
/////////////////////////////////////////////
always@(posedge iCLK or negedge iRST_N)
begin
if(!iRST_N)
begin
oDone <= 1'b0;
LCD_EN <= 1'b0;
preStart<= 1'b0;
mStart <= 1'b0;
Cont <= 0;
ST <= 0;
end
else
begin
////// Input Start Detect ///////
preStart<= iStart;
if({preStart,iStart}==2'b01)
begin
mStart <= 1'b1;
oDone <= 1'b0;
end
//////////////////////////////////
if(mStart)
begin
case(ST)
0: ST <= 1; // Wait Setup
1: begin
LCD_EN <= 1'b1;
ST <= 2;
end
2: begin
if(Cont<CLK_Divide)
Cont <= Cont+1;
else
ST <= 3;
end
3: begin
LCD_EN <= 1'b0;
mStart <= 1'b0;
oDone <= 1'b1;
Cont <= 0;
ST <= 0;
end
endcase
end
end
end
endmodule
5.8 LCD显示模块
module LCD_TEST ( // Host Side
iCLK,iRST_N,iopen_enable,iup_enable,
idown_enable,iclose_enable,istop_enable,
// LCD Side
LCD_DATA,LCD_RW,LCD_EN,LCD_RS );
// Host Side
input iCLK,iRST_N;
input idown_enable,iclose_enable,istop_enable,iopen_enable,iup_enable;
// LCD Side
output [7:0] LCD_DATA;
output LCD_RW,LCD_EN,LCD_RS;
// Internal Wires/Registers
reg [5:0] LUT_INDEX;
reg [8:0] LUT_DATA;
reg [5:0] mLCD_ST;
reg [17:0] mDLY;
reg mLCD_Start;
reg [7:0] mLCD_DATA;
reg mLCD_RS;
reg ok;
wire mLCD_Done;
parameter LCD_INTIAL = 0;
parameter LCD_LINE1 = 5;
parameter LCD_CH_LINE = LCD_LINE1+16;
parameter LCD_LINE2 = LCD_LINE1+16+1;
parameter LUT_SIZE = LCD_LINE1+32+1;
always@(posedge iCLK or negedge iRST_N)
begin
if(!iRST_N)
begin
LUT_INDEX <= 0;
mLCD_ST <= 0;
mDLY <= 0;
mLCD_Start <= 0;
mLCD_DATA <= 0;
mLCD_RS <= 0;
end
else
begin
if(LUT_INDEX<LUT_SIZE)
begin
case(mLCD_ST)
0: begin
mLCD_DATA <= LUT_DATA[7:0];
mLCD_RS <= LUT_DATA[8];
mLCD_Start <= 1;
mLCD_ST <= 1;
end
1: begin
if(mLCD_Done)
begin
mLCD_Start <= 0;
mLCD_ST <= 2;
end
end
2: begin
if(mDLY<18'h00008)
mDLY <= mDLY+1;
else
begin
mDLY <= 0;
mLCD_ST <= 3;
end
end
3: begin
LUT_INDEX <= LUT_INDEX+1;
mLCD_ST <= 0;
end
endcase
end
else //如果已发完第一遍数据,就刷新
begin
LUT_INDEX <= 0;
end
end
end
always
begin
if(iopen_enable)//如果LCD仲裁器的“开门使能”有效就执行:
case(LUT_INDEX)
// Initial
LCD_INTIAL+0: LUT_DATA <= 9'h038;
LCD_INTIAL+1: LUT_DATA <= 9'h00C;
LCD_INTIAL+2: LUT_DATA <= 9'h001;
LCD_INTIAL+3: LUT_DATA <= 9'h006;
LCD_INTIAL+4: LUT_DATA <= 9'h080;
// Line 1
LCD_LINE1+0: LUT_DATA <= 9'h120; //
LCD_LINE1+1: LUT_DATA <= 9'b1_0110_0100; //d // door is open..
LCD_LINE1+2: LUT_DATA <= 9'b1_0110_1111; //o
LCD_LINE1+3: LUT_DATA <= 9'b1_0110_1111; //o
LCD_LINE1+4: LUT_DATA <= 9'b1_0111_0010; //r
LCD_LINE1+5: LUT_DATA <= 9'h120; //
LCD_LINE1+6: LUT_DATA <= 9'b1_0110_1001; //i
LCD_LINE1+7: LUT_DATA <= 9'b1_0111_0011; //s
LCD_LINE1+8: LUT_DATA <= 9'h120; //
LCD_LINE1+9: LUT_DATA <= 9'b1_0110_1111; //o
LCD_LINE1+10: LUT_DATA <= 9'b1_0111_0000; //p
LCD_LINE1+11: LUT_DATA <= 9'b1_0110_0101; //e
LCD_LINE1+12: LUT_DATA <= 9'b1_0110_1110; //n
LCD_LINE1+13: LUT_DATA <= 9'b1_0010_1110; //.
LCD_LINE1+14: LUT_DATA <= 9'b1_0010_1110; //.
LCD_LINE1+15: LUT_DATA <= 9'h120; //
default: LUT_DATA <= 9'h000;
endcase
else if(idown_enable) //如果LCD仲裁器的“下降使能”有效就执行:
case(LUT_INDEX)
// Initial
LCD_INTIAL+0: LUT_DATA <= 9'h038;
LCD_INTIAL+1: LUT_DATA <= 9'h00C;
LCD_INTIAL+2: LUT_DATA <= 9'h001;
LCD_INTIAL+3: LUT_DATA <= 9'h006;
LCD_INTIAL+4: LUT_DATA <= 9'h080;
// Line 1
LCD_LINE1+0: LUT_DATA <= 9'h120;//
LCD_LINE1+1: LUT_DATA <= 9'b1_0110_1001;//i // it is falling..
LCD_LINE1+2: LUT_DATA <= 9'b1_0111_0100;//t
LCD_LINE1+3: LUT_DATA <= 9'h120;//
LCD_LINE1+4: LUT_DATA <= 9'b1_0110_1001;//i
LCD_LINE1+5: LUT_DATA <= 9'b1_0111_0011;//s
LCD_LINE1+6: LUT_DATA <= 9'h120;//
LCD_LINE1+7: LUT_DATA <= 9'b1_0110_0110;//f
LCD_LINE1+8: LUT_DATA <= 9'b1_0110_0001;//a
LCD_LINE1+9: LUT_DATA <= 9'b1_0110_1100;//l
LCD_LINE1+10: LUT_DATA <= 9'b1_0110_1100;//l
LCD_LINE1+11: LUT_DATA <= 9'b1_0110_1001;//i
LCD_LINE1+12: LUT_DATA <= 9'b1_0110_1110;//n
LCD_LINE1+13: LUT_DATA <= 9'b1_0110_0111;//g
LCD_LINE1+14: LUT_DATA <= 9'b1_0010_1110;//.
LCD_LINE1+15: LUT_DATA <= 9'b1_0010_1110;//.
default: LUT_DATA <= 9'h000;
endcase
else if(iup_enable) //如果LCD仲裁器的“上升使能”有效就执行:
case(LUT_INDEX)
// Initial
LCD_INTIAL+0: LUT_DATA <= 9'h038;
LCD_INTIAL+1: LUT_DATA <= 9'h00C;
LCD_INTIAL+2: LUT_DATA <= 9'h001;
LCD_INTIAL+3: LUT_DATA <= 9'h006;
LCD_INTIAL+4: LUT_DATA <= 9'h080;
// Line 1
LCD_LINE1+0: LUT_DATA <= 9'h120;//
LCD_LINE1+1: LUT_DATA <= 9'b1_0110_1001;//i // it is rising..
LCD_LINE1+2: LUT_DATA <= 9'b1_0111_0100;//t
LCD_LINE1+3: LUT_DATA <= 9'h120;//
LCD_LINE1+4: LUT_DATA <= 9'b1_0110_1001;//i
LCD_LINE1+5: LUT_DATA <= 9'b1_0111_0011;//s
LCD_LINE1+6: LUT_DATA <= 9'h120;//
LCD_LINE1+7: LUT_DATA <= 9'b1_0111_0010;//r
LCD_LINE1+8: LUT_DATA <= 9'b1_0110_1001;//i
LCD_LINE1+9: LUT_DATA <= 9'b1_0111_0011;//s
LCD_LINE1+10: LUT_DATA <= 9'b1_0110_1001;//i
LCD_LINE1+11: LUT_DATA <= 9'b1_0110_1110;//n
LCD_LINE1+12: LUT_DATA <= 9'b1_0110_0111;//g
LCD_LINE1+13: LUT_DATA <= 9'b1_0010_1110;//.
LCD_LINE1+14: LUT_DATA <= 9'b1_0010_1110;//.
LCD_LINE1+15: LUT_DATA <= 9'h120;//
default: LUT_DATA <= 9'h000;
endcase
else if(istop_enable) //如果LCD仲裁器的“停止等待使能”有效就执行:
case(LUT_INDEX)
// Initial
LCD_INTIAL+0: LUT_DATA <= 9'h038;
LCD_INTIAL+1: LUT_DATA <= 9'h00C;
LCD_INTIAL+2: LUT_DATA <= 9'h001;
LCD_INTIAL+3: LUT_DATA <= 9'h006;
LCD_INTIAL+4: LUT_DATA <= 9'h080;
// Line 1
LCD_LINE1+0: LUT_DATA <= 9'h120;//
LCD_LINE1+1: LUT_DATA <= 9'b1_0110_1001;//i // it is static..
LCD_LINE1+2: LUT_DATA <= 9'b1_0111_0100;//t
LCD_LINE1+3: LUT_DATA <= 9'h120;//
LCD_LINE1+4: LUT_DATA <= 9'b1_0110_1001;//i
LCD_LINE1+5: LUT_DATA <= 9'b1_0111_0011;//s
LCD_LINE1+6: LUT_DATA <= 9'h120;//
LCD_LINE1+7: LUT_DATA <= 9'b1_0111_0011;//s
LCD_LINE1+8: LUT_DATA <= 9'b1_0111_0100;//t
LCD_LINE1+9: LUT_DATA <= 9'b1_0110_0001;//a
LCD_LINE1+10: LUT_DATA <= 9'b1_0111_0100;//t
LCD_LINE1+11: LUT_DATA <= 9'b1_0110_1001;//i
LCD_LINE1+12: LUT_DATA <= 9'b1_0110_0011;//c
LCD_LINE1+13: LUT_DATA <= 9'b1_0010_1110;//.
LCD_LINE1+14: LUT_DATA <= 9'b1_0010_1110;//.
LCD_LINE1+15: LUT_DATA <= 9'h120;//
default: LUT_DATA <= 9'h000;
endcase
else if(iclose_enable) //如果LCD仲裁器的“关门使能”有效就执行:
case(LUT_INDEX)
// Initial
LCD_INTIAL+0: LUT_DATA <= 9'h038;
LCD_INTIAL+1: LUT_DATA <= 9'h00C;
LCD_INTIAL+2: LUT_DATA <= 9'h001;
LCD_INTIAL+3: LUT_DATA <= 9'h006;
LCD_INTIAL+4: LUT_DATA <= 9'h080;
// Line 1
LCD_LINE1+0: LUT_DATA <= 9'h120;//
LCD_LINE1+1: LUT_DATA <= 9'b1_0110_0100;//d // door is close..
LCD_LINE1+2: LUT_DATA <= 9'b1_0110_1111;//o
LCD_LINE1+3: LUT_DATA <= 9'b1_0110_1111;//o
LCD_LINE1+4: LUT_DATA <= 9'b1_0111_0010;//r
LCD_LINE1+5: LUT_DATA <= 9'h120;//
LCD_LINE1+6: LUT_DATA <= 9'b1_0110_1001;//i
LCD_LINE1+7: LUT_DATA <= 9'b1_0111_0011;//s
LCD_LINE1+8: LUT_DATA <= 9'h120;//
LCD_LINE1+9: LUT_DATA <= 9'b1_0110_0011;//c
LCD_LINE1+10: LUT_DATA <= 9'b1_0110_1100;//l
LCD_LINE1+11: LUT_DATA <= 9'b1_0110_1111;//o
LCD_LINE1+12: LUT_DATA <= 9'b1_0111_0011;//s
LCD_LINE1+13: LUT_DATA <= 9'b1_0110_0101;//e
LCD_LINE1+14: LUT_DATA <= 9'b1_0010_1110;//.
LCD_LINE1+15: LUT_DATA <= 9'b1_0010_1110;//.
default: LUT_DATA <= 9'h000;
endcase
else //默认的情况
case(LUT_INDEX)
// Initial
LCD_INTIAL+0: LUT_DATA <= 9'h038;
LCD_INTIAL+1: LUT_DATA <= 9'h00C;
LCD_INTIAL+2: LUT_DATA <= 9'h001;
LCD_INTIAL+3: LUT_DATA <= 9'h006;
LCD_INTIAL+4: LUT_DATA <= 9'h080;
// Line 1
LCD_LINE1+0: LUT_DATA <= 9'h120;//
LCD_LINE1+1: LUT_DATA <= 9'b1_0110_1001;//i // it is static..
LCD_LINE1+2: LUT_DATA <= 9'b1_0111_0100;//t
LCD_LINE1+3: LUT_DATA <= 9'h120;//
LCD_LINE1+4: LUT_DATA <= 9'b1_0110_1001;//i
LCD_LINE1+5: LUT_DATA <= 9'b1_0111_0011;//s
LCD_LINE1+6: LUT_DATA <= 9'h120;//
LCD_LINE1+7: LUT_DATA <= 9'b1_0111_0011;//s
LCD_LINE1+8: LUT_DATA <= 9'b1_0111_0100;//t
LCD_LINE1+9: LUT_DATA <= 9'b1_0110_0001;//a
LCD_LINE1+10: LUT_DATA <= 9'b1_0111_0100;//t
LCD_LINE1+11: LUT_DATA <= 9'b1_0110_1001;//i
LCD_LINE1+12: LUT_DATA <= 9'b1_0110_0011;//c
LCD_LINE1+13: LUT_DATA <= 9'b1_0010_1110;//.
LCD_LINE1+14: LUT_DATA <= 9'b1_0010_1110;//.
LCD_LINE1+15: LUT_DATA <= 9'h120;//
default: LUT_DATA <= 9'h000;
endcase
end
LCD_Controller u0 ( // Host Side
.iDATA(mLCD_DATA),
.iRS(mLCD_RS),
.iStart(mLCD_Start),
.oDone(mLCD_Done),
.iCLK(iCLK),
.iRST_N(iRST_N),
// LCD Interface
.LCD_DATA(LCD_DATA),
.LCD_RW(LCD_RW),
.LCD_EN(LCD_EN),
.LCD_RS(LCD_RS) );
Endmodule |
|