随笔 - 284, 文章 - 0, 评论 - 60, 阅读 - 53万
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

关于信号的延迟---verilog

Posted on   沉默改良者  阅读(3669)  评论(0编辑  收藏  举报

关于信号的延迟---verilog

复制代码
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: chensimin
// 
// Create Date: 2018/02/08 11:39:20
// Design Name: 
// Module Name: signal_detect
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//////////////////////////////////////////////////////////////////////////////////


module signal_detect(

    input wire clk,
    input wire rst,
    input wire signal_en
    //input wire signal
    //output wire signal_existence
    );



    reg signal;
    always @(posedge clk or posedge rst)
    begin
        if(rst)
            signal <= 1'b0;
        else if(signal_en)
            signal <= 1'b1;
        else
            signal <= 1'b0;
    end



    reg signal_delay;
    wire signal_rise;
    always @(posedge clk or posedge rst)
    begin
        if(rst)
            signal_delay <= 1'b0;
        else
            signal_delay <= signal;
    end

    assign signal_rise = !signal_delay && signal;


endmodule




/*

add_force {/signal_detect/clk} -radix hex {1 0ns} {0 50000ps} -repeat_every 100000ps
add_force {/signal_detect/rst} -radix hex {1 0ns} {0 150ns}
add_force {/signal_detect/signal_en} -radix hex {0 0ns} {1 300ns} {0 400ns}


*/
复制代码

仿真波形:

容易犯下这样一种错误:

复制代码
module signal_detect(

    input wire clk,
    input wire rst,
    input wire signal
    //input wire signal
    //output wire signal_existence
    );


    reg signal_delay;
    wire signal_rise;
    always @(posedge clk or posedge rst)
    begin
        if(rst)
            signal_delay <= 1'b0;
        else
            signal_delay <= signal;
    end

    assign signal_rise = !signal_delay && signal;


endmodule




/*

add_force {/signal_detect/clk} -radix hex {1 0ns} {0 50000ps} -repeat_every 100000ps
add_force {/signal_detect/rst} -radix hex {1 0ns} {0 150ns}
add_force {/signal_detect/signal} -radix hex {0 0ns} {1 300ns} {0 400ns}


*/
复制代码

仿真波形:

像这种写法,根本就起不到边沿检测的作用,只是对外部信号进行一次采集。

编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示