如何使用python代码计算时钟周期中上升沿的数量?

2024-05-15 04:02:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我对python编码还不熟悉。我正在尝试编写一个python函数,它计算一个时钟的posedge数并返回最终的计数值。你知道吗

谢谢你的时间!你知道吗

我写了下面这样的东西,请纠正我:

from admit.util.peakfinder.PeakDetect import PeakDetect
import numpy as np
import time
from detect_peaks import detect_peaks


@always(clk.posedge)
def freq_meas():
    num_posedge_cnt =0
    total_time = time.time()

    #detect all peaks
    #pd = peakDetect(y, edge='posedge')
    #pd = peakDetect(edge='posedge')
    pd = detect_peaks(edge='rising', show=true)
    print(pd)
    if not edge:
    #do nothing
    else:
    if edge.lower() in ['rising']:
       num_posedge_cnt += 1
    elapsed = time.time() - total_time
    #freq    = num_posedge_cnt/elapsed
    #return freq

    return num_posedge_cnt

Tags: fromimporttimenumtotalpddetectfreq

热门问题