[VerilogA] moving average for measurement in simulation



    In the simulation environment, we will consider it as a perfect world. However, it's not in reality. According to adaptive time step, we will get a result which it's a little different from the theory. Sometimes, we can't not measure just one time. We need to measure multiple times in the period. At this moment, we adopt "moving average" method.

In VerilogA, we can measure "Count" times. TESTX[j] is the data in period.
We average this data to get more-close-to theoretic data in simulation.

We implement moving average  in VerilogA.

/// moving average
    for( ( j = Count-1) ; j >= 1 ; j = j-1)
    t_testx[j]  =  t_testx[j-1];
 
    generate j (0, Count-1)
    t_test_sum = t_test_sum+t_testx[j];

    t_test  =  t_test_sum/(Count);
    t_test_sum=0;
/// moving average

留言

這個網誌中的熱門文章

[維修小札] 小米掃地機器人 x10+ 更換電池 離開充電座馬上沒電 [Fix Notes] Xiaomi Robotic Vacuum Battery Replacement.

[生活小物] 威猛先生/超濃水管疏通膠/黃色