|
剛接觸,看不懂,希望先進們可以解說一下程式,還有一直編譯錯誤,我不懂為什麼錯誤,如果可以也想請教一下
% `( Q5 q7 v# i! \8 c2 c
6 T7 d4 N& S( R7 n9 f: v) U5 S'timescale 1ns/1ns! H; F$ v7 a1 U' Q9 h( S+ h
( U( A9 {8 a; y' h7 f) Gmodule the_2-4_decoder_testing_and_certification_program;" h w& i6 W" w; s4 r
) M s3 u4 F; N) Z. l+ @
wire[3:0]y;
' O9 F6 N0 x! Nreg a;) h* K) J, Q3 W9 k7 F
reg b;1 a* s" K' E( v0 b5 O* V) E
8 N! A, G2 o# r z: Z: A; _
deco2_4g UUT(
' T2 l5 x! {# r4 c+ I/ t* Z$ ? y .y(y),
6 ~1 a& V9 x4 P% Z .a(a),. ]% c+ A9 L4 n8 U, g% o9 i5 ~
.b(b));& c! u; ^/ D4 q) p+ a d6 G7 ?, c
7 C: l: H* |% ~- k# ~7 i r" L: I9 R0 Binteger TX_FILE;6 H: k# X. d& D: G
integer TX_ERROR;$ G; F, I6 ^8 ^
: q9 x& e+ V" f! w- L: J
initial $ r7 k( V& }% A- T/ ]0 n
begin
1 C4 {2 T [" X7 F `* w TX_ERROR=0;/ u: l6 O8 p- }5 C' u: d
TX_FILE=$fopen("result.txt");0 {, z9 `. s3 ^% ^$ P% D; s
% J' @" L, s: ~6 J3 j! i0 k/ ]- l) V# |
a=1'b0; + X' n: E' i& i/ v, s7 _
b=1'b0;& I' Q! O4 I. g w, T# Z, z
0 D L6 s7 l! ~5 j3 K0 B #100
: ]. z8 [, A x3 N( f0 t: z a=1'b1;
P& j4 K# R; o 6 L4 s0 J4 d$ t
#100
& P+ M8 K+ Z$ H q9 w3 s a=1'b0;
* X; {2 I! C, ?3 }( Q4 y b=1'b1;+ {. x$ i, {/ j5 ]2 Q
: R# ]9 k" s9 E+ T
#100# b0 x0 y5 x- b7 j! ]- u
b=1'b1;7 z& d0 |& B# k3 b' o2 }3 h( ]
6 {) `/ S2 A7 e& ]/ } #150. X+ r( \4 K' U4 ^
if(TX_ERROR==0)4 ~& v. U4 |& } w# o a6 ]
begin
7 O( I7 F' R2 \2 p% W1 u $display("No errors or warning");
: A% G3 ?- Q/ b6 V2 v p( x $display(TX_FILE,"No errors or warning");
" f; k/ f( T$ F2 o end else begin1 ?& v* |( |' o6 c+ ?
$display("%d errors found in simulation",TX_ERROR);( P+ n2 H3 x8 w; u' ^
$display(TX_FILE,"%d errors found in simulation",TX_ERROR);
' i' F! y+ k0 z, W/ n end + w% b8 D; U, A/ }
$fclose(TX_FILE);2 l7 C0 U& J" x" @/ o$ X1 J- M4 S
$stop;
3 H" Z9 F( E% _& p* H end
' w/ }1 t- d/ j9 \
+ v2 _3 `* Q% ~7 U" v" P* x. i task CHECK_y;+ @" H* t( n- Q. U
input[3:0]NEXT_y;
" c5 D2 r8 w7 ^8 }. h #0 begin
; [, r- y& c0 a- X2 m8 H B! T if(NEXT_y!==y)begin
2 D# G! s/ o- c( i' y# c3 Q9 s. { $display("Error at time=%dns y=%b,expected=%b",
) W- X7 ~" s5 i) F- ?- W $time,y,NEXT_y);' x1 u4 D1 c- G! T+ b3 `! M9 ]
$fdisplay(TX_FILE,"Error at time=%dns y=%b,expected=%b", * b: [4 l) C- g$ z% b0 g/ z7 I# G
$time,y,NEXT_y);# t9 u4 z8 a- a/ }! g3 | T
TX_ERROR=TX_ERROR+1;" a8 |6 t) x# t ]& \
end
2 X: h3 [' Z+ j* r9 Q# Y- v K3 ~( o end- ~% i2 N1 { N0 u3 J E+ I
endtask
3 g+ n% y& s' B/ n0 t" v5 E& o8 qendmodule |
|