标题: 对这段文字描述感觉有些困惑 [打印本页] 作者: mengzhuhao 时间: 2007-12-21 18:01 标题: 对这段文字描述感觉有些困惑 对这段文字描述感觉有些困惑 0 H& Q$ u) [/ N8 ] ! V' Y( v1 J$ @) j4 n Z+ R1 g1 M . @: E' h& U" v& F4 x5 D# H8.0 Actual "full_case" design problem1 r8 A7 C+ C5 R$ {1 M
The 2-to-4 decoder with enable in Example 12, uses a case statement that is coded without using0 `3 ]! z/ a- `7 x% p" `
any synthesis directives. The resultant design was a decoder built from 3-input and gates and6 I% r1 k8 v p5 t/ ]0 q
inverters. No latch is inferred because all outputs are given a default assignment before the case : ~' ^ O9 h7 p- \% J1 gstatement. For this example, the pre-synthesis and post-synthesis designs and simulations( S$ Z/ @0 V; A5 A/ m0 Y, v/ S
matched. The 2-to-4 decoder with enable in Example 13, uses a case statement with the # P0 A# g, S( \"full_case" synthesis directive. Because of this synthesis directive, the enable input (en) was- x5 u! H F4 B6 f
optimized away during synthesis and left as a dangling input. The pre-synthesis simulation) p% V" q M# }( u9 k( f
results of modules code4a and code4b matched the post-synthesis simulation results of module0 i+ ~. a% G7 r
code4a, but did not match the post-synthesis simulation results of module code4b [2].6 q# U9 f( Q, @- X' B% k& |2 X* J
// no full_case Q6 k* L+ {0 |+ k( E9 h
// Decoder built from four 3-input and gates9 y8 N' J9 z* {+ N9 b
// and two inverters4 f% n, Z! }, @2 G- l8 j
module code4a (y, a, en); ; O- Z% A, D X4 _output [3:0] y; h! A3 G7 S* F7 M; B' ~
input [1:0] a; , b3 i ]; i+ `! }& E% d6 l F- `6 c0 xinput en; * E+ C9 X, v4 e- D! oreg [3:0] y;: ~% c; i2 I, p: Y, q* l$ ~
always @(a or en) begin* N- Y1 s9 U6 o' o, A9 f
y = 4'h0;( `0 L$ i; D/ j: S
case ({en,a}) ! x. o) i0 H u1 c' z7 u% F3'b1_00: y[a] = 1'b1;0 z- b& T2 z2 ]& z7 I1 a, B% G
3'b1_01: y[a] = 1'b1;. @! w: o3 w5 a) k! N( v. v
3'b1_10: y[a] = 1'b1;! i6 |# C( R' |# p1 ]' F
3'b1_11: y[a] = 1'b1; * j" O/ X1 `3 A& |endcase . R, }! }- V6 G7 F0 k- ]end" ^) q$ V; D' f! @3 B
endmodule) w& V' _* {" H, \/ r
Example 12 - Decoder example with no "full_case" directive # u- I! w& v1 hStatistics for case statements in always block at line 9 in file - J! G+ R1 J: T l# E'.../code4a.v' 0 O, _& B- S4 t) I ]/ t===============================================0 `( i/ J2 A; r5 V# {8 C
| Line | full/ parallel | ) F. u. u1 t1 \* \% l=============================================== N( n+ j2 U/ Y5 v
| 12 | no/auto |7 R" i. R* @9 O
===============================================- ^' d3 D3 |& I5 k" H6 F
Figure 19 - Case statement report for Example 12; [4 g: g6 o/ @
* V0 d. T* ]! M1 g; D/ y {7 T 8 [/ R6 o- ~0 E( }' c// full_case example) z. {3 N+ E: B `/ \: d0 N. a% x
// Decoder built from four 2-input nor gates + U8 y+ w: i% o; u// and two inverters 0 L/ i+ B" I* J' z% C8 n1 _// The enable input is dangling (has been optimized away)" b: \& {# @3 P2 I" c( c. N) N% V. Z
module code4b (y, a, en);8 D" l6 Y' [( I/ K" X. V/ `
output [3:0] y;5 f& Y3 p2 S) i+ ` _0 A0 a) Z
input [1:0] a;8 ?: D Z7 d: O( q/ g" R- a
input en; 0 `; [* E8 ^$ ]$ L* v( \reg [3:0] y; " q# h! C. ^ Q& i, |5 @' `6 Malways @(a or en) begin) j7 n7 o+ @# C
y = 4'h0; ) _! y1 W# Z2 J0 g3 hcase ({en,a}) // synopsys full_case ! v( v+ f1 P4 l, o8 s3 H! p3'b1_00: y[a] = 1'b1; 4 ~8 g, N% c; S' T, c7 d; n( ]5 E- n3'b1_01: y[a] = 1'b1;/ e- h" q/ g& e2 t, q' L2 R
3'b1_10: y[a] = 1'b1;" q" a6 B; w" z, U4 _$ _: j
3'b1_11: y[a] = 1'b1; 2 Z- f6 X; ?. m2 U) t+ T) lendcase6 e4 N( }% X( H4 ^$ y1 \4 o
end- \! Q5 A8 u& N
endmodule- y( a" H. D3 r3 e0 v
Example 13 - Decoder example with "full_case" directive& g1 s+ r" L! U* C( _! V, @
Warning: You are using the full_case directive with a case statement in which 0 M+ X% o: b7 X c1 }not all cases are covered& c% N8 r, Y8 G7 s0 E; |7 z/ F
Statistics for case statements in always block at line 10 in file ) C2 X$ d6 U6 ^" y/ T+ c: V E( {'.../code4b.v' * k8 m0 I" v. ?( `) ~6 v===============================================0 [$ P1 _3 B; N8 q1 ]
| Line | full/ parallel | - l o# F+ t' g===============================================5 G# z6 Y) g+ l6 o- E, @7 Y2 w4 z* `
| 13 | user/auto |' e: ?3 v! H/ K* N" s6 A
=============================================== 6 q. J: x/ w+ {5 ?5 PFigure 20 - Case statement report for Example 130 S1 u9 }( G$ n( [' V: M7 H
0 h- I. b1 m8 p. S+ _2 E谁给解释一下原因呢? ) ~( L6 I, P/ e0 l: c为啥会有差异?