利用电话远程系统

源代码在线查看: phone control.v

软件大小: 4 K
上传用户: renyumeng
关键词: 电话远程
下载地址: 免注册下载 普通下载 VIP

相关代码

				////////////////////////////////////////////////////////////				// phone control.v				// 				// created 2008.10.07				// Author : dreamstar at VLSI & Integrated System Lab Of BJUT.				///////////////////////////////////////////////////////////												`timescale 1ns/10ps								 module phone_control(clk,rst,enable,dtmf_high,dtmf_low,dtmf_data,playl,				           tele_on,isd_addr,led1,led2,clr,dtmf_clr,				           tstate,pass_counter,wrong_time,dtmf_con);				 				 output [2:0] tstate;   //STATE REGISTER;				 				 output [2:0] pass_counter;  //PASSWORD COUNTER;				 output [1:0] wrong_time;    //PASSWORD WRONG INPUT TIMES;				 output [3:0] dtmf_con;      //control number				 				 input clk;				 input enable;   //ring_c enable				 input rst;				 input dtmf_high;   //DTMF CODING COMPLETE INDICATION;				 input dtmf_low;				 input [3:0] dtmf_data;  //DTMF CODING DATA;				 				 output clr;      //ring_c clear;				 output dtmf_clr; //dtmf clear;				 output playl;    //ISE1420 PLAY CONTROL;				 output tele_on;  //telephone open;				 output [7:0] isd_addr;  //ISD ADDRESS;				 output led1;				 output led2;				 				 reg clr;				 reg dtmf_clr;				 reg playl;				 reg tele_on;				 reg [7:0] isd_addr;				 reg led1;				 reg led2;				 				 reg [2:0] tstate;   //STATE REGISTER;				 reg [2:0] ring_counter;  //RING COUNTER;				 reg [3:0] dtmf [3:0];    //DTMF PASSWORD MEMORY;				 reg [2:0] pass_counter;  //PASSWORD COUNTER;				 reg [1:0] wrong_time;    //PASSWORD WRONG INPUT TIMES;				 reg [3:0] dtmf_con;      //control number				 reg sel;				  				 parameter idle             =3'b000;				 parameter phone_on         =3'b001;				 parameter password_check   =3'b010;				 parameter password_wrong1  =3'b011;				 parameter password_wrong2  =3'b100;				 parameter phone_off        =3'b101; 				 parameter receive_control  =3'b110;				 				 parameter password1=4'b0001;				 parameter password2=4'b0010;				 parameter password3=4'b0011;				 parameter password4=4'b0100;				 				 				  				 always@(posedge clk or negedge rst)				   begin				    if(rst==0)				     begin				         tstate       				         tele_on      				         playl        				         isd_addr     				         clr          				         dtmf[0]      				         dtmf[1]      				         dtmf[2]      				         dtmf[3]      				         pass_counter 				         wrong_time   				         led1         				         led2         				         dtmf_clr     				       end				    else				     begin				     case(tstate)				     idle: begin				           if (enable==1'b1)				             begin				                 tele_on      				                 tstate       				                 isd_addr     				                 playl        				                 clr          				             end				           else				                 tstate       				          end				             				      phone_on:  				           begin				               if (dtmf_high==1'b1)				                 begin				                   dtmf[pass_counter] 				                   pass_counter       				                   playl              				                   dtmf_clr           				                 end				               else if (dtmf_low==1'b1)				                 dtmf_clr  				               else if (pass_counter==3'b100)				                    begin				                      tstate       				                      pass_counter 				                    end				               else 				                    tstate  				          end				                        				      password_check:    				      begin				        if(dtmf[0]==password1 & dtmf[1]==password2 &				           dtmf[2]==password3 & dtmf[3]==password4)				          begin				              tstate      				              wrong_time  				              isd_addr    				              playl       				              clr         				          end				        else if (wrong_time==2'b00)				          begin				              tstate      				              wrong_time  				              isd_addr    				              playl       				          end				        else if (wrong_time==2'b01)				          begin				              tstate      				              wrong_time  				              isd_addr    				              playl       				          end				        else				          begin				              tstate      				              wrong_time  				              isd_addr    				              playl       				          end				      end				                       				      password_wrong1:   				      begin				           if (dtmf_high==1'b1)				              begin				                  dtmf[pass_counter] 				                  pass_counter       				                  playl              				                  dtmf_clr           				              end				           else if (dtmf_low==1'b1)				               dtmf_clr  				           else if (pass_counter==3'b100)				              begin				                  tstate          				                  pass_counter    				              end				           else				              tstate				          end				         				      password_wrong2: 				         begin				             if (dtmf_high==1'b1)				               begin				                   dtmf[pass_counter]  				                   pass_counter        				                   playl               				                   dtmf_clr            				               end				             else if (dtmf_low==1'b1)				                 dtmf_clr   				             else if (pass_counter==3'b100)				               begin				                   tstate          				                   pass_counter    				               end				             else				               tstate 				           end				               				      phone_off:  				      begin				           // if (dtmf_high==1'b1)				              // begin				              //     playl    				             //      tele_on  				            //   end				            // else				        tele_on 				        tstate  				     end				               				      receive_control:				         begin				            if (dtmf_high==1)				            begin				                dtmf_con  				                dtmf_clr  				            end				            else if(dtmf_low==1'b1)				                dtmf_clr  				            else if (dtmf_con==4'b0001)				               begin				                   led1   				                   tstate 				               end				            else if (dtmf_con==4'b0010)				               begin				                   led2   				                   tstate 				               end				            else				                tstate 				         end				    				      default: tstate 				  endcase				  end				  end				  endmodule				  				 				  				          			

相关资源