FPGA|CPLD|ASIC论坛
直播中

YYL

8年用户 42经验值
擅长:可编程逻辑 模拟技术 处理器/DSP 接口/总线/驱动 控制/MCU
私信 关注
[讨论]

关于FPGA上升、下降沿检测的问题

程序和仿真文件如下,为啥MODELSIM里没有波形,哪有问题呢?
module sck_test
(
    input clk,
    input nrst,
    input sck,
    output sck_riseedge,
    output sck_falLEDge
);

reg sig_sck0;
reg sig_sck1;

assign   sck_riseedge  = ~sig_sck1 &  sig_sck0;
assign   sck_falledge  = ~sig_sck0 &  sig_sck1;

always@(posedge clk or negedge nrst)
begin
    if (~nrst)
        begin
            sig_sck0 <= 0;
            sig_sck1 <= 0;
        end
    else
        begin
            sig_sck0 <= sck;
            sig_sck1 <= sig_sck0;
        end
end
endmodule

////////////////////////
`timescale 1ns/1ns
module sck_test_tb;
reg clk;
reg nrst;
reg sck;


wire sck_riseedge;
wire sck_falledge;

initial
begin
        clk = 1'b0;
        nrst = 1'b1;
        sck = 0;
        #100 nrst = 0;
        repeat(8)
           begin
               #500 sck = 1;
               #500 sck = 0;
           end
        #1000;
  $stop;
end


always#10 clk = ~clk;//50Mhz

sck_test dut
(
        .clk     (clk),
        .nrst    (nrst),
        .sck     (sck),
        .sck_riseedge   (sck_riseedge),
        .sck_falledge   (sck_falledge)
);
endmodule

回帖(1)

卿小小_9e6

2021-7-14 11:38:36
没波形就对了,说明仿真环境没问题。
//------
查看tb仿真代码,‘ #100 nrst = 0;’一直复位,所以sig_sck0和sig_sck1一直为0.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分