|
剛接觸,看不懂,希望先進們可以解說一下程式,還有一直編譯錯誤,我不懂為什麼錯誤,如果可以也想請教一下
, j0 U: Z+ }. C7 [: \; ~2 W6 ^ p# \8 X! O
'timescale 1ns/1ns# K2 M1 w- Z# H v% O2 y* v
7 M& o' d% k; W3 Y1 p
module the_2-4_decoder_testing_and_certification_program;
& ^3 D2 P4 G( m/ u- _$ e7 h' j9 o& z- j" u# Q
wire[3:0]y;
7 K& b% L. ~$ D6 g2 b( V8 treg a;; [' d5 `: s# ~
reg b;
5 N+ C: `1 r- g. E
$ ]# j' J, {$ ^5 Q% T) a' V; Qdeco2_4g UUT(7 g( I" H: U) E3 [" W+ \
.y(y),# }- ^8 ^2 f: S& w0 ~' S r' z
.a(a),, L3 m6 a2 _" F
.b(b));
8 y$ D+ E( D$ u2 Z8 }1 ^: V0 ~1 Z. F 3 n; @7 h2 T' y# Q4 `
integer TX_FILE;
2 i- Q( C/ v0 L Sinteger TX_ERROR;% ~ n" ]. g5 L, m
$ \! I5 o, x6 M, a, U _4 v& Y
initial / _0 x, f# U) L6 ]. m" P
begin
, p g9 L! W( V' u% x8 L TX_ERROR=0;# j$ g( ?8 u$ } b' ^6 _
TX_FILE=$fopen("result.txt");
& N) S5 Y. Q: j7 C6 m& n! c
( u8 l. y1 |5 Y+ g v, { a=1'b0;
& b8 i4 U0 U& [5 ^* b) i* D- \% B0 v b=1'b0;( e) {( t" W& d! t9 B
$ `6 G- } p/ F9 _1 | #100
3 V3 n* D- O. e5 D7 W a=1'b1;
9 j' b" J R# M/ u2 B) ] : W0 F+ ~: Z) F* ?# J+ h8 W
#1002 L# v \0 C! o/ b4 A
a=1'b0; 5 c9 p% A7 j1 }0 y
b=1'b1;$ q4 ^8 z. N0 h
% Z8 {8 w1 d, Q2 z9 Y, e
#100
2 z2 _, d; k k3 ` b=1'b1;
& A% i- Q1 P1 L8 h/ e/ Q" Y, b
4 c5 }6 y$ a- k D+ J #150
: h, B8 h8 A% Y if(TX_ERROR==0)
( F4 U: @3 G4 I2 e. q x begin
" F& t+ H, ?9 Z! }8 S! S6 K $display("No errors or warning");3 a0 H ?4 P! P, _; Y
$display(TX_FILE,"No errors or warning");
+ S7 w7 b; b/ e# e+ b" O end else begin
( x& p [7 F. h5 ^# I9 C: j# e $display("%d errors found in simulation",TX_ERROR);+ g0 i) w Q8 L) s$ f
$display(TX_FILE,"%d errors found in simulation",TX_ERROR);
) l3 ]/ R8 H2 c( s3 L' G1 [ end
, k& @* l/ o' | $fclose(TX_FILE); L7 X" \, _3 C' o F9 c' K
$stop;
3 `4 p9 n" C D+ k) p- W end 4 J3 }8 [4 i- {5 A7 _
6 C1 g$ @, Y w4 w: G9 O @0 ]1 N
task CHECK_y;. H% |8 f6 e5 T+ c7 Z4 l
input[3:0]NEXT_y;
( A6 ]7 k; p3 x! a0 {* c( W #0 begin) j7 s! c X/ q
if(NEXT_y!==y)begin
+ w0 i( L* M( {0 V2 V/ h; ` $display("Error at time=%dns y=%b,expected=%b",! b2 V$ R+ ~4 h2 ^8 \
$time,y,NEXT_y);
/ {6 k7 N& V- g+ F $fdisplay(TX_FILE,"Error at time=%dns y=%b,expected=%b",
$ _2 ~+ x8 i- W $time,y,NEXT_y);& e* C8 G# ]6 C( i7 r5 T$ K6 Y, L
TX_ERROR=TX_ERROR+1;
! s) U1 q* C# {/ r end / V$ [" A v1 W1 i4 S' B
end
. N& j' t3 C( X% eendtask2 |9 t/ F6 I6 |9 C% F( ]
endmodule |
|