片状卷积的verilog实现

给大家推荐免费的kugou音乐 vip哈, 还不知道的一定有相见恨晚的感觉,获取地址http://www.service99.cn

                                                        ------------题记

在mobilenet中,广泛使用片状的卷积

卷积核的代码为

module conv_2d_kernel_(
    x0,x1,x2,x3,x4,x5,x6,x7,x8,
    y0,y1,y2,y3,y4,y5,y6,y7,y8,
    rst
    );  
input[15:0] x0;
input[15:0] x1;
input[15:0] x2;
input[15:0] x3;
input[15:0] x4;
input[15:0] x5;
input[15:0] x6;
input[15:0] x7;
input[15:0] x8;

input[15:0] y0;
input[15:0] y1;
input[15:0] y2;
input[15:0] y3;
input[15:0] y4;
input[15:0] y5;
input[15:0] y6;
input[15:0] y7;
input[15:0] y8;
output[15:0] rst;
assign rst = x0*y0+x1*y1+x2*y2+x3*y3+x4*y4+x5*y5+x6*y6+x7*y7;

endmodule

testbench可以自动生成模板:首先(open)打开需要仿真的模块 ,Source -> Show Language Templates,在显示的 Language Templates栏目中选择“Create Testbench”,软件自动弹出的"Create Testbench Wizzard”窗口中,在"work"下选择待仿真模块,按照提示走完,即自动生成。增加值,代码如下:

module conv_2d_kernel__tb  ; 
 
  reg  [15:0]  x8   ; 
  wire  [15:0]  rst ; 
  reg  [15:0]  y0   ; 
  reg  [15:0]  y1   ; 
  reg  [15:0]  y2   ; 
  reg  [15:0]  y3   ; 
  reg  [15:0]  y4   ; 
  reg  [15:0]  y5   ; 
  reg  [15:0]  y6   ; 
  reg  [15:0]  y7   ; 
  reg  [15:0]  x0   ; 
  reg  [15:0]  y8   ; 
  reg  [15:0]  x1   ; 
  reg  [15:0]  x2   ; 
  reg  [15:0]  x3   ; 
  reg  [15:0]  x4   ; 
  reg  [15:0]  x5   ; 
  reg  [15:0]  x6   ; 
  reg  [15:0]  x7   ; 
  
  initial
  begin
    x0=1;
    x1=1;
    x2=1;
    x3=1;
    x4=1;
    x5=1;
    x6=1;
    x7=1;
    x7=1;
    
    y0=1;
    y1=1;
    y2=1;
    y3=1;
    y4=1;
    y5=1;
    y6=1;
    y7=1;
    y8=1;
  end   
  
  conv_2d_kernel_  
   DUT  ( 
       .x8 (x8 ) ,
      .rst (rst ) ,
      .y0 (y0 ) ,
      .y1 (y1 ) ,
      .y2 (y2 ) ,
      .y3 (y3 ) ,
      .y4 (y4 ) ,
      .y5 (y5 ) ,
      .y6 (y6 ) ,
      .y7 (y7 ) ,
      .x0 (x0 ) ,
      .y8 (y8 ) ,
      .x1 (x1 ) ,
      .x2 (x2 ) ,
      .x3 (x3 ) ,
      .x4 (x4 ) ,
      .x5 (x5 ) ,
      .x6 (x6 ) ,
      .x7 (x7 ) ); 
endmodule


仿真的结果为

右键library中的worker中选择simulate相当于给某个器件上电,run相当于打开了开关。

如何根据大学教授的名字起名字?

1. 打开互联网一元服务超市网址

2. 点击宝宝起名

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

andeyeluguo

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值