0% found this document useful (0 votes)
32 views24 pages

Basics in Verilog

This document provides an overview of basics in Verilog including system tasks, file operations, randomization concepts and interview questions. It discusses tasks like $display, $monitor, $strobe and their priorities. It also covers random number generation using $random, $urandom and $urandom_range as well as file I/O tasks like $fopen, $fclose, $fdisplay, $fwrite, $fstrobe and $fmonitor.

Uploaded by

jerinkakkurumpil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views24 pages

Basics in Verilog

This document provides an overview of basics in Verilog including system tasks, file operations, randomization concepts and interview questions. It discusses tasks like $display, $monitor, $strobe and their priorities. It also covers random number generation using $random, $urandom and $urandom_range as well as file I/O tasks like $fopen, $fclose, $fdisplay, $fwrite, $fstrobe and $fmonitor.

Uploaded by

jerinkakkurumpil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

BASICS IN VERILOG

Presented by : Revanth Jangili


Trainer : Sulthana Shaik
Overview
�System Tasks
�Randomization Concepts
�File Operations
�Interview Questions

2
System Tasks

3
$display

4
5
$display example :

6
$monitor

7
$monitor example :

8
9
$display , $monitor , $strobe
�These three syntax have priorities while display
�$strobe has least priority compared to $display
�In-between $monitor and $strobe ,$monitor has least
priority
�Priority order:
$display ,$strobe ,$monitor
Ex: $display(”A”);
$display(“B”); OUTPUT: A
$monitor(“C”); B
$monitor(“D”); D
10
11
12
13
Randomization concept in verilog
Why Randomization?
�Direct Stimuli takes long time to develop all possible
scenarios to verify different features
�Random testing is used to find the unexpected bugs

Few keywords used for random value generation are:


Ø $random
Ø $urandom()
Ø $urandom_range()

14
15
16
EXAMPLE:

17
$urandom()
�Function generates 32-bit random number but it is
always unsigned

bit{31:0] d;
d=$urandom();
Integer seed =3;
Int b=$urandom(seed);

18
$urandom_range()
�It returns the unsigned values between specified range

Syntax:
$urandom_range(max,min);

19
File Operations
�$fopen opens an output file and gives the open file a
handle for use by the other commands.
�$fclose closes the file and lets other programs access it.
�$fdisplay and $fwrite write formatted data to a file
whenever they are executed. They are the same except
$fdisplay inserts a new line after every execution and
$write does not.
�$fstrobe also writes to a file when executed, but it waits
until all other operations in the time step are complete
before writing.
�$fmonitor writes to a file whenever any of its arguments
changes
20
File Operations - Usage
�handle1=$fopen("filenam1.suffix") ;
�handle2=$fopen("filenam2.suffix") ;
�$fstrobe(handle1, format, variable list); //strobe data
into filenam1.suffix
�$fdisplay(handle2, format, variable list); //write data
into filenam2.suffix
�$fwrite(handle2, format, variable list); //write data
into filenam2.suffix

21
Reading from a file
�$readmemh("filename.suffix“, mem) ; // To read a file
consists of HEX values
�$readmemb("filename.suffix“, mem) ; // To read a file
consists of BIN values
* mem is an array data type

22
Interview Questions
�Difference between $display and $monitor?
�Difference between $random and $urandom?

23
k y o u
Than

24

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy