zynq高频小数据量PS闭环 抖动时间的测量

参考

zynq高频小数据量PS闭环的三个实验-第0课:目的和目标

zynq高频小数据量PS闭环的三个实验-第1课:PL搭建

zynq高频小数据量PS闭环的三个实验-第2课:Vitis裸机测试

zynq高频小数据量PS闭环的三个实验-第3课:Linux驱动测试

测量两个脉冲之间的时间差

闭环控制i_pulse2产生高之后还有短暂的确定时间,忽略不计

pulse_diff_measure.v

verilog 复制代码
module pulse_diff_measure (
    input  wire         i_clk,
    input  wire         i_rst_n,
    input  wire         i_pulse1,   // IRQ触发信号,拉高=开始测量
    input  wire         i_pulse2,   // ctrl_done,拉高=结束测量
    output reg          o_pulse_diff
);
always @(posedge i_clk or negedge i_rst_n) begin
    if(!i_rst_n) begin
        o_pulse_diff <= 1'b0;
    end
    else begin
        if(i_pulse2) begin
            o_pulse_diff <= 1'b0;
        end
        else if(i_pulse1) begin
            o_pulse_diff <= 1'b1;
        end
    end
end
endmodule

tb.v

verilog 复制代码
`timescale 1ns/1ps

module tb;


reg i_clk;
reg i_rst_n;
reg i_pulse1;
reg i_pulse2;
wire o_pulse_diff;

pulse_diff_measure u_pulse_diff_measure
(
    .i_clk(i_clk),
    .i_rst_n(i_rst_n),
    .i_pulse1(i_pulse1),
    .i_pulse2(i_pulse2),
    .o_pulse_diff(o_pulse_diff)
);


// 100MHz
always #5 i_clk = ~i_clk;



initial
begin
    i_clk = 0;
    i_rst_n  = 0;
    i_pulse1 = 0;
    i_pulse2 = 0;
    #20;
    i_rst_n = 1;
    // 等几个clk
    repeat(5) @(posedge i_clk);
    // pulse1 开始
    @(posedge i_clk);
    i_pulse1 <= 1'b1;
    @(posedge i_clk);
    i_pulse1 <= 1'b0;
    // 间隔10个clk
    repeat(10) @(posedge i_clk);
    // pulse2结束
    @(posedge i_clk);
    i_pulse2 <= 1'b1;
    @(posedge i_clk);
    i_pulse2 <= 1'b0;
    #100;
    $stop;

end

endmodule

测试

相关推荐
long3161 小时前
MySQL 学习练习(配套 01 入门资料)
数据库·学习·mysql
梦雨生生2 小时前
java开发工具(学习第一天)
java·开发语言·学习
IT古董7 小时前
【MES学习笔记系列】05 - MES 数据库设计
笔记·学习·mes
LATASA9 小时前
【 从0到1构建 Agent Harness学习笔记】
网络·笔记·学习
weixin_431600449 小时前
做 Agent 会用到的 Node API(3):异步与流
前端·学习·ai·agent·ai编程
70asunflower10 小时前
Triton 从 0 到 1 完整学习教程
学习·triton
天国梦10 小时前
2026年英语教学数字化工具深度测评:天学网、腾讯英语君、翼课网横向对比
人工智能·学习
oier_Asad.Chen12 小时前
【OI学习笔记】Floyed-Warshall算法解决传递闭包问题
c++·笔记·学习·算法·图论·最短路·传递闭包
鱼听禅12 小时前
C#学习笔记-添加编译参数到程序集自动更新程序编译时间
笔记·学习·c#