|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
七人表决器的程序如下9 r$ Z n k* Q) ~/ O
module voter7( 8 w$ x- }2 V6 T6 V# j1 E
output reg pass,
) {$ k, L$ U8 l( e" [5 ?# O/ J# c input[6:0] vote
6 |, t$ \- `; F5 V1 p );3 F3 e$ M# ^3 |1 V. a
integer i;
- y/ E, C$ a; j" Q- u" I c* Hreg[2:0] sum;
$ T) E2 I5 i' f8 O+ h9 D initial
6 W# V# x% \# R$ b ` begin5 |8 m! y% |3 Q( K% S9 U5 X
sum=3'b000;
& H* N- _8 Z. U6 t) l: z end
/ j) t, O3 t3 e7 a, f 0 U: C8 W) Y- }) V* w
always @(vote) / ^' d2 Q( p" \5 K# j0 x
begin & Y% z& P: y* C4 N/ V( I3 C
7 Z* `4 G5 b* J4 o3 @. D% U( q
for(i=0;i<=6;i=i+1) //for语句3 n' n" G! S; R/ J3 |9 {$ o9 k
begin
V0 G6 q5 S/ y' I+ P if(vote[i]) sum=sum+1;
. j$ K9 J. L# Y/ M/ L5 {. m q end$ V3 }" ]& U. N
if(sum>3) pass=1'b1; //若超过4人赞成,则pass=1 / \2 u# X( ]2 ~1 a
else pass=1'b0;
! H' t# m: g! i, I end 8 t# a' \- {; C! c
endmodule % q6 X4 v6 R$ p- V+ d
( I* Y; Z9 y) C
3 v4 H8 ~8 i+ [. e4 ]' L: t6 Z
7 a8 A2 \& M0 c% B有提示是这样的! C5 ~- K( a% Z0 Y: U; p
Warning (10235): Verilog HDL Always Construct warning at voter7.v(18): variable "sum" is read inside the Always Construct but isn't in the Always Construct's Event Control1 t0 v; M! S4 X, t; d
# l, H4 f1 u$ o6 }% R
Warning (10240): Verilog HDL Always Construct warning at voter7.v(13): inferring latch(es) for variable "sum", which holds its previous value in one or more paths through the always construct7 f2 V) |6 G6 N) R- o1 }9 }) l6 G
# ], e0 J% s1 S9 T2 u/ M6 p
仿真的时候pass信号为未知状态 / E$ I) l2 Q: W& N% q& ?8 E" X
怎么办呢? |
|