Lenet神经网络加速器作为NICE协处理器
Lenet神经网络加速器作为NICE协处理器
团队编号:CICC2136
团队名称:芯如止水
功能介绍
Lenet神经网络加速器可以用于识别手写的数字,并将结果返回
利用Lenet神经网络加速器作为NICE协处理器,可以实现从内存中读取图像数据,将数据利用神经网络加速器进行识别,最后将识别的结果返回
硬件部分简介
- 例化Lenet神经网络加速器的顶层模块,用于处理图像数据
lenet i_lenet( .clk (nice_clk), .rst_n (nice_rst_n), .go (compute_go_r), .cena_image (cena_image), .aa_image (aa_image), .conv1_image (image_input), .digit (result_digit_nxt), .ready (result_ready) ); 定义一个存储模块,用于保存从内存中读取的图像数据
lenet_src_rom lenet_src_rom( .clk (nice_clk), .rst_n (nice_rst_n), .aa (aa_image), //地址 .cena (cena_image), //使能 .qa (image_input),//图像数据 .data_in_en (lbuf_wr ), .data_in (lbuf_wdata[7:0] ), .data_in_addr (lbuf_idx ) );
软件部分简介
定义了两条NICE协处理器指令,分别用于从内存中读取数据,利用LENET处理图像
// custom lbuf
__STATIC_FORCEINLINE void custom_lbuf(int addr)
{
int zero = 0;
asm volatile (
".insn r 0x7b, 2, 1, x0, %1, x0"
:"=r"(zero)
:"r"(addr)
);
}
// custom calculate
__STATIC_FORCEINLINE int custom_calculate(int addr)
{
int result;
asm volatile (
".insn r 0x7b, 4, 1, %0, %1, x0"
:"=r"(result)
:"r"(addr)
);
return result;
}
主程序部分
uint64_t addr = 0xA0000000 ;
printf("custom_lbuf\n");
custom_lbuf(addr);
printf("Finish_custom_lbuf\n");
printf("custom_calculate\n");
int result = custom_calculate(addr);
printf("Finish_custom_calculate result is %x\n", result);
💡 请 登录 后参与讨论(微信扫码即登录/注册)
帖子信息
版块全国大学生集成电路创新创业大赛
回复1
浏览3772
发布2023-05-27 18:21