本文将简述一种fifo读控制的不合理设计案例,在此案例中,反压信号type1_fc和type2_fc会不合理阻塞读控制信号,造成性能损失,甚至会造成严重bug。
如下图所示:all_data_fifo 为主数据路径的存储fifo,用于存储报文,所有正常报文类型包含:TYPE1和TYPE2。数据从all_data_fifo读出后会分根据报文类型分发到两个fifo,分别是type1_data_fifo和type2_data_fifo。两个fifo分别产生反压信号type1_fc和type2_fc作用到data_fifo的读控制模块。type1_data_fifo/type2_data_fifo将满时,将type1_fc/type2_fc置1表示不希望上游all_data_fifo向下发送数据。
data_fifo_ren为all_data_fifo读使能信号,1表示读fifo。all_data_fifo_empty为1表示all_data_fifo为空,没有数据。
错误设计中,all_data_fifo_empty、type2_fc和type1_fc均为0,才允许读all_data_fifo。
正确设计中,应该区分当前all_data_fifo中的数据类型,当数据为type1类型时,type1_fc才会生效,当数据为type2类型时,type2_fc才会生效,避免出现过度流控,造成数据阻塞。
NOTE: 本文中列举的案例很简单,但在实际芯片设计中时常会出现此类问题,并且隐藏在很复杂的读控制逻辑中,不容易发现。
//---错误设计---//assign data_fifo_ren=(!all_data_fifo_empty)&&(!type2_fc)&&(!type1_fc);
//---正确设计---//assign data_fifo_ren=(!all_data_fifo_empty)&&(!type1_pkt_fc)&&(!type2_pkt_fc);
assign type1_pkt_fc = (all_data_fifo_dout.msg_type==`MSG_TYPE1) && type1_fc ;
assign type2_pkt_fc = (all_data_fifo_dout.msg_type==`MSG_TYPE2) && type2_fc ;
特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.