Professional Documents
Culture Documents
3.Sv Language Basic
3.Sv Language Basic
Lecturer: hungpt@uit.edu.vn 1
DATA TYPE
Integer
Lecturer: hungpt@uit.edu.vn 2
DATA TYPE
Integer: example 2 state
Lecturer: hungpt@uit.edu.vn 3
DATA TYPE
Integer: example 4 state
Lecturer: hungpt@uit.edu.vn 4
DATA TYPE
String
Lecturer: hungpt@uit.edu.vn 5
DATA TYPE
Enum
Lecturer: hungpt@uit.edu.vn 6
DATA TYPE
Fixed arrays(1)
Lecturer: hungpt@uit.edu.vn 7
DATA TYPE
Fixed arrays(2)
◼ $dimensions (array_name):
returns the number of
dimensions in the array
◼ $size (array_name,
dimension): returns the total
number of elements in the
specified dimension ($high -
$low +1)
Lecturer: hungpt@uit.edu.vn 8
DATA TYPE
Dynamic array
Lecturer: hungpt@uit.edu.vn 9
DATA TYPE
Queues(1)
Lecturer: hungpt@uit.edu.vn 10
DATA TYPE
Queues(2)
Lecturer: hungpt@uit.edu.vn 11
DATA TYPE
Associative array(1)
Lecturer: hungpt@uit.edu.vn 12
DATA TYPE
Associative array(2)
◼ Array can be traversed with:
◼ Syntax:
function int first (ref index)
function int last (ref index)
function int next (ref index)
function int prev (ref index)
Lecturer: hungpt@uit.edu.vn 14
DATA TYPE
Summary array
Lecturer: hungpt@uit.edu.vn 15
PROCEDURAL PROGRAMMING STATEMENT
Overview
◼ Procedural programming statements shall be contained within
any of the following constructs
Always
Initial
Subroutine (task, function)
Lecturer: hungpt@uit.edu.vn 18
PROCEDURAL PROGRAMMING STATEMENT
Loop statements
Lecturer: hungpt@uit.edu.vn 19
PROCEDURAL PROGRAMMING STATEMENT
Jump statements
Lecturer: hungpt@uit.edu.vn 20
PROCEDURAL PROGRAMMING STATEMENT
Parallel block: overview
Lecturer: hungpt@uit.edu.vn 21
PROCEDURAL PROGRAMMING STATEMENT
Parallel block: creating
◼ The parallel block are created in a fork-join block
Lecturer: hungpt@uit.edu.vn 23
PROCEDURAL PROGRAMMING STATEMENT
Parallel block: wait fork
◼ To prevent improper early termination of simulation, one can use wait
fork
begin
fork
task1();
task2();
join_any
fork
task3();
task4();
join_none
wait fork
end
◼ The wait fork statement is used to ensure that all child processes have
completed execution
Lecturer: hungpt@uit.edu.vn 24
PROCEDURAL PROGRAMMING STATEMENT
Parallel block: disable fork
task watch_dog_timer;
fork
run_test();
time_out(1000);
join_any
endtask
Lecturer: hungpt@uit.edu.vn 25
SUBROUTINES
overview
◼ Task and function are called subroutines
◼ A function can not enable a task; a task can enable other tasks and
functions
Lecturer: hungpt@uit.edu.vn 27
SUBROUTINES
examples
Lecturer: hungpt@uit.edu.vn 28
SUBROUTINES
Pass argument
Lecturer: hungpt@uit.edu.vn 29
SUBROUTINES
Summary
Lecturer: hungpt@uit.edu.vn 30
LAB INTRODUCTION
Lecturer: hungpt@uit.edu.vn 31