【问题标题】:Division on the last outputs最后输出的划分
【发布时间】:2014-02-17 20:04:04
【问题描述】:

计数器计算输入样本的数量。然后计数器输出(n),我想检查样本数是否为偶数,然后 n_of_samples = (n*n) 否则如果奇数则为 ((n*n)-1) 会是这样的

signal dis : integer range 0 to 255 := 0;
signal n   : integer range 0 to 255 :=0;
 if n mod 2=1 then
      n_of samples<= ((n*n)-1);
   else
      n_of_samples <= n*n;
  end if;
    norm_dis <= dis / n_of_samples ;

这两个信号的值为 (1,6,9,8,.....100) 和 (0,2,8,9.......,200) 我想从两个信号(100,200)中获取最后两个输出 并除以 100/200。我如何在 vhdl 中编写它以及如何克服除以零错误。

【问题讨论】:

    标签: vhdl


    【解决方案1】:

    只要确保你不被零除!

    if n_of_samples/=0 then
        norm_dis <= dis / n_of_samples ;
    end if;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-27
      • 2018-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-19
      相关资源
      最近更新 更多