卷积函数的FPGA实现(八)IPcore的BRAM尺寸及加入偏置和ReLU

61 篇文章 102 订阅

背景:第一次编写的IPcore存在问题,没有加入偏置与ReLU

目的:给IPcore加入偏置和ReLU。

 

一、最终BRAM尺寸的确定

1.1 IBRAM

	//calculate parameters about IBRAM
	printf("inWidth = %d, in_ChannelNum = %d \n",inWidth, inChanNum);
	int input_pixel = inWidth*inChanNum*NUM_IMG_CACHE_LINES;
	if (input_pixel > Max_input_image_pixels) 
		Max_input_image_pixels = input_pixel;
	printf("-----------Max_input_image_pixels = %d-----------\n",Max_input_image_pixels);

 输入的图片尺寸的大小,

1.2 WBRAM

 	//calculate parameters about WBRAM
	int out_channelNum=OutChanNum;
	printf("OutchanelNum = %d , inChannelNum = %d \n",out_channelNum, inChanNum);
	int max_co_Num_per_PE=(out_channelNum+N_PE-1)/N_PE;
	printf("max_co_Num_per_PE= %d \n",max_co_Num_per_PE);
	int max_filters_per_PE=max_co_Num_per_PE*inChanNum;
	printf("max_filters_per_PE= %d\n \n",max_filters_per_PE);
	
	if(max_co_Num_per_PE>MAXCO_PER_PE)MAXCO_PER_PE=max_co_Num_per_PE;
	if(max_filters_per_PE>MAX_FILTERS_PER_PE)MAX_FILTERS_PER_PE=max_filters_per_PE;
	printf("-----------%d  %d --------\n",MAXCO_PER_PE,MAX_FILTERS_PER_PE);

1.3 OBRAM

	//calculate parameters about OBRAM
	printf("\nCo num = %d \n",OutChanNum);
    if(out_channelNum > max_out_channelNum) max_out_channelNum=out_channelNum;
    printf("******** max_out_channelNum = %d  *********\n",max_out_channelNum);

1.4  加入BBRAM

表示偏移的BRAM,尺寸为最大的输出通道的个数。

float BiasCache::BBRAM[MAX_NUM_CHOUT];

1.4 定义

// ==========================
// = Architecture Constants =
// ==========================
// Number of Image Cache Lines (need 3, use 4 for simplified Addressing HW)
const int NUM_IMG_CACHE_LINES = 4;
// Number of Processing Elements
const int N_PE = 8;

const int DRAM_DEPTH = 5932576;

//IBRAM, OBRAM, WBRAM size (this value need to be changed by network)
const int MAX_IMAGE_CACHE_SIZE = 8704;
const int MAX_NUM_CHOUT = 128;
//const int MAX_CO_PER_PE=8;
// const int MAX_2D_FILTERS_PER_PE=1024;
const int MAX_2D_FILTERS_PER_PE= 2048;
//-------------Cache BRAM variable----------------
float OutputCache::OBRAM[MAX_NUM_CHOUT];
float ImageCache::IBRAM[MAX_IMAGE_CACHE_SIZE];
float WeightsCache::WBRAM[N_PE][MAX_2D_FILTERS_PER_PE][9];

二、程序之中结构嵌套及

 

 

未完

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

祥瑞Coding

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

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

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

打赏作者

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

抵扣说明:

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

余额充值