|
剛接觸,看不懂,希望先進們可以解說一下程式,還有一直編譯錯誤,我不懂為什麼錯誤,如果可以也想請教一下( n" a' [0 D1 \+ M% d+ w2 q
& B% h8 v: ~1 i8 G t* s'timescale 1ns/1ns
) I1 |! N/ ^7 W& d/ {. C: g: Z& C$ `! _) Q' G6 S
module the_2-4_decoder_testing_and_certification_program;
) v6 S- [- f! B3 o: i; B ]9 N* p3 n s: T) [
wire[3:0]y;: M; Z2 R; n$ y7 L. q) }( O2 C( c2 R
reg a;; t% s0 j( {3 x, d$ x
reg b;' `' E t' W% y, A- J
: b( h! Y# h4 K7 E: B4 ^deco2_4g UUT(' [1 Z* S. A: s1 l
.y(y),
) p) d3 q& i# `+ @( X .a(a),
4 @ D# }* o3 z/ s9 T .b(b));# Y2 s6 A! s3 w% l8 V2 W# j0 g- C
' F' y5 r2 g$ N2 C: n* Ointeger TX_FILE;
( U: U- V8 k" h; @$ H1 j6 jinteger TX_ERROR;. A4 ?4 s. C' d* T( t8 n4 u4 l
: ?4 f4 \0 _7 l; P( Q$ t
initial ' x) E1 o+ Q% ~- c; L
begin
1 w( n; s+ ]/ S8 y2 O TX_ERROR=0;
. Q! z/ L! F) _! s TX_FILE=$fopen("result.txt");4 y; ]9 L" N4 _, I( x* B
% S9 U3 o5 N) @. K* F9 t a=1'b0; ' M! s3 ?7 X/ ]/ i' t7 d" S9 o! `# t2 I
b=1'b0;! u$ ?: h% k+ l& T3 V& ^$ A3 d4 `! R
+ C* } F1 r4 R7 q I #100
. N* r( G5 ?8 ^8 |8 C a=1'b1;# ~! O& U6 C4 r2 U- e8 D
0 N% B( W, j9 y6 Q6 [. l #100
& G3 H" A" A8 ~ a=1'b0; 0 f% `! W$ | Q% G5 B. R
b=1'b1;- Y: q5 I: L$ B0 e" u$ ]8 O
( n# m- i1 L3 R: M #100' S# C4 H& q# b2 A d4 l+ a4 {5 T
b=1'b1;5 }$ u9 |, R& W( |
. c# Y) m0 n$ K' T# C! t
#150 r/ i( S3 J8 _
if(TX_ERROR==0)
: S: `; i& p x: v8 E0 h begin
/ L& T2 e1 U. [. V' b @7 Q $display("No errors or warning");
- F8 V+ Y; P, \( o/ a% j0 D" H $display(TX_FILE,"No errors or warning");7 X" O7 C) ^( h- k6 f2 k
end else begin% }9 K8 @5 k6 b0 x% d# d
$display("%d errors found in simulation",TX_ERROR);
; S6 {' l% F7 o* v $display(TX_FILE,"%d errors found in simulation",TX_ERROR);
n2 U+ v- V$ y0 l4 X end
: R. R& O- X( C0 e' n $fclose(TX_FILE);
, Q5 s& c, `- s; n9 x: J0 } $stop;
5 U6 `. X# r& r: a# K N: U& g end $ L2 U3 }) w& N: P+ z( y4 k# y& s
; ~; ~. h3 }; b
task CHECK_y;( v; R2 Y1 q' ~& K
input[3:0]NEXT_y;
. ?' O" @ d7 }5 g #0 begin
# A8 \3 h6 @, e if(NEXT_y!==y)begin
. f; C7 F/ `9 d; e \. P. U* w $display("Error at time=%dns y=%b,expected=%b",: J7 c" M4 e9 N/ K0 J' J5 Q+ g
$time,y,NEXT_y);. y; E6 }: o% W9 A, P* u
$fdisplay(TX_FILE,"Error at time=%dns y=%b,expected=%b", & a' _9 r P0 e1 K# b
$time,y,NEXT_y);
7 {# Q F1 |6 D) z/ m/ [* G7 R TX_ERROR=TX_ERROR+1;
8 I2 M8 B$ C% }5 I end $ x2 z( k2 I; j! d- z- j
end8 @2 S/ A0 t# o
endtask
0 a1 C$ ]4 }/ e" `7 Sendmodule |
|