1 / 26

The data types in Systemverilog

Speaker: Hsiu-Yi Lin Date: 5/4 2010. The data types in Systemverilog. Outline. Built-In Data Types The Logic type 2-State Data Types Arrays Declaring fixed-size arrays Unpacked array Packed array Dynamic array Queues Associative array Choosing a Storage Type. Built-In Data Types.

duncan
Download Presentation

The data types in Systemverilog

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Speaker: Hsiu-Yi Lin Date: 5/4 2010 The data types in Systemverilog

  2. Outline • Built-In Data Types • The Logic type • 2-State Data Types • Arrays • Declaring fixed-size arrays • Unpacked array • Packed array • Dynamic array • Queues • Associative array • Choosing a Storage Type

  3. Built-In Data Types • The Logic type • 2-State Data Types

  4. The Logic type • Verilog always leaves new users confusing because they can’t know the difference of “reg” and “wire”. • SystemVerilog improves the classic reg data type so that it can be driven by continuous assignments, gates, and modules. • A logic signal can be used anywhere a net is uesd.

  5. Example

  6. 2-State Data Types • SystemVerilog introduces several 2-state types to improve simulator performance and reduce memory usage. • Original version in Verilog is 4-state types (0,1,Z,X) . • The common 2-state types in SystemVerilog are bit, int and byte…etc.

  7. Example

  8. Arrays • Declaring fixed-size arrays • Unpacked array • Packed array • Dynamic arrays

  9. Declaring fixed-size arrays • Verilog requires that the low and high array limits must be given in the declaration. • SystemVeriolog lets you use the shortcut of just giving the array size, which is similar to C’s style.

  10. Example

  11. Unpacked array • If the array bounds are declared after the variable name, it is called an unpacked array

  12. Packed Array •  If the array upper and lower bounds are declared between the variable type and the variable name, the array is called packed. • A SystemVerilog packed array is treated as both an array and a single value.

  13. Dynamic Arrays • If we do not know the size of the array until run-time, we can use dynamic arrays. • SystemVerilog provides a dynamic array that can be allocated and resized during simulation and so our simulation consumes a minimal amount of memory.

  14. Queues • SystemVerilog introduces a new data type, the queue, which combines the best of an linked list and array. • Like an array, we can directly access any element with an index, without linked list’s overhead of stepping through the preceding elements. • The elements of a queue are numbered from 0 to $.

  15. Associative Arrays • If we want to create a big array and processor may only touch a few memory locations, we can use associative arrays. • SystemVerilog offers associative arrays that store entries in a sparse matrix, and allocates memory for an element when we write to it.

  16. Choosing a Storage Type • Flexibility • Memory Usage • Speed • Sorting

  17. Flexibility • Choose a fixed-size array if the array size is known at compile time. • Choose a dynamic array if the array size is known at run-time. • Choose associative arrays for nonstandard indices such as widely separated values because of random values or addresses. • Queues are a good way to store values when the number of elements grows and shrinks a lot during simulation.

  18. Memory Usage • Use 2-state elements to reduce the simulation memory usage. • For arrays with a thousand to a million active elements, fixed-size and dynamic arrays are the most memory efficient. • Modeling memories larger than a few megabytes should be done with an associative array.

  19. Speed • Choose our array type based on how many times it is accessed per clock cycle. • Fixed-size and dynamic arrays are stored in contiguous memory, and so any element can be found in the same amount of time. • Queues own a similar performance to fixed-size and dynamic arrays when reading and writing data, but it will be slow when inserting new elements into a large queue. • Associative arrays are slowest because they require more computation when search for the element in memory.

  20. Choosing the best data structure • Nework packets • Fixed-size, acceseed sequentially. • Use a fixed-size or dynamic array. • Scoreboard of expected values • Size is not known until run-time. • Use a queue. • Use associative arrays when we often insert and delete the elements in large space.

  21. Choosing the best data structure (cont.) • Modeling very large memories • If we don’t need every location, use an associative array. • If we need use every location, try a different approach where we do not need so much live data. • Be sure to use 2-state values.

More Related