Verilog HDL: System Tasks, File Related Operations, Compiler Directives

System  Tasks:
->all  system  tasks  appear  in  the  form  $
->operations   such  as  displaying  on  the  screen,  monitoring  values  of  nets,  stopping,  and  finishing  are  done  by  system tasks.
$display :  system  task  for  displaying  values  of  variables  or  strings   or   expressions very much   similar to  “printf”  in  C
Eg:  $display (p1,p2,p3,………pn);     where  p1,p2,p3  etc.  can  be  quoted  strings or variables or  expressions.
 

String  Format  Specification:
Format                                             Display
%d  or  %D      --------------à           display  variable  in  decimal
%b  or  %B       --------------à          display  variable  in  binary
%s  or  %S        --------------à            display  string
%h  or  %H      ---------------à           display  variable  in  hex
%c  or  %C       ---------------à             display  ASCII  character
%m  or  %M      ------------à            display  hierarchical  name (no  argument  required)
%v  or  %V        --------------à              display  strength
%o  or  %O          -------------à          display  variable  in  octal
%t  or  %T           -------------à            display  in  current  time  format
%e  or  %E            -------------à           display  real  no.  in  scientific  format (eg: 3e10)
%f  or  %F            --------------à           display  real  no.  in   decimal  format  (eg: 2.13)
%g  or  %G           -------------à          display  real  no.  in  scientific  or  decimal  whichever  is  shorter

$monitor:      monitor  a  signal  when  its   value  changes.
                       Eg:   $monitor(p1,p2,p3,……….pn);           where  p1,p2,p3 etc  can  be  variable,  signal  names  or  quoted  strings;   when  value  changes  ,value  is  displayed.
$monitoron:   enables  monitoring
$monitoroff:  disables  monitoring
$stop : task is  stopped  during  simulation
$finish :   terminates the  simulation

Useful  System  Tasks :
$fopen (“”);
Writing  to  files  : $fdisplay,$fmonitor,$fwrite,$fstrobe
$fdisplay(,p1,p2,……..pn) ;
$fmonitor(,p1,p2,………pn) ;
Closing  file :   $fclose () ;
Random number  generation  : $random() ;
Initializing  memory  from  file :
 $readmemb(“”,) ;
$readmemb(“”,,) ;
$readmemb(“”,,,) ;
Identical  syntax  for  $readmemb
Value change dump file :
$dumpvars
$dumpfile
$dumpon
$dumpoff
$dumpall
File Related Operations:
$fopen
$fclose
$fdisplay
$fmonitor
$readmemb
$readmemh

module mem8x8;
reg [0:7]  mem8x8[0:7];
integer chan_num1, i ;
initial
begin
$readmemb(“init8x8.data”, mem8x8);
chan_num1=$fopen(“mem8x8.data”);
for (i=0;i<8;i=i+1)
$display(chan_num1, “memory [%0d]=%b”, I, mem8x8[i]);
$fclose(chan_num1);
//Bit fields can’t be directly accessed from the memory.
//Read  a byte, then store temporarily in registervariable, then access bits.
//Only binary or hex values can be read from memory.
//($readmemb or $readmemh à no read of integer or float.
//File concepts are not synthesizable; Only static information available in the files are synthesizable.

Compiler   Directives:
‘define :-   same  as  #define  in  C
‘include :-   same  as  #include  in  C
‘ifdef  :-
‘timescale :-

No comments:

Post a Comment

Your Comments... (comments are moderated)