仿真思路

其实是使用了很普通的硬件的函数的仿真方法,但是有趣的是我为了提升精度将划分划分的更加细致了;
看一下matlab源代码还有图像大家就知道了:

function Mysolution()
x1=0:0.01:0.125;
f1=0.2498 ;
x2=0.125:0.01:0.25;
f2=0.2478;
x3=0.25:0.01:0.375;
f3= 0.2440 ;
x4=0.375:0.01:0.5;
f4=0.2384;
x5=0.5:0.01:0.625;
f5=0.2312;
x6=0.625:0.01:0.75;
f6=0.2226;
x7=0.75:0.01:0.875;
f7=0.2129;
x8=0.875:0.01:1;
f8=0.2022;
x9=1:0.01:1.125;
f9=0.1909;
x10=1.125:0.01:1.25;
f10=0.1791;
x11=1.25:0.01:1.375;
f11=0.1671;
x12=1.375:0.01:1.5;
f12=0.1551;
x13=1.5:0.01:1.625;
f13=0.1443;
x14=1.625:0.01:1.75;
f14=0.1317;
x15=1.75:0.01:1.875;
f15=0.1206;
x16=1.875:0.01:2;
f16=0.1101;
x17=2:0.01:2.125;
f17=0.1001;
x18=2.125:0.01:2.25;
f18=0.0907;
x19=2.25:0.01:2.375;
f19=0.0820;
x20=2.375:0.01:2.5;
f20=0.0739;
x21=2.5:0.01:2.625;
f21=0.0665;
x22=2.625:0.01:2.75;
f22=0.0597;
x23=2.75:0.01:2.875;
f23=0.0534;
x24=2.875:0.01:3;
f24=0.0478;
x25=3:0.01:3.125;
f25=0.0427;
x26=3.125:0.01:3.25;
f26=0.0381;
x27=3.25:0.01:3.375;
f27=0.0339;
x28=3.375:0.01:3.5;
f28=0.0302;
x29=3.5:0.01:3.625;
f29=0.0268;
x30=3.625:0.01:3.75;
f30=0.0238;
x31=3.75:0.01:3.875;
f31=0.0211;
x32=3.875:0.01:4;
f32=0.0188;
x33=4:0.01:4.125;
f33=0.0166;
x34=4.125:0.01:4.25;
f34=0.0147;
x35=4.25:0.01:4.375;
f35=0.0130;
x36=4.375:0.01:4.5;
f36=0.0116;
x37=4.5:0.01:4.625;
f37=0.0102;
x38=4.625:0.01:4.75;
f38=0.009;
x39=4.75:0.01:4.875;
f39=0.008;
x40=4.875:0.01:5;
f40=0.0071;
x41=5:0.01:5.125;
f41=0.0063;
x42=5.125:0.01:5.25;
f42=0.0055;
x43=5.25:0.01:5.375;
f43=0.0049;
x44=5.375:0.01:5.5;
f44=0.0043;
x45=5.5:0.01:5.625;
f45=0.0038;
x46=5.625:0.01:5.75;
f46=0.0034;
x47=5.75:0.01:5.875;
f47=0.0030;
x48=5.875:0.01:6;
f48=0.0026;
x49=6:0.01:6.125;
f49=0.0023;
x50=6.125:0.01:6.25;
f50=0.0020;
x51=6.25:0.01:6.375;
f51=0.0018;
x52=6.375:0.01:6.5;
f52=0.0016;
x53=6.5:0.01:6.625;
f53=0.0014;
x54=6.625:0.01:6.75;
f54=0.0012;
x55=6.75:0.01:6.875;
f55=0.0011;
x56=6.875:0.01:7;
f56=0.0010;
x57=7:0.01:7.125;
f57=0.0009;
x58=7.125:0.01:7.25;
f58=0.0008;
x59=7.25:0.01:7.375;
f59=0.0007;
x60=7.375:0.01:7.5;
f60=0.0006;
x61=7.5:0.01:7.625;
f61=0.0005;
x62=7.625:0.01:7.75;
f62=0.0005;
x63=7.75:0.01:7.875;
f63=0.0004;
x64=7.875:0.01:8;
f64=0.0004;
x=0.0625:0.125:7.9375;
fx=exp(-x)./(1+exp(-x)).^2;
plot(x,fx,'b');
hold on;
plot(x1,f1,'r');hold on;
plot(x2,f2,'r');hold on;
plot(x3,f3,'r');hold on;
plot(x4,f4,'r');hold on;
plot(x5,f5,'r');hold on;
plot(x6,f6,'r');hold on;
plot(x7,f7,'r');hold on;
plot(x8,f8,'r');hold on;
plot(x9,f9,'r');hold on;
plot(x10,f10,'r');hold on;
plot(x11,f11,'r');hold on;
plot(x12,f12,'r');hold on;
plot(x13,f13,'r');hold on;
plot(x14,f14,'r');hold on;
plot(x15,f15,'r');hold on;
plot(x16,f16,'r');hold on;
plot(x17,f17,'r');hold on;
plot(x18,f18,'r');hold on;
plot(x19,f19,'r');hold on;
plot(x20,f20,'r');hold on;
plot(x21,f21,'r');hold on;
plot(x22,f22,'r');hold on;
plot(x23,f23,'r');hold on;
plot(x24,f24,'r');hold on;
plot(x25,f25,'r');hold on;
plot(x26,f26,'r');hold on;
plot(x27,f27,'r');hold on;
plot(x28,f28,'r');hold on;
plot(x29,f29,'r');hold on;
plot(x30,f30,'r');hold on;
plot(x31,f31,'r');hold on;
plot(x32,f32,'r');hold on;
plot(x33,f33,'r');hold on;
plot(x34,f34,'r');hold on;
plot(x35,f35,'r');hold on;
plot(x36,f36,'r');hold on;
plot(x37,f37,'r');hold on;
plot(x38,f38,'r');hold on;
plot(x39,f39,'r');hold on;
plot(x40,f40,'r');hold on;
plot(x41,f41,'r');hold on;
plot(x42,f42,'r');hold on;
plot(x43,f43,'r');hold on;
plot(x44,f44,'r');hold on;
plot(x45,f45,'r');hold on;
plot(x46,f46,'r');hold on;
plot(x47,f47,'r');hold on;
plot(x48,f48,'r');hold on;
plot(x49,f49,'r');hold on;
plot(x50,f50,'r');hold on;
plot(x51,f51,'r');hold on;
plot(x52,f52,'r');hold on;
plot(x53,f53,'r');hold on;
plot(x54,f54,'r');hold on;
plot(x55,f55,'r');hold on;
plot(x56,f56,'r');hold on;
plot(x57,f57,'r');hold on;
plot(x58,f58,'r');hold on;
plot(x59,f59,'r');hold on;
plot(x60,f60,'r');hold on;
plot(x61,f61,'r');hold on;
plot(x62,f62,'r');hold on;
plot(x63,f63,'r');hold on;
plot(x64,f64,'r');hold on;
xx=0.0625:0.125:8-0.0625;
ff=exp(-xx)./(1+exp(-xx)).^2
plot(xx,ff,'black');
end


确实比较简单,但是硬件实现遇见了很大的麻烦,为什么呢,因为我们用到的数据是16位的浮点型,大概画一下结构好了;

也就是说,我现在知道了每个范围的x所对应的y的值,在输入一个十六位二进制的浮点型数据之后,根据这个数据得知rom里面对应的y的地址值,反正就是很麻烦我也没啥时间写,直接上代码吧。
先做一个y值得rom

memory_initialization_radix=2;
memory_initialization_vector=
0011000011111111
0011000011111101
0011000011111001
0011000011110100
0011000011101100
0011000011100011
0011000011011001
0011000011001111
0011000011000011
0011000010110111
0011000010101011
0011000010011110
0011000010010010
0011000010000110
0010110001111011
0010110001110000
0010110001100110
0010110001011100
0010110001010011
0010110001001011
0010110001000100
0010100000111101
0010100000110110
0010100000110000
0010100000101011
0010100000100110
0010100000100010
0010010000011110
0010010000011011
0010010000011000
0010010000010101
0010010000010011
0010010000010001
0010000000001111
0010000000001101
0010000000001011
0010000000001010
0010000000001001
0010000000001000
0001110000000111
0001110000000110
0001110000000101
0001110000000100
0001110000000100
0001100000000011
0001100000000011
0001100000000011
0001100000000010
0001100000000010
0001100000000010
0001010000000001
0001010000000001
0001010000000001
0001010000000001
0001010000000001
0001000000000000
0001000000000000
0001000000000000
0001000000000000
0001000000000000
0001000000000000
0000110000000000
0000110000000000
0000110000000000;

然后用x对应到地址,我设计的很巧妙的呦:

//由x得到adress
module Mysolution(clk,read_x,addra);
input clk;
input [15:0] read_x;
output [5:0] addra;
reg [15:0] Data1;
reg [15:0] Data2;
reg [5:0] addra;
always @(posedge clk)
begin
Data1={6'b000001,read_x[9:0]};
Data2={6'b000000,read_x[9:0]};
if(read_x[14:10]>=5'b01111)
addra=Data1[12:7];
else
addra=Data2[12:7];
end
endmodule
module addrtodata(clk,ena,read_x,douta);
input clk,ena;
input[15:0] read_x;
output [15:0] douta;
wire [15:0] douta;
wire [5:0] addra;
Mysolution  mysolution_init_0(.clk(clk),.read_x(read_x),.addra(addra));
blk_mem_gen_0 addrtodata(.clka(clk),.addra(addra),.douta(douta),.ena(ena));
endmodule

好了,testbench自己写,加油;

sigmoid函数导数的硬件实现(verilog)相关推荐

  1. 神经网络的反向传播(BP)是什么?sigmoid函数的导数是什么,有什么形式优势、优缺点?

    神经网络的反向传播(BP)是什么?sigmoid函数的导数是什么,有什么形式优势? 目录

  2. 计算 sigmoid 函数的导数

    计算 sigmoid 函数的导数 回想一下,sigmoid 函数有一个完美的导数,我们可以在下面的计算中看到.这将使我们的反向传播步骤更加简洁.

  3. Python绘制sigmoid函数及其导数图像

    import numpy as np import matplotlib.pyplot as plt def sigmoid(x):y=1/(1+np.exp(-x))#dy=y*(1-y)retur ...

  4. sigmoid函数及其导数

    sigmoid函数: g = 1.0 ./ (1.0 + exp(-z)); sigmoid函数的导数: g=sigmoid(z).*(1-sigmoid(z));

  5. sigmoid函数及其导数的python实现与可视化

    文章目录 一.sigmoid函数的概念 二.sigmoid函数的优点 三.sigmoid函数的python实现代码 四.sigmoid函数的图像 一.sigmoid函数的概念 sigmoid函数,也就 ...

  6. sigmoid函数求导与自然指数

    sigmoid函数求导与自然指数 在神经网络里经常使用sigmoid做激活函数,它的导数是怎么样求解呢?因为要使用它的导数来计算梯度下降. 这个过程如下: 1. sigmoid 函数:f(z) = 1 ...

  7. 交叉熵代价函数——当我们用sigmoid函数作为神经元的激活函数时,最好使用交叉熵代价函数来替代方差代价函数,以避免训练过程太慢...

    交叉熵代价函数 machine learning算法中用得很多的交叉熵代价函数. 1.从方差代价函数说起 代价函数经常用方差代价函数(即采用均方误差MSE),比如对于一个神经元(单输入单输出,sigm ...

  8. sigmoid函数(Logistic函数)

    文章目录 Sigmoid函数由下列公式定义: 其对x的导数可以用自身表示: Sigmoid函数的图形如S曲线: Sigmoid函数的级数表示: 用python打印Sigmoid函数曲线: 结果: 若想 ...

  9. sigmoid函数_机器学习面试常考知识之激活函数

    神经网络的知识 激活函数 y=f(Wx+b) 常用的激活函数有sigmoid.tanh.ReLu.LeakyReLU等 ​ 为什么需要激活函数(这里说的激活函数一般指非线性激活),假设不用激活函数(相 ...

  10. sigmoid函数解决溢出_梯度消失和梯度爆炸及解决方法

    一.为什么会产生梯度消失和梯度爆炸? 目前优化神经网络的方法都是基于BP,即根据损失函数计算的误差通过梯度反向传播的方式,指导深度网络权值的更新优化.其中将误差从末层往前传递的过程需要链式法则(Cha ...

最新文章

  1. 利用Github+Jeklly搭建个人博客网站
  2. js进阶 11-22/23 js如何实现选项卡
  3. java二叉堆_为什么二叉堆利用数组存储?
  4. 8个主流且实用的Python开发工具推荐
  5. java中如何声明外键约束_java – 如何使用Hibernate注释标记外键约束...
  6. 复习支持向量机(SVM)没空看书时,掌握下面的知识就够了
  7. Selenium断言的使用,等待
  8. java ipv4和ipv6通信_IPv6与IPv4连接负载
  9. App测试中ios和Android的区别1
  10. IBM Lotus Domino V8.5 服务器管理入门手册
  11. 轻松玩转windows7之一:利用无线玩转虚拟网络
  12. JAVA实现邮件发送
  13. 原创 | 混沌工程(Chaos Engineering)初识
  14. oracle蓝屏解决方法,win10系统蓝屏怎么办 蓝屏代码0x000007e的3种解决方法
  15. 2020年HS芯片说明海思论坛
  16. 关于给hexo博客增加每日一言(诗句,影视名句,网易云热评等)
  17. Conway生命游戏
  18. 利用Python实现NBA球员分析绘制数据可视化图表
  19. Spring基础学习
  20. [项目管理]工业工程理论在软件项目中的实践

热门文章

  1. 从四面体数据中提取表面
  2. 【笔记】MyBatis 大于等于小于等于常用写法
  3. 【GLPNet2021】GLOBAL-LOCAL PROPAGATION NETWORK FOR RGB-D SEMANTIC SEGMENTATION
  4. dataframe保存为txt_如何快速将TXT转换为SRT文件
  5. 史上最全Android版本号信息:)
  6. Gstreamer 命令行
  7. 北斗微信与服务器怎么联接,北斗卫星的导航服务全球性升级,手机怎样“连接”使用北斗导航?...
  8. 管理大师德鲁克管理学精髓
  9. proc report过程步
  10. 惠普微型计算机主机拆卸,HP 惠普 Pavilion Wave 台式主机 拆机