3360 views|7 replies

3

Posts

0

Resources
The OP
 

If and else have been matched, and latches are also generated [Copy link]

  In this code, if and else are already matched, why is there still a latch? When I change the number in the green box to all f, no latch is generated (I know how to fix other warnings, but I don’t know how to fix this latch problem)
This post is from Altera SoC

Latest reply

Direct Fword   Details Published on 2018-10-21 17:00
 
 

3

Posts

0

Resources
2
 
  1. module exe( clk , rst_n , CFword , data ); input clk; input rst_n; input [31:0] CFword; output [31:0] data; reg [31:0]data; reg [31:0 ] Fword; //frequency step always@(posedge clk or negedge rst_n)begin if(rst_n==1'b0)begin Fword <= 32'b0; end else Fword <= Fword + 21'h100000; end always@(posedge clk or negedge rst_n)begin if(rst_n==1'b0)begin data <= 32'b0; end else data < = Fword; end endmodule
复制代码
This is the code I wrote
This post is from Altera SoC
 
 
 

336

Posts

0

Resources
3
 
Fword <= Fword + 21'h100000; The subsequent addend uses 21 bits. Is it because of the bit width?
This post is from Altera SoC
Personal signature每一刻都是崭新的,加油!
 
 
 

3

Posts

0

Resources
4
 
Now I know the reason, it is because the last 20 bits are always zero, which is a fixed value, so the compiler will warn, but I don’t know how to change this program
This post is from Altera SoC

Comments

Adding a constant is no different from adding 1. Try replacing 21'10000 with 65536.  Details Published on 2018-8-8 11:18
 
 
 

5

Posts

0

Resources
5
 
This depends on whether your code will be modified. If the last few digits remain unchanged, you can directly write them as 0, then add the changed digits, and then splice them with 0. However, in this case, the code cannot be modified at will.
This post is from Altera SoC
 
 
 

367

Posts

0

Resources
6
 
This post was last edited by coyoo on 2018-8-8 11:20
qianguangsha posted on 2018-6-9 15:00 Now I know the reason, it is because the last 20 bits are always zero, which is a fixed value, so the compiler will warn, but I don’t know how to change this program
Adding a constant is no different from accumulating 1; you can try replacing 21'10000 with 1048576; this seems to be 32bit by default
This post is from Altera SoC
 
 
 

2113

Posts

0

Resources
7
 
Direct Fword <= Fword + 32'h100000;
This post is from Altera SoC
 
 
 

1

Posts

0

Resources
8
 
Direct Fword <= Fword + 32'h100000; Because your Fword is 32 bits, your direct Fword <= Fword + 21'h100000; is equivalent to the lower 21 bits being a D flip-flop, and the [31:22] bits are not assigned, so Fword[31:22] is recognized as a latch
This post is from Altera SoC
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list