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. 面对一个新的MCU,我再也不敢说第一步是点灯了

    折腾了几天AT91SAM3S,今天才算是把开发板上的3个LED点亮. 在点亮之前,起码看了百八十页的Datasheet,动用了N次百度. 各种时钟,看门狗,分散加载,中断向量,都得去整.这些都远远超过 ...

  2. java io流 创建文件、写入数据、设置输出位置

    java io流 创建文件 写入数据 改变system.out.print的输出位置 //创建文件 //写入数据 //改变system.out.print的输出位置 import java.io.*; ...

  3. nbu恢复 oracle10g rac asm 到单实例asm(恢复某个表空间)

    一 检验条件 二 准备工作 1 创建相关目录 mkdir -p /oracle/admin/orcl/adumpmkdir -p /oracle/admin/orcl/bdumpmkdir -p /o ...

  4. json格式的数组长度

    var data = [{"id":"1","name":"a"},{"id":"2&qu ...

  5. Vs打包工程 错误: Unable to update the dependencies of the project (转)

    Setup Project 错误: Unable to update the dependencies of the project 在VS2010中编译包含安装工程的解决方案提示错误:Unable ...

  6. Fping

    (十大特色功能) Ping是最常用的网络测试工具,ping的测试功能其实比较多,xp系统的ping有12个选项.但是,fping测试工具有25个选项,在ping的基础上增加了许多专业的功能,可用于更深 ...

  7. Sass浅谈

    对于一名前端开发来说,CSS并不陌生,几乎每天都在和CSS打交道.相处久了就会觉得CSS有些许的机械化,有些许的无趣:就会觉得写CSS很多时候都是在做一些复制粘贴性的工作,布局排版,颜色设置,边框属性 ...

  8. Java内各种进制的表示

    不同进制的数据表现: 二进制:由0,1组成.以0b开头. 八进制:由0,1,...7组成.以0开头. 十进制:由0,1,...9组成.默认整数是十进制. 十六进制:由0,1,...9,a,b,c,d, ...

  9. Python isdigit()方法

    描述 Python isdigit() 方法检测字符串是否只由数字组成. 语法 isdigit()方法语法: str.isdigit() 参数 无. 返回值 如果字符串只包含数字则返回 True 否则 ...

  10. zookeeper节点失效重连机制

    http://www.blogjava.net/xylz/archive/2011/12/05/365578.html http://blog.csdn.net/tswisdom/article/de ...