|
剛接觸,看不懂,希望先進們可以解說一下程式,還有一直編譯錯誤,我不懂為什麼錯誤,如果可以也想請教一下- v7 Y# j. j+ o2 D
# O9 _! |( x& ?. J; C'timescale 1ns/1ns* j- V* Z r8 R4 [% e1 d# @+ d5 {
% a4 R* Z% x! z" @5 n0 K) o1 Hmodule the_2-4_decoder_testing_and_certification_program;
5 K0 x7 Z7 Y8 C. K. a+ w' F/ R% }0 p. u+ a2 c$ ^
wire[3:0]y;9 z, E- a. z, ^, v3 o1 g* K
reg a; F7 p J, F& N* c9 M
reg b;" m& X: U4 h) n' b9 w. I8 B( S- @' a
! Z. v ~4 p X6 ddeco2_4g UUT(
" o2 q; Y8 n* B6 Y- e1 _ .y(y),
' a3 q, T+ J# t7 X1 K5 J' O1 L8 C: g .a(a),
3 ], `4 b {; y. a6 T f+ ^9 c .b(b));
3 C; e4 r* _- x4 c0 r) j3 H - d/ O# `1 j0 V) @# @ b+ E9 ^
integer TX_FILE;
& z5 a) J( ^/ s }) L8 hinteger TX_ERROR;; f- s0 s! Q8 }* A, ^+ A. r
! b+ [9 X u, X5 E! j8 Kinitial
5 E2 f# a0 k/ t& J ]! o2 k `! X2 A: @begin
/ l o9 P% B6 F$ \; b& b. A7 g3 l TX_ERROR=0;
& K3 S5 I' @0 U$ {& Z { TX_FILE=$fopen("result.txt");
; U6 a* l# D3 X" ]0 q3 ^: b4 P ' \) }' y& v T" M7 ?! F% C
a=1'b0; ]' Q4 n) R5 z* A
b=1'b0;6 {6 i: b3 U, w- f2 @* x' P! O( t& V
) b, a! P9 p/ B) Y7 g: V& Q/ E #1000 P# l1 F* t5 K1 r" q" g
a=1'b1;
" l- q! p& c: a$ E/ J) N7 J
& s, @0 ~& V5 W+ x/ o4 G2 Y" @, _ #100
* [4 q- P7 i4 H. l! f9 S! Q a=1'b0; 6 B$ G+ S* w' Z4 X& [* r
b=1'b1;, j7 Q/ } M6 T" Z! y/ L
+ l6 V2 e. A3 I% k/ G6 M+ Y
#100
6 V6 t) h; ^: r& S b=1'b1;
" f* k1 b& U' v0 ] 2 s" L3 Y& m, h/ Z( T! W+ a/ I
#150) F K! j* F: {5 @$ Y1 t5 ^
if(TX_ERROR==0)
% m: M/ d2 c1 y) [: f# o0 i3 z, P begin
" l4 |' P+ E, \1 ~: B' x. p $display("No errors or warning");
- s0 K9 s6 X8 d( J3 K $display(TX_FILE,"No errors or warning");3 _+ A7 n t+ d; Y
end else begin
' T' f2 a8 c2 `( c8 [4 Z; _ $display("%d errors found in simulation",TX_ERROR);8 H: M' G$ b9 Z- m6 E6 f
$display(TX_FILE,"%d errors found in simulation",TX_ERROR);
% c7 A* R9 \. u$ Y end
+ r7 C* j7 h) h0 x8 a ]# t y8 O( O. I2 v/ l $fclose(TX_FILE);/ @6 e0 f. E: [6 g, a7 I) u
$stop;7 V# S2 x/ D0 W* w- \8 ]0 R
end ' K( o; J0 x. m" p
}' l( j8 o0 r: |9 F task CHECK_y;
1 m" ]1 u0 v) B input[3:0]NEXT_y;
, ~1 W: c6 H! P #0 begin* k. s2 w( f2 ?
if(NEXT_y!==y)begin
+ Q9 O$ a, w; `% q1 F $display("Error at time=%dns y=%b,expected=%b",4 ^0 D+ L/ Z2 o6 p# K' V
$time,y,NEXT_y);
5 W! ~( U+ t- Y! D $fdisplay(TX_FILE,"Error at time=%dns y=%b,expected=%b", 6 O6 X$ L c4 ^1 f8 @# o6 v! M8 q
$time,y,NEXT_y);5 C/ s' s2 F! H
TX_ERROR=TX_ERROR+1;) \/ e" [2 [& y& N
end ' J' P8 g8 B9 ^5 y
end
$ C. h* n; }% g% V1 l- o% Uendtask
- [# E! Q4 N3 H8 k" S2 n7 k2 Mendmodule |
|