Syntax Highlighting in Latex With The Listings Package: 1 VHDL
Syntax Highlighting in Latex With The Listings Package: 1 VHDL
writeLaTeX
June 1, 2018
1 VHDL
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− T i t l e : SAD
−− P r o j e c t : F i n a l p r o j e c t : SAD C a l c u l a t i o n
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− F i l e : SAD. vhd
−− Language : VHDL
−− Author ( s ) : F r a n c e s c o Urbani
−− Company :
−− Created : F r i May 18 1 6 : 2 3 : 3 3 CEST 2018
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− D e s c r i p t i o n : Actual SAD c a l c u l a t o r ( top l e v e l )
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
−− Update :
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
library ieee ;
use i e e e . s t d l o g i c 1 1 6 4 . a l l ;
−− u s e i e e e . s t d l o g i c u n s i g n e d . a l l ;
use i e e e . numeric std . a l l ;
2 Java
c l a s s HelloWorldApp {
p u b l i c s t a t i c v o i d main ( S t r i n g [ ] a r g s ) {
System . out . p r i n t l n ( ” H e l l o World ! ” ) ; // D i s p l a y t h e s t r i n g .
f o r ( i n t i = 0 ; i < 1 0 0 ; ++i ) {
System . out . p r i n t l n ( i ) ;
}
}
}
3 Python
1
#! / u s r / l o c a l / b i n / python
# c o d i n g : l a t i n −1
d e f t h i r d g r a d e e q u a t i o n ( c3 , c2 , c1 , c0 ) :
p r i n t ” Third g r a d e e q u a t i o n ”
p r i n t ” S t i l l working on t h i s f e a t u r e . . . ”
2
, myFormat ( phase ( re , im ) ) )
else :
p r i n t ( ” Second g r a d e e q u a t i o n . 2 pure i m a g i n a r y r o o t s ”
)
p r i n t ( ” d e l t a = %s ” ) %myFormat(− d e l t a )
p r i n t ( ” x1 = j%s ” ) %myFormat ( im )
p r i n t ( ” x2 = −j%s ” ) %myFormat ( im )
p r i n t ( ” \n” )
p r i n t ( ” x1 = %sexp ( j p i / 2 ) ” ) %myFormat ( im )
p r i n t ( ” x2 = %sexp (− j p i / 2 ) ” ) %myFormat ( im )
def f i r s t g r a d e e q u a t i o n (b , c ) :
i f b == 0 :
i f c == 0 :
p r i n t ”0 = 0 . I ’ l l take note . ”
else :
p r i n t ” O p e r a t i o n f a i l e d . %s i s not e q u a l t o 0 ” %
myFormat ( c )
else :
p r i n t ( ” F i r s t grade equation . 1 root ” )
p r i n t ( ”x = %s ” ) %myFormat ( f l o a t (−c ) /b )
d e f c a l c u l a t e ( c3 , c2 , c1 , c0 ) :
i f c3 == 0 :
i f c2 == 0 :
f i r s t g r a d e e q u a t i o n ( c1 , c0 )
else :
s e c o n d g r a d e e q u a t i o n ( c2 , c1 , c0 )
else :
t h i r d g r a d e e q u a t i o n ( c3 , c2 , c1 , c0 )
4 MATLAB/Octave
o c t a v e :1> f u n c t i o n xdot = f ( x , t )
>
> r = 0.25; k = 1.4;
> a = 1.5; b = 0.16; c = 0.9; d = 0.8;
>
> xdot ( 1 ) = r ∗x ( 1 ) ∗ ( 1 − x ( 1 ) /k ) − a∗x ( 1 ) ∗x ( 2 ) / ( 1 + b∗x ( 1 ) ) ;
> xdot ( 2 ) = c ∗ a∗x ( 1 ) ∗x ( 2 ) / ( 1 + b∗x ( 1 ) ) − d∗x ( 2 ) ;
>
> endfunction