SystemVerilog for Verification

Slides:



Advertisements
Similar presentations
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
Advertisements

Pointers & Dynamic Memory Allocation Mugurel Ionu Andreica Spring 2012.
Main Index Contents 11 Main Index Contents Container Types Container Types Sequence Containers Sequence Containers Associative Containers Associative Containers.
Pointers1 Pointers & Dynamic Arrays Allocating memory at run-time.
Main Index Contents 11 Main Index Contents Container Types Container Types Sequence Containers Sequence Containers Associative Containers Associative Containers.
Lecture 11 Standard Template Library Stacks, Queue, and Deque Lists Iterators Sets Maps.
Review C++ exception handling mechanism Try-throw-catch block How does it work What is exception specification? What if a exception is not caught?
Data Structures Using C++ 2E
C Tokens Identifiers Keywords Constants Operators Special symbols.
Lecture DS & Algorithms:09 Abstract Data Types. Lecture DS & Algorithms:09 2 Abstract Data Types Data Type: A data type is a collection of values and.
Generic Positional Containers and Double-Ended Queues.
Main Index Contents 11 Main Index Contents Week 3 – The Vector Container.
C++ STL CSCI 3110.
Lists, Stacks and Queues in C Yang Zhengwei CSCI2100B Data Structures Tutorial 4.
Array, Structure and Union
Review of Stacks and Queues Dr. Yingwu Zhu. How does a Stack Work? Last-in-First-out (LIFO) data structure Adding an item Push operation Removing an item.
Introduction to the Standard Template Library (STL) A container class holds a number of similar objects. Examples: –Vector –List –Stack –Queue –Set –Map.
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
Lecture 11 Standard Template Library Lists Iterators Sets Maps.
Lecture 7 : Intro. to STL (Standard Template Library)
Data Structures Using C++1 Chapter 3 Pointers and Array-Based Lists.
The List ADT Reading: Sections 3.2, 3.3, 3.5.
CNG 140 C Programming (Lecture set 12) Spring Chapter 13 Dynamic Data Structures.
1 Chapter 15-1 Pointers, Dynamic Data, and Reference Types Dale/Weems.
Collection types CS Chakrabarti Motivation  Thus far the only collection types we have used are vector and matrix  Problem #1: given an input.
List Structures What is a list? A homogeneous collection of elements with a linear relationship between the elements linear relationship - each element.
Java Programming Language Lecture27- An Introduction.
Linked Lists Source: presentation based on notes written by R.Kay, A. Hill and C.Noble ● Lists in general ● Lists indexed using pointer arrays ● Singly.
STACKS & QUEUES for CLASS XII ( C++).
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
Chapter 6 Arrays in C++ 2nd Semester King Saud University
Data types Data types Basic types
An Introduction to Programming with C++ Sixth Edition
Arrays An array is a grouping of elements of the same type that share a common base name Can have any number of elements in the array Individual elements.
SystemVerilog for Verification
Two Dimensional Array Mr. Jacobs.
UNIT-3 LINKED LIST.
Data Structures and Algorithms
ENERGY 211 / CME 211 Lecture 12 October 17, 2008.
ENEE150 Discussion 13 Section 0101 Adam Wang.
Module 2 Arrays and strings – example programs.
Stack Lesson xx   This module shows you the basic elements of a type of linked list called a stack.
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Pointers and References
Arrays, For loop While loop Do while loop
Object Oriented Programming COP3330 / CGS5409
Generic Positional Containers and Double-Ended Queues
Chapter 18: Linked Lists.
Popping Items Off a Stack Lesson xx
Pointers, Dynamic Data, and Reference Types
Arrays under SystemVerilog
Arrays under SystemVerilog
Data Structures and Algorithms
Chapter 1: Introduction to Data Structures(8M)
SystemVerilog for Verification
Chapter 17: Linked Lists.
The Standard Template Library
Lecture 8 : Intro. to STL (Standard Template Library)
Introduction to Data Structure
Arrays An array is a grouping of elements of the same type that share a common base name Can have any number of elements in the array Individual elements.
Chapter 9: Pointers and String
Dynamic allocation (continued)
C Language B. DHIVYA 17PCA140 II MCA.
Pointers and References
Pointers, Dynamic Data, and Reference Types
8.3 Vectors Copyright © 2008 Pearson Addison-Wesley. All rights reserved. 1.
Python fundamental.
Extra C Material Based on material in: The C Programming Language, Second Edition by Brian W. Kernighan and Dennis M. Ritchie. Prentice Hall, Inc., 1988. 
Presentation transcript:

SystemVerilog for Verification Basic data types – Part III

Agenda Structure Union Arrays Dynamic Array Associative Array Queue

Structure (Collection of Data Types) Structure Declaration : struct { logic [3:0] addr; int data; } IR; IR.addr = 4’b0010; User-defined structure : typedef struct { } instruction; instruction IR; Packed structure : struct packed { IR = 36’hA013BCD34; Signed Packed structure : struct packed signed { bit [3:0] addr; } IR; //signed 2-state Unsigned Packed structure : struct packed unsigned { } IR; //signed 4-state structure literal : int a; shortreal b; } ab; ab c; c = ‘{0,0.0}

Structure Exercise Address Name Access (R –Read, W-Write, Declare a user-defined packed structure for below register table. Make a code that reads and writes the value through register with sensitivity of register address change. Provide various register addresses from testbench at different time. Improper access should shout error. Address Name Access (R –Read, W-Write, RO – Read Only, WO – Write Only) 0xEEF1_0000 REG0 R/W 0xEEF1_0004 REG1 0xEEF1_0008 REG2 RO 0xEEF1_000C REG3 0xEEF1_0010 REG4 WO

Union A single piece of storage that can be accessed using one of the named member data types. User-defined Unpacked (Default) union : typedef union { int a; shortreal b; } uni; uni u; u.b = 0.0; User-defined Packed Union : All Datatype of integral type having same size typedef packed union { bit [31:0] mem1; bit [3:0] [7:0] mem2; } packuni; packuni p; Memory Allocation : Tagged Union : Original Union Loophole – updated using value of one member datatype, read using another. Tagged Union – value can be read only by one having tagged of lastly updated. typedef union tagged packed{int a1, int a2 } u; u u1; u1 = tagged a1 5; int b = u1.a1; 8 8

Arrays Packed Arrays : Treated as single vector byte, shortint, int, longint, integer, time byte c2; integer a1; bit signed [7:0] c2;//size before variable logic signed [31:0] a1; Unpacked Array : size after variable name logic b1 [7:0] int a1 [7:0] // 2D array - packed int; unpacked byte Memory : logic [7:0] mem [0:255] mem[5] = 0; data = mem[addr] Array Literals: int a [3:0];  a = ‘{4{3}} = ‘{3,3,3,3} int b [0:1] [0:2]  b = ‘{‘{1,2,3},’{3{4}}} 1 2 3 4

Dynamic Array Unpacked array, whose size can be set/change at runtime. declared by [] Ex. - int a []; Method Description new[]() Set/Change size of array, default value of array members = 0 set  int a [] = new [4]; //a size 4  int a [] = new [4] (b); //copy b to a change  int a [] = new [8] (a); //copy old a to new a, increase size to 8 size() Returns current size of dynamic array  int j = addr.size();  addr = new[ addr.size() * 4 ] (addr); // quadruple addr array delete() Empties an array int ab = new [4]; ab.delete(); // ab having size = 0

Dynamic Array Exercise Using dynamic array, allocate the array size of 15 location, assign random values to all. Now double the array size by keeping content of initial 15 locations same as previous. Use foreach loop to print content of each. Note: search for $random in SV LRM.

Associative Array Dynamic array - good with contiguous data collection, whose size changes dynamically But when size of collection is unknown / Data space is sparse –Use Associative Array Index can be of any data type, say string. data_type array_name [index_type] Ex. int abc [string]; integer def [*]; //unspecified index, can be anything Associative arrays do not have any storage allocated until it is used.

Associative Array Method Description num(), size() Returns number of entries in associative array delete() Removes entry at specific index exists() Checks whether element exists at specific index first() Returns the value of first index last() Returns the value of last index next() Returns the smallest index whose value is greater than given index prev() Returns the largest index whose value is lesser than given index

Associative Array Exercise Add 70 integer values at random locations(between 1 to 150) of an integer associative array. Check whether value at index 10 and 56 exists. Print the value at first index along with index. Print the value at last index along with index. Check the array size. Delete 15th, 30th and 65th index if they exists. Print array size again.

Queue variable-size, ordered collection of homogeneous elements. byte q1 [$] ; // queue of bytes, $ represents last. string q2 [$] = {“hello”} ; // queue of strings initialized to “hello” int q3 [$] = {3,2,7} ; // initialized queue of integers

Queue Method Description size() Returns number of items in queue insert() Inserts given item at specific index delete() Deletes item at specific index pop_front() Removes and returns the first element of queue pop_back() Removes and returns the last element of queue push_front() Inserts element at front of queue push_back() Inserts element at last of queue

Queue Exercise Make a FIFO (First In First Out) of 128x32 using queue & its methods Hint: methods – push_front, pop_back Make a LIFO (Last In First Out) of 256x64 using queue & its methods Hint: methods – push_front, push_back

Thank You