
2.2. A SIMPLE UART
25
Listing 2.1: Test bench for the UART.
‘ t i m e s c a l e 1 n s / 10 ps
module l a b 0 _ t b ( ) ;
re g c l k _ i ;
re g r s t _ i ;
re g s e n d _ i ;
re g [ 7 : 0 ] s w i t c h _ i ;
wi r e [ 7 : 0 ] l e d _ o ;
wi r e jumpe r ;
/ / I n s t a n t i a t e a UART
l a b 0 u a r t ( . c l k _ i ( c l k _ i ) , . r s t _ i ( r s t _ i ) , . r x _ i ( ju m p e r ) , . t x _ o ( j um per ) ,
. l e d _ o ( l e d _ o ) , . s w i t c h _ i ( s w i t c h _ i ) , . s e n d _ i ( s e n d _ i ) ) ;
al ways # 1 2 . 5 c l k _ i = ~ c l k _ i ; / / 40 MHz c l o c k
i n i t i a l
beg i n
c l k _ i = 1 ’ b0 ;
s w i t c h _ i = 8 ’ h41 ; / / A
r s t _ i = 1 ’ b1 ;
s e n d _ i = 1 ’ b0 ;
#100 r s t _ i = 1 ’ b0 ;
#1000 s e n d _ i = 1 ’ b1 ;
#1100 s e n d _ i = 1 ’ b0 ;
end
endmodule
Kommentare zu diesen Handbüchern