 Hello and welcome to the series of video lectures on the subject digital techniques for secondary IT students. I am Dr. Srisail Sharad Kashbhar and in this video lecture we are going to study system task functions and compiler directives that are used in virilog programming. At the end of this session, you will be able to describe system task functions used in virilog programming. You will also be able to describe compiler directives that are used in virilog programming. Now let us see what are system task and functions. System task and functions are predefined task and functions which provide common operations to generate input and output during simulation. The purpose of a function is to respond to an input value by returning a single value, whereas a task can support multiple goals and can calculate multiple result values. Identifiers which start with dollar symbol are considered to be system task or functions in virilog. Virilog provides standard system task for certain routine operations. Operations such as displaying on the screen, monitoring values of needs, stopping and finishing etc are done by system task. A system task can be defined as a task whose definition is built in. Now as mentioned earlier, they begin with dollar symbol. These are used to provide output capabilities and information facilities to the virilog model. Like user defined task, system task must be invoked as a procedural statement. The most commonly used system tasks are four and they are namely display task, monitor task, stop task and finish task. Here display task is denoted as dollar display and it is used to print output on the standard output device. A monitor task written in code as dollar monitor is used to trace all value changes of the specified arguments. A stop task temporarily suspends simulation to provide the user interface to the simulation, whereas finish task terminates the simulation. The usage of display task in virilog code is shown. Here p1, p2, p3, pn can be coded strings or variables or expressions. The format of display task is very similar to printf function in C. A display task inserts a new line at the end of the stream by default. A display task without any arguments produces a new line. A format similar to the display task is used in the monitor task. Monitor task continuously monitors the values of the variables or signals specified in the parameters list. And displays all parameters in the list whenever the value of any one variable or signal changes. Unlike dollar display, that is display task, monitor task needs to be invoked only once. Now something regarding monitoring statement. Only one monitoring list can be active at a time. If there are more than one monitor statement in your simulation, the last monitor statement will be the active statement. The earlier monitor statements will be overwritten. Usage for stop and finish task is also shown here. The stop task puts the simulation in an interactive mode. The designer can then debug the design from the interactive mode. The stop task is used whenever the designer wants to suspend the simulation and examine the values of signals in the design. The finish task denoted as dollar finish terminates the simulation. Strings can be formatted using the specifications listed in the shown table. For example, %d can be used for displaying a variable in decimal. One can use these string format specifications as per the need during the simulation. For example, %b can be used to display a binary number. %e displays the number in a scientific format. One can use these string format specifications as per the need during the simulation. System functions are just like system tasks except that they are used as an operand in an expression. The most commonly used system functions are time function which returns the current simulation time in 64-bit binary format. A function s time returns the current simulation time as a 32-bit number whereas a random function returns a 32-bit random number. Now this time function, this s time or random function, they can all be passed as an operand in an expression. One such example will be displayed in the example section. Let us see some of the examples of system tasks and functions. The first example is dollar display in bracket in double quotation hello variable of world semicolon. It will display the string in quotes which is provided as an argument to the display task. Here the output is a string message hello variable of world. In the second example, the argument passed to the display task is a system function namely time. Here time function returns the current simulation time which is displayed by the display task. Now assuming the current simulation time as 230, the output shown is 230. In the third example, assuming 4-bit bus values as 10xx where x stands for unknown value, it is shown by the display task since percent b format specifier is used here for displaying the value of 4-bit variable bus which is of type register. Here example of monitor task is given. With monitors time and the value of signals clock and reset, typical sample output is also given for understanding the purpose of monitor task. By observing the partial output of the monitor statement, one can see that clock toggles every five time units and reset goes down at 10 time units. Example showing use of stop and finish task is given here. The execution of stop task puts the simulation in an interactive mode. The designer can then debug the design from the interactive mode. The stop task is used whenever the designer wants to suspend the simulation and examine the values of signals in the design. The finish task terminates the simulation. In the given example, simulation will be suspended at time equal to 100 and will be terminated at time equal to 1000. Now pause the video for two minutes and write down the answer of the given question. I hope you have written the answer. The output in this case will be as follows. String this is a will be shown as a first line while multi-line string is displayed on the new line. Compiler directives are provided in very long. All compiler directives are defined by using the back tick keyword construct. In this lecture, we will deal with the two most useful compiler directives namely back tick define which is similar to hash define in C. Back tick include which is similar to hash include in C. Back tick define is used to define text macros or constants. The examples are given. First example defines a text macro that defines default word size of 32 bits referred in the code using the name word underscore size. Second example defines an alias. Here a stop task will be substituted wherever character capital S appears. The second most important compiler directive is back tick include. Back tick include is used to include entire contents of a very long source file in another file during compilation. This is similar to hash include in C programming language and is typically used to include header files which typically contain global or commonly used definitions. For example, suppose we want to include contents of header dot v file into file 1 dot v then it can be written as back tick include header dot v followed by very long code describing file 1 dot v. Here dot v file stands for a very long file. These are the references. Thank you.