|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
七人表决器的程序如下
" u. ~5 C4 f9 V& k$ @% d& X7 qmodule voter7(
2 j7 H4 ^+ L1 V5 V% ]/ \' ] output reg pass,
' y" n2 b( g- w# k% X2 [3 D input[6:0] vote5 A, O5 y, g7 N" I; [" N; J7 }
);
1 k: r9 s, Y% G2 I6 O# Uinteger i; - F! r6 W$ x) w$ T9 C. A- [
reg[2:0] sum;
4 O' k& I2 p+ h) c& h) y initial
0 s( B7 H; {0 ^ begin
R9 A8 a* y: J, ?) y sum=3'b000;
7 [! I# Q4 ~, p end
1 d' n, t$ Z6 j4 `2 R * Y$ G" m/ x( K }, F7 s* X
always @(vote) $ a! L5 A0 h7 Y: a
begin
( Q9 k/ J/ H( n9 w
+ o. Y7 M/ K3 f9 v& f: U for(i=0;i<=6;i=i+1) //for语句% e4 j' P! ~4 z) T0 @
begin , p# A$ E/ g) g5 }) H6 R G7 |
if(vote[i]) sum=sum+1; 8 _. O" P3 v* v" ? w# P
end
1 d9 N3 e4 j6 w5 o5 O$ \: S if(sum>3) pass=1'b1; //若超过4人赞成,则pass=1 6 o7 e3 r4 b; z/ h( l9 F$ C' r
else pass=1'b0; 4 l( _ S6 R- v* r; ]+ L
end 1 ]9 t( }4 @2 K( T$ `' m0 }1 \
endmodule
( C6 N5 m5 d _: Y) q, T8 w3 B
1 L/ t1 I, z$ {- [" v& K7 f1 D) K3 v1 T/ M- [) \% e, x
) u1 ~' P( m; B7 @) v
有提示是这样的, J5 B! f! ]) I# U) }1 q& r
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 Control
& s4 P- v+ q3 ?# h0 K
( E5 l; ~- c, NWarning (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 construct6 t1 O* @: D) p W( U0 w- T; e
" r- I: u( b% ~/ Y7 R
仿真的时候pass信号为未知状态 1 X+ {# j) M3 ~$ j
怎么办呢? |
|