因为在图像处理的时候需要用到很多filter,其中Gaussian filter是一个是exponential function,所以要用到e和**。
正规的做法是用Cordic或者xilinx/altera的math lib。
cordic核貌似只能对以e为底的数计算,e^x=coshx+sinhx,选择双曲计算sinh and cosh选项,然后把两个输出相加就是e^x结果.
可以参考http://verilog.openhpsdr.org/。上面有Cordic的分析和test,用的modelsim。路径是:E:\verilog\thesis_2014\Apr6_Conv\cordic\CORDIC Test
但为了快速检验设计,看看neural network对不对,所以暂时先不考虑cordic的设计。当然,要记住RTL是设计电路而不是程序。
参考的资料是:SystemVerilog and verilog gotcha 101 和 http://billauer.co.il/blog/2009/07/verilog-standard-short-port-declaration-output-reg-autoarg/
看到了对于input的实数要定义成:var real 2.718,而output只要real 3.14就行。
//&#