本帖最后由 何立立 于 2015-7-5 20:06 编辑
本实验RTL原理图如下:
sos_module.v 如字面上的意思,是产生“SOS信号”的“功能模块”。但是看简单一点,就是有次序的控制输出莫斯密码的“点”,“画”和“间隔”。而 control_module.v 是一个简单的定时触发器,每一段时间都会使能sos_module.v。
在这里稍微认识一下“摩斯密码"的基本三个元素:
英文字母“S”是 “. . .”,亦即三个短音节之中夹杂间隔。而英文字母“O”是“_ _ _”,亦即三个长音节之中夹杂间隔。所以SOS形成了“ . . . _ _ _ . . . ”
下面给出实验代码:
顶层模块sos_generator_module:
- module sos_generator_module
- (
- CLK,Pin_Out
- );
- input CLK;
-
- output Pin_Out;
- /****************************/
- wire SOS_En_Sig;
- control_module U1
- (
- .CLK( CLK ),
- .SOS_En_Sig( SOS_En_Sig )
- );
- wire Pin_Out_Wire;
- sos_module U2
- (
- .CLK( CLK ),
-
- .SOS_En_Sig( SOS_En_Sig ),
- .Pin_Out( Pin_Out_Wire )
- );
- /******************************/
- assign Pin_Out = !Pin_Out_Wire;
- /******************************/
- endmodule
control_module:
- module control_module
- (
- CLK,SOS_En_Sig
- );
- input CLK;
- output SOS_En_Sig;
- /********************************/
- parameter T3S = 26'd35_997_000;
- /********************************/
- reg isEn=1'b0;
- reg [25:0]Count1=26'd0;
-
- always @ ( posedge CLK )
- begin
- if( Count1 == T3S )
- begin
- isEn <= 1'b1;
- Count1 <= 26'd0;
- end
- else
- begin
- isEn <= 1'b0;
- Count1 <= Count1 + 1'b1;
- end
- end
- /*****************************************/
- assign SOS_En_Sig = isEn;
- /*****************************************/
- endmodule
sos_module:
- module sos_module
- (
- CLK, Pin_Out, SOS_En_Sig
- );
- input CLK;
- input SOS_En_Sig;
- output Pin_Out;
- /****************************************/
- parameter T1MS = 16'd11_999;//1ms
- /***************************************/
- reg [15:0]Count1=16'd0;;
- always @ ( posedge CLK )
- begin
- if( isCount && Count1 == T1MS )
- Count1 <= 16'd0;
- else if( isCount )
- Count1 <= Count1 + 1'b1;
- else if( !isCount )
- Count1 <= 16'd0;
- end
- /****************************************/
- reg [9:0]Count_MS= 10'd0;
- always @ ( posedge CLK )
- begin
- if( isCount && Count1 == T1MS )
- Count_MS <= Count_MS + 1'b1;
- else if( !isCount )
- Count_MS <= 10'd0;
- end
- /******************************************/
- reg isCount= 1'b0;
- reg rPin_Out= 1'b0;;
- reg [4:0]i=5'd0;
- always @ ( posedge CLK )
- begin
- case( i )
- 5'd0 :
- if( SOS_En_Sig ) i <= 5'd1;
- 5'd1, 5'd3, 5'd5,5'd13, 5'd15, 5'd17 :
- if( Count_MS == 10'd100 ) begin isCount <= 1'b0; rPin_Out <= 1'b0; i <= i + 1'b1; end // short
- else begin isCount <= 1'b1; rPin_Out <= 1'b1; end
- 5'd7, 5'd9, 5'd11 :
- if( Count_MS == 10'd300 ) begin isCount <= 1'b0; rPin_Out <= 1'b0; i <= i + 1'b1; end // long
- else begin isCount <= 1'b1; rPin_Out <= 1'b1; end
- 5'd2, 5'd4, 5'd6, 5'd8, 5'd10, 5'd12, 5'd14, 5'd16, 5'd18 :
- if( Count_MS == 10'd50 ) begin isCount <= 1'b0; i <= i + 1'b1; end// interval
- else isCount <= 1'b1;
- 5'd19 :
- begin rPin_Out <= 1'b0; i <= 5'd0; end // end
- endcase
- end
- /***************************************************/
- assign Pin_Out = rPin_Out;
- /***************************************************/
- endmodule
拐角约束文件:
- NET "CLK" LOC = U14;
- NET "Pin_Out" LOC = P18;
下载到z-turn board 后你会听到:‘’嘀嘀嘀 哒哒哒 嘀嘀嘀‘’的声音。