集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 993|回复: 0

FPGA时序改善代码,参悟

[复制链接]
fpga_feixiang 发表于 2017-8-26 15:53:50 | 显示全部楼层 |阅读模式
1 module randomlogic_1(
2     output reg [7:0] Out,
3     input [7:0] A, B, C,
4     input clk,
5     input Cond1, Cond2);
6 always @(posedge clk)
7     if(Cond1)
8         Out <= A;
9     else if(Cond2 && (C < 8))
10         Out <= B;
11     else
12         Out <= C;
13 endmodule            
复制代码


第二版:

复制代码
1 module randomlogic_2(
2     output reg [7:0] Out,
3     input [7:0] A, B, C,
4     input clk,
5     input Cond1, Cond2);
6
7 wire CondB = (Cond2 & !Cond1);
8
9 always @(posedge clk)
10     if(CondB && (C < 8))
11         Out <= B;
12     else if(Cond1)
13         Out <= A;
14     else
15         Out <= C;
16 endmodule
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-5-5 20:06 , Processed in 0.056818 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表