FPGA组合逻辑之注意项
2016-01-29 18:30
489 查看
先上代码:
always @(*)begin
if(recie_tlp_fifo_ren & recie_tlp_fifo_rdata[TLP_SOP])begin
if({recie_tlp_fifo_rdata[TLP_FMT_1D +:2],recie_tlp_fifo_rdata[TLP_TYPE_1D+:5]}==MWR_3DW)
word_3d_type = 3'b001;
else if({recie_tlp_fifo_rdata[TLP_FMT_1D +:2],recie_tlp_fifo_rdata[TLP_TYPE_1D+:5]}==MRB_3DW)
word_3d_type = 3'b010;
else
word_3d_type = 3'b100;
end
end
你们觉得这样写对吗?当初用chipscope在板子上调试时word_3d_type值为3‘b111或3’b110等其它情况,当时以为是distri
fifo不稳定导致的,后改为block fifo还是这样,而直接改为时序逻辑又会增加很多判断条件,无奈请教之,才知道,组合逻辑必须要将else补充完整,不能出现不确定状态和环路状态(即word_3d_type = word_3d_type,当然时序逻辑可以这样),否则导致程序出错,后改为如下方法
always @(posedge clk_125m) begin
recie_tlp_fifo_ren_1d <= recie_tlp_fifo_ren;
end
always @(posedge clk_125m) begin
recie_tlp_fifo_rdata_1d <= recie_tlp_fifo_rdata;
end
always @(posedge clk_125m) begin
if(recie_tlp_fifo_ren & recie_tlp_fifo_rdata[TLP_SOP])begin
if({recie_tlp_fifo_rdata[TLP_FMT_1D +:2],recie_tlp_fifo_rdata[TLP_TYPE_1D +:5]}==MWR_3DW)
word_3d_type <= 3'b001;
else if({recie_tlp_fifo_rdata[TLP_FMT_1D +:2],recie_tlp_fifo_rdata[TLP_TYPE_1D +:5]}==MRB_3DW)
word_3d_type <= 3'b010;
else
word_3d_type <= 3'b100;
end
end
然后再根据word_3d_type 判断recie_tlp_fifo_ren_1d与recie_tlp_fifo_rdata_1d情况。
提示:对于提前获取关键信息,这种打拍方法是非常可取的。
always @(*)begin
if(recie_tlp_fifo_ren & recie_tlp_fifo_rdata[TLP_SOP])begin
if({recie_tlp_fifo_rdata[TLP_FMT_1D +:2],recie_tlp_fifo_rdata[TLP_TYPE_1D+:5]}==MWR_3DW)
word_3d_type = 3'b001;
else if({recie_tlp_fifo_rdata[TLP_FMT_1D +:2],recie_tlp_fifo_rdata[TLP_TYPE_1D+:5]}==MRB_3DW)
word_3d_type = 3'b010;
else
word_3d_type = 3'b100;
end
end
你们觉得这样写对吗?当初用chipscope在板子上调试时word_3d_type值为3‘b111或3’b110等其它情况,当时以为是distri
fifo不稳定导致的,后改为block fifo还是这样,而直接改为时序逻辑又会增加很多判断条件,无奈请教之,才知道,组合逻辑必须要将else补充完整,不能出现不确定状态和环路状态(即word_3d_type = word_3d_type,当然时序逻辑可以这样),否则导致程序出错,后改为如下方法
always @(posedge clk_125m) begin
recie_tlp_fifo_ren_1d <= recie_tlp_fifo_ren;
end
always @(posedge clk_125m) begin
recie_tlp_fifo_rdata_1d <= recie_tlp_fifo_rdata;
end
always @(posedge clk_125m) begin
if(recie_tlp_fifo_ren & recie_tlp_fifo_rdata[TLP_SOP])begin
if({recie_tlp_fifo_rdata[TLP_FMT_1D +:2],recie_tlp_fifo_rdata[TLP_TYPE_1D +:5]}==MWR_3DW)
word_3d_type <= 3'b001;
else if({recie_tlp_fifo_rdata[TLP_FMT_1D +:2],recie_tlp_fifo_rdata[TLP_TYPE_1D +:5]}==MRB_3DW)
word_3d_type <= 3'b010;
else
word_3d_type <= 3'b100;
end
end
然后再根据word_3d_type 判断recie_tlp_fifo_ren_1d与recie_tlp_fifo_rdata_1d情况。
提示:对于提前获取关键信息,这种打拍方法是非常可取的。
相关文章推荐
- 读OpenGL游戏编程笔记1
- 数据库配置环境
- 编译androdi的时候,res下面不能放bat文件
- 三天学会HTML5 之第一天
- Twitter Snowflake 的Java实现
- Codeforces Gym 100819S Surf
- 基础差不得不学啊(unity shader中的矩阵学习一)
- hdu 2212 DFS
- scikit-learn入门到精通(二):seting和estimator
- 这些年我踩过的坑——Android
- struct 和 class 不同点
- 比 Logcat 更加美观易用的异常信息接收器: CrashWoodpecker
- VS2012发布网站详细步骤
- USB集腋成裘:从Linux PC角度看sys.usb.config为none时的Android设备
- CAS SSO使用指南
- 配置持续集成QuickBuild调用Ranorex进行IOS自动化测试
- 大数据下的日志-前台展示:无按钮浏览(无按钮,自动滚屏)
- ListView的条目定位
- Python -- 字典与字符串的互转
- Android studio 删除无用代码