SOS信号:. . . _ _ _ . . .

1.

module sos_module
(
CLK, RSTn, Pin_Out, SOS_En_Sig
); input CLK;
input RSTn;
input SOS_En_Sig;
output Pin_Out; /****************************************/ parameter T1MS = 'd49_999;//DB4CE15开发板使用的晶振为50MHz,50M*0.001-1=49_999 /***************************************/ reg [:]Count1; always @ ( posedge CLK or negedge RSTn )
if( !RSTn )
Count1 <= 'd0;
else if( isCount && Count1 == T1MS )
Count1 <= 'd0;
else if( isCount )
Count1 <= Count1 + 'b1;
else if( !isCount )
Count1 <= 'd0; /****************************************/ reg [:]Count_MS; always @ ( posedge CLK or negedge RSTn )
if( !RSTn )
Count_MS <= 'd0;
else if( isCount && Count1 == T1MS )
Count_MS <= Count_MS + 'b1;
else if( !isCount )
Count_MS <= 'd0; /******************************************/ reg isCount;
reg rPin_Out;
reg [:]i; always @ ( posedge CLK or negedge RSTn )
if( !RSTn )
begin
isCount <= 'b0;
rPin_Out <= 'b0;
i <= 'd0;
end
else
case( i ) 'd0 :
if( SOS_En_Sig ) i <= 'd1; 'd1, 5'd3, 'd5,
'd13, 5'd15, 'd17 :
if( Count_MS == 'd100 ) begin isCount <= 1'b0; rPin_Out <= 'b0; i <= i + 1'b1; end // short
else begin isCount <= 'b1; rPin_Out <= 1'b1; end 'd7, 5'd9, 'd11 :
if( Count_MS == 'd300 ) begin isCount <= 1'b0; rPin_Out <= 'b0; i <= i + 1'b1; end // long
else begin isCount <= 'b1; rPin_Out <= 1'b1; end 'd2, 5'd4, 'd6,
'd8, 5'd10, 'd12,
'd14, 5'd16, 'd18 :
if( Count_MS == 'd50 ) begin isCount <= 1'b0; i <= i + 'b1; end// interval
else isCount <= 'b1; 'd19 :
begin rPin_Out <= 'b0; i <= 5'd0; end // end endcase /***************************************************/ assign Pin_Out = rPin_Out; /***************************************************/ endmodule

2.

“Start_Sig”如同 C 语言中的调用指令,“Done_Sig”如同 C 语言的返回指令。这两个信号的存在就是为了控制模块的调用。

module sos_control_module
(
CLK, RSTn,
Start_Sig,
S_Done_Sig, O_Done_Sig,
S_Start_Sig, O_Start_Sig,
Done_Sig
); input CLK;
input RSTn;
input Start_Sig;
input S_Done_Sig, O_Done_Sig;
output S_Start_Sig, O_Start_Sig;
output Done_Sig; /*************************************/ reg [:]i;
reg isO;
reg isS;
reg isDone; always @ ( posedge CLK or negedge RSTn )
if( !RSTn )
begin
i <= 'd0;
isO <= 'b0;
isS <= 'b0;
isDone <= 'b0;
end
else if( Start_Sig )
case( i ) 'd0:
if( S_Done_Sig ) begin isS <= 'b0; i <= i + 1'b1; end
else isS <= 'b1; 'd1:
if( O_Done_Sig ) begin isO <= 'b0; i <= i + 1'b1; end
else isO <= 'b1; 'd2:
if( S_Done_Sig ) begin isS <= 'b0; i <= i + 1'b1; end
else isS <= 'b1; 'd3:
begin isDone <= 'b1; i <= 4'd4; end 'd4:
begin isDone <= 'b0; i <= 4'd0; end endcase /*****************************************/ assign S_Start_Sig = isS;
assign O_Start_Sig = isO;
assign Done_Sig = isDone; /*****************************************/ endmodule
module s_module
(
CLK, RSTn,
Start_Sig,
Done_Sig,
Pin_Out
); input CLK;
input RSTn;
input Start_Sig;
output Done_Sig;
output Pin_Out; /****************************************/ parameter T1MS = 'd49_999; /***************************************/ reg [:]Count1; always @ ( posedge CLK or negedge RSTn )
if( !RSTn )
Count1 <= 'd0;
else if( Count1 == T1MS )
Count1 <= 'd0;
else if( isCount )
Count1 <= Count1 + 'b1;
else if( !isCount )
Count1 <= 'd0; /****************************************/ reg [:]Count_MS; always @ ( posedge CLK or negedge RSTn )
if( !RSTn )
Count_MS <= 'd0;
else if( Count_MS == rTimes )
Count_MS <= 'd0;
else if( Count1 == T1MS )
Count_MS <= Count_MS + 'b1; /******************************************/ reg [:]i;
reg rPin_Out;
reg [:]rTimes;
reg isCount;
reg isDone; always @ ( posedge CLK or negedge RSTn )
if( !RSTn )
begin
i <= 'd0;
rPin_Out <= 'b0;
rTimes <= 'd1000;
isCount <= 'b0;
isDone <= 'b0;
end
else if( Start_Sig )
case( i ) 'd0, 4'd2, 'd4:
if( Count_MS == rTimes ) begin rPin_Out <= 'b0; isCount <= 1'b0; i <= i + 'b1; end
else begin isCount <= 'b1; rPin_Out <= 1'b1; rTimes <= 'd100; end 'd1, 4'd3, 'd5:
if( Count_MS == rTimes ) begin isCount <= 'b0; i <= i + 1'b1; end
else begin isCount <= 'b1; rTimes <= 10'd50; end 'd6:
begin isDone <= 'b1; i <= 4'd7; end 'd7:
begin isDone <= 'b0; i <= 4'd0; end endcase /******************************************/ assign Done_Sig = isDone;
assign Pin_Out = !rPin_Out; /******************************************/ endmodule
module o_module
(
CLK, RSTn,
Start_Sig,
Done_Sig,
Pin_Out
); input CLK;
input RSTn;
input Start_Sig;
output Done_Sig;
output Pin_Out; /****************************************/ parameter T1MS = 'd49_999; /***************************************/ reg [:]Count1; always @ ( posedge CLK or negedge RSTn )
if( !RSTn )
Count1 <= 'd0;
else if( Count1 == T1MS )
Count1 <= 'd0;
else if( isCount )
Count1 <= Count1 + 'b1;
else if( !isCount )
Count1 <= 'd0; /****************************************/ reg [:]Count_MS; always @ ( posedge CLK or negedge RSTn )
if( !RSTn )
Count_MS <= 'd0;
else if( Count_MS == rTimes )
Count_MS <= 'd0;
else if( Count1 == T1MS )
Count_MS <= Count_MS + 'b1; /******************************************/ reg [:]i;
reg rPin_Out;
reg [:]rTimes;
reg isCount;
reg isDone; always @ ( posedge CLK or negedge RSTn )
if( !RSTn )
begin
i <= 'd0;
rPin_Out <= 'b0;
rTimes <= 'd1000;
isCount <= 'b0;
isDone <= 'b0;
end
else if( Start_Sig )
case( i ) 'd0, 4'd2, 'd4:
if( Count_MS == rTimes ) begin rPin_Out <= 'b0; isCount <= 1'b0; i <= i + 'b1; end
else begin isCount <= 'b1; rPin_Out <= 1'b1; rTimes <= 'd400; end 'd1, 4'd3, 'd5:
if( Count_MS == rTimes ) begin isCount <= 'b0; i <= i + 1'b1; end
else begin isCount <= 'b1; rTimes <= 10'd50; end 'd6:
begin isDone <= 'b1; i <= 4'd7; end 'd7:
begin isDone <= 'b0; i <= 4'd0; end endcase /******************************************/ assign Done_Sig = isDone;
assign Pin_Out = !rPin_Out; /******************************************/ endmodule
module sos_module
(
CLK, RSTn,
Start_Sig,
Done_Sig,
Pin_Out
); input CLK;
input RSTn;
input Start_Sig;
output Done_Sig;
output Pin_Out; /*****************************/ wire S_Done_Sig;
wire S_Pin_Out; s_module U1
(
.CLK( CLK ),
.RSTn( RSTn ),
.Start_Sig( S_Start_Sig ), // input - from U3
.Done_Sig( S_Done_Sig ), // output - to U3
.Pin_Out( S_Pin_Out ) // output - to selector ) ; /*********************************/ wire O_Done_Sig;
wire O_Pin_Out; o_module U2
(
.CLK( CLK ),
.RSTn( RSTn ),
.Start_Sig( O_Start_Sig ), // input - from U3
.Done_Sig( O_Done_Sig ), // output - to U3
.Pin_Out( O_Pin_Out ) // output - to selector
); /*********************************/ wire S_Start_Sig;
wire O_Start_Sig; sos_control_module U3
(
.CLK( CLK ),
.RSTn( RSTn ),
.Start_Sig( Start_Sig ), // input - from top
.S_Done_Sig( S_Done_Sig ), // input - from U1
.O_Done_Sig( O_Done_Sig ), // input - from U2
.S_Start_Sig( S_Start_Sig ), // output - to U1
.O_Start_Sig( O_Start_Sig ), // output - to U2
.Done_Sig( Done_Sig ) // output - to top
); /*********************************/ //selector reg Pin_Out; always @ ( * )
if( S_Start_Sig ) Pin_Out = S_Pin_Out; // select from U1
else if( O_Start_Sig ) Pin_Out = O_Pin_Out; // select from U2
else Pin_Out = 'bx; /*********************************/ endmodule

Verilog之SOS信号-仿顺序操作的更多相关文章

  1. 【黑金教程笔记之006】【建模篇】【Lab 05 SOS信号之一】—笔记

    sos_module.v是产生SOS信号的功能模块.即有次序的输出莫斯码:点.画.间隔.control_module.v是一个定时触发器,每一段时间使能sos_module.v. 模块: /***** ...

  2. 【黑金教程笔记之007】【建模篇】【Lab 06 SOS信号之二】—笔记

    控制模块的协调角色. 实验六用到了实验四的按键消抖模块debounce_module.v和实验五的sos_module.v. 设计思路: debounce_module.v看成一个输入,sos_mod ...

  3. 【黑金教程笔记之001】veriloghdl 扫盲文—笔记&勘误

    001_veriloghdl 扫盲文—笔记&勘误 2014/10/31 原文作者:akuei2 联系方式:blog.ednchina.con/akuei2 勘误001: Page 3 0.1 ...

  4. 【设计经验】1、Verilog中如何规范的处理inout信号

    在FPGA的设计过程中,有时候会遇到双向信号(既能作为输出,也能作为输入的信号叫双向信号).比如,IIC总线中的SDA信号就是一个双向信号,QSPI Flash的四线操作的时候四根信号线均为双向信号. ...

  5. verilog实现中值滤波

    前言 项目需要,想要实现算法中的其中一步即中值滤波,同时,因为图像处理部分中值滤波相对来说还是比较简单的,将中值滤波的硬件实现作为进入FPGA领域的第一次尝试.虽然说网上有较多关于中值滤波的文档,可是 ...

  6. 基于Proteus仿真的Arduino学习(1)——Arduino Uno最小系统及LED的简单使用

    一.前言:  A.Arduino简介 Arduino是由一个欧洲开发团队于2005年冬季开发.其成员包括Massimo Banzi.David Cuartielles.Tom Igoe.Gianluc ...

  7. SPI通信实验---verilog(FPGA作为从机,使用可读可写)

    本实验讲究实用性,故设计思想为:主机先向从机发送地址,若是向从机写入数据,则向从机发送数据,若是读取从机数据,则向从机发送时钟,然后在时钟下降沿读取数据即可.cs信号上升沿作为SPI通信的结束信号.r ...

  8. SPI的通信试验 --verilog (从机-全双工)

    SPI的 有关知识参考FPGA作为主机的通信实验. 本实验中FPGA作为从机通过SPI与MCU等通信的试验,可以在时钟上升沿接收数据并且在时钟下降沿发送数据,模仿全双工模式.接收的 数据作为地址,通过 ...

  9. 【接口时序】2、Verilog实现流水灯及与C语言的对比

    一. 软件平台与硬件平台 软件平台: 1.操作系统:Windows-8.1 2.开发套件:ISE14.7 3.仿真工具:ModelSim-10.4-SE 硬件平台: 1.FPGA型号:XC6SLX45 ...

随机推荐

  1. String字符串

    主要来源:http://www.cnblogs.com/devinzhang/archive/2012/01/25/2329463.html http://blog.csdn.net/qh_java/ ...

  2. Hololens开发笔记之Gesture手势识别(手势检测反馈)

    本文实现当使用者手出现在Hololens视野范围内时,跟踪手并给出反馈的效果. 1.在Manager上添加HandsManager脚本组件,用于追踪识别手 HandsManager.cs如下(直接使用 ...

  3. gerrit error: unpack failed: error Permission denied

    gerrit服务器迁移后,clone和pull代码到本地,都没问题. 但是,push时,报错: 查看了下git版本库存储目录,发现git下版本库镜像文件owner都是root.因为之前安装的gerri ...

  4. Python第十二章正则表达式(2)

    1.前提是引入import re 匹配邮箱后缀需要写入r=r'\.com\.cn|\.com|\.cn' r=r'(\w+@\w+(\.com\.con|\.com|\.cn))'ll=re.find ...

  5. Codeforces Round #228 (Div. 1) A

    A. Fox and Box Accumulation time limit per test 1 second memory limit per test 256 megabytes input s ...

  6. 【转】web测试总结

    1.字符型输入框: (1)字符型输入框:英文全角.英文半角.数字.空或者空格.特殊字符“~!@#¥%……&*?[]{}”特别要注意单引号和&符号.禁止直接输入特殊字符时,使用“粘贴.拷 ...

  7. 修改安全策略组 -- windows

    1.新建安全策略组文件SAMTool.inf md C:\SAMLog & echo [Version] >C:\SAMLog\SAMTool.inf &echo signatu ...

  8. IDE神器intellij idea的基本使用

    摘自: http://www.cnblogs.com/newpanderking/p/4887981.html 一.编码快捷键(比较常用的快捷键)该套快捷键选择的是:Mac OS X 10.5+ 1. ...

  9. animate.css配合wow.min.js实现各种页面滚动效果

    有的页面在向下滚动的时候,有些元素会产生细小的动画效果.虽然动画比较小,但却能吸引你的注意.比如刚刚发布的 iPhone 6 的页面(查看).如果你希望你的页面也更加有趣,那么你可以试试 WOW.js ...

  10. Java设计模式——适配器模式

    JAVA 设计模式 适配器模式 用途 适配器模式 (Adapter) 将一个类的接口转换成客户希望的另外一个接口. Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作. 适配器 ...