tuple

class tuple#(type T1 =  int,
type T2 =  int,
type T3 =  int,
type T4 =  int,
type T5 =  int,
type T6 =  int,
type T7 =  int,
type T8 =  int,
type T9 =  int,
type T10 =  int)

Provides a tuple that carries up to ten values, which can be different types.

Parameters

T1optional The type of the first value of a tuple.  The default is int.
T2optional The type of the second value of a tuple.  The default is int.
T3optional The type of the third value of a tuple.  The default is int.
T4optional The type of the fourth value of a tuple.  The default is int.
T5optional The type of the fifth value of a tuple.  The default is int.
T6optional The type of the sixth value of a tuple.  The default is int.
T7optional The type of the seventh value of a tuple.  The default is int.
T8optional The type of the eighth value of a tuple.  The default is int.
T9optional The type of the ninth value of a tuple.  The default is int.
T10optional The type of the tenth value of a tuple.  The default is int.
Summary
tupleProvides a tuple that carries up to ten values, which can be different types.
Types
this_typeThe shorthand of tuple#(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10)
Properties
firstThe first value inside the tuple.
secondThe second value inside the tuple.
thirdThe third value inside the tuple.
fourthThe fourth value inside the tuple.
fifthThe fifth value inside the tuple.
sixthThe sixth value inside the tuple.
seventhThe seventh value inside the tuple.
eighthThe eighth value inside the tuple.
ninthThe ninth value inside the tuple.
tenthThe tenth value inside the tuple.
Functions
newCreates a tuple of values of types T1, T2, and T3.
eqReturns 1 if this object is equal to the specified tuple.
neReturns 1 if this object is not equal to the specified tuple.
ltReturns 1 if this object is less than the specified tuple.
gtReturns 1 if this object is greater than the specified tuple.
leReturns 1 if this object is less than or equal to the specified tuple.
geReturns 1 if this object is greater than or equal to the specified tuple.
cloneCreates a tuple by cloning this object.
swapSwaps the contents of this tuple with the ones of the specified tuple.

Types

this_type

typedef tuple#(T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10) this_type

The shorthand of tuple#(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10)

Properties

first

T1 first

The first value inside the tuple.

Example

tuple#(int,string,bit[7:0]) t = new( 1, "apple", 8'hFF );
assert( t.first == 1 );

second

T2 second

The second value inside the tuple.

Example

tuple#(int,string,bit[7:0]) t = new( 1, "apple", 8'hFF );
assert( t.second == "apple" );

third

T3 third

The third value inside the tuple.

Example

tuple#(int,string,bit[7:0]) t = new( 1, "apple", 8'hFF );
assert( t.third == 8'hFF );

fourth

T4 fourth

The fourth value inside the tuple.

Example

tuple#() t = new( 1, 2, 3, 4 );
assert( t.fourth == 4 );

fifth

T5 fifth

The fifth value inside the tuple.

Example

tuple#() t = new( 1, 2, 3, 4, 5 );
assert( t.fifth == 5 );

sixth

T6 sixth

The sixth value inside the tuple.

Example

tuple#() t = new( 1, 2, 3, 4, 5, 6 );
assert( t.sixth == 6 );

seventh

T7 seventh

The seventh value inside the tuple.

Example

tuple#() t = new( 1, 2, 3, 4, 5, 6, 7 );
assert( t.seventh == 7 );

eighth

T8 eighth

The eighth value inside the tuple.

Example

tuple#() t = new( 1, 2, 3, 4, 5, 6, 7, 8 );
assert( t.eighth == 8 );

ninth

T9 ninth

The ninth value inside the tuple.

Example

tuple#() t = new( 1, 2, 3, 4, 5, 6, 7, 8, 9 );
assert( t.ninth == 9 );

tenth

T10 tenth

The tenth value inside the tuple.

Example

tuple#() t = new( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );
assert( t.tenth == 10 );

Functions

new

function new(T1 first,  
T2 second,  
T3 third,  
T4 fourth =  0,
T5 fifth =  0,
T6 sixth =  0,
T7 seventh =  0,
T8 eighth =  0,
T9 ninth =  0,
T10 tenth =  0,
comparator#(this_type) cmp =  null)

Creates a tuple of values of types T1, T2, and T3.  Optionally, a tuple can have up to ten values of different types.

Arguments

firstThe first value of a tuple.
secondThe second value of a tuple.
thirdThe third value of a tuple.
fourthoptional The fourth value of a tuple.
fifthoptional The fifth value of a tuple.
sixthoptional The sixth value of a tuple.
seventhoptional The seventh value of a tuple.
eighthoptional The eighth value of a tuple.
ninthoptional The ninth value of a tuple.
tenthoptional The tenth value of a tuple.
cmpoptional A strategy object used to compare two tuples.  If not specified or null, tuple_comparator #(this_type) is used.  The default is null.

Returns

None.

Example

tuple#(int, string, bit[7:0]) t = new( 1, "apple", 8'hFF );

eq

function bit eq(const ref this_type t)

Returns 1 if this object is equal to the specified tuple.  The comparison is done by the strategy object specified at the object construction.

Argument

tA tuple to compare with.

Returns

If this object is equal to t, then returns 1.  Otherwise, returns 0.

Example

tuple#(int, string, bit[7:0]) t = new( 1, "apple", 8'hFF );
tuple#(int, string, bit[7:0]) u = new( 1, "apple", 8'hFF );
assert( t.eq( u ) == 1 ); // 1 == 1 && "apple" == "apple" && 8'hFF == 8'hFF

ne

function bit ne(const ref this_type t)

Returns 1 if this object is not equal to the specified tuple.  The comparison is done by the strategy object specified at the object construction.

Argument

tA tuple to compare with.

Returns

If this object is not equal to t, then returns 1.  Otherwise, returns 0.

Example

tuple#(int, string, bit[7:0]) t = new( 1, "apple",  8'hFF );
tuple#(int, string, bit[7:0]) u = new( 1, "orange", 8'hFF );
assert( t.ne( u ) == 1 ); // "apple" != "orange"

lt

function bit lt(const ref this_type t)

Returns 1 if this object is less than the specified tuple.  The comparison is done by the strategy object specified at the object construction.

Argument

tA tuple to compare with.

Returns

If this object is less than t, then returns 1.  Otherwise, returns 0.

Example

tuple#(int, string, bit[7:0]) t = new( 1, "apple", 8'hFF );
tuple#(int, string, bit[7:0]) u = new( 2, "apple", 8'hFF );
assert( t.lt( u ) == 1 ); // 1 < 2

gt

function bit gt(const ref this_type t)

Returns 1 if this object is greater than the specified tuple.  The comparison is done by the strategy object specified at the object construction.

Argument

tA tuple to compare with.

Returns

If this object is greater than t, then returns 1.  Otherwise, returns 0.

Example

tuple#(int, string, bit[7:0]) t = new( 1, "orange", 8'hFF );
tuple#(int, string, bit[7:0]) u = new( 1, "apple",  8'hFF );
assert( t.gt( u ) == 1 ); // "orange" > "apple" by the lexicographical order

le

function bit le(const ref this_type t)

Returns 1 if this object is less than or equal to the specified tuple.  The comparison is done by the strategy object specified at the object construction.

Argument

tA tuple to compare with.

Returns

If this object is less than or equal to t, then returns 1.  Otherwise, returns 0.

Example

tuple#(int, string, bit[7:0]) t = new( 1, "apple",  8'hFF );
tuple#(int, string, bit[7:0]) u = new( 1, "orange", 8'hFF );
assert( t.le( u ) == 1 ); // "apple" < "orange" by the lexicographical order

ge

function bit ge(const ref this_type t)

Returns 1 if this object is greater than or equal to the specified tuple.  The comparison is done by the strategy object specified at the object construction.

Argument

tA tuple to compare with.

Returns

If this object is greater than or equal to t, then returns 1.  Otherwise, returns 0.

Example

tuple#(int, string, bit[7:0]) t = new( 2, "apple",  8'hFF );
tuple#(int, string, bit[7:0]) u = new( 1, "orange", 8'hFF );
assert( t.ge( u ) == 1 ); // 2 > 1

clone

function this_type clone()

Creates a tuple by cloning this object.

Returns

A cloned tuple.

Example

tuple#(int, string, bit[7:0]) t = new( 1, "apple",  8'hFF );
tuple#(int, string, bit[7:0]) u = t.clone();
assert( t.eq( u ) == 1 );

swap

function void swap(ref this_type t)

Swaps the contents of this tuple with the ones of the specified tuple.

Argument

tA tuple to swap the contents.

Example

tuple#(int, string, bit[7:0]) t = new( 1, "apple",  8'hFF );
tuple#(int, string, bit[7:0]) u = new( 2, "orange", 8'hAA );
t.swap( u );
assert( t.first == 2 );
assert( u.first == 1 );
assert( t.second == "orange" );
assert( u.second == "apple" );
assert( t.third == 8'hAA );
assert( u.third == 8'hFF );
class tuple#(type T1 =  int,
type T2 =  int,
type T3 =  int,
type T4 =  int,
type T5 =  int,
type T6 =  int,
type T7 =  int,
type T8 =  int,
type T9 =  int,
type T10 =  int)
Provides a tuple that carries up to ten values, which can be different types.
typedef tuple#(T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10) this_type
The shorthand of tuple#(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10)
T1 first
The first value inside the tuple.
T2 second
The second value inside the tuple.
T3 third
The third value inside the tuple.
T4 fourth
The fourth value inside the tuple.
T5 fifth
The fifth value inside the tuple.
T6 sixth
The sixth value inside the tuple.
T7 seventh
The seventh value inside the tuple.
T8 eighth
The eighth value inside the tuple.
T9 ninth
The ninth value inside the tuple.
T10 tenth
The tenth value inside the tuple.
function new(T1 first,  
T2 second,  
T3 third,  
T4 fourth =  0,
T5 fifth =  0,
T6 sixth =  0,
T7 seventh =  0,
T8 eighth =  0,
T9 ninth =  0,
T10 tenth =  0,
comparator#(this_type) cmp =  null)
Creates a tuple of values of types T1, T2, and T3.
function bit eq(const ref this_type t)
Returns 1 if this object is equal to the specified tuple.
function bit ne(const ref this_type t)
Returns 1 if this object is not equal to the specified tuple.
function bit lt(const ref this_type t)
Returns 1 if this object is less than the specified tuple.
function bit gt(const ref this_type t)
Returns 1 if this object is greater than the specified tuple.
function bit le(const ref this_type t)
Returns 1 if this object is less than or equal to the specified tuple.
function bit ge(const ref this_type t)
Returns 1 if this object is greater than or equal to the specified tuple.
function this_type clone()
Creates a tuple by cloning this object.
function void swap(ref this_type t)
Swaps the contents of this tuple with the ones of the specified tuple.
class tuple_comparator#(type T =  tuple) extends comparator#(T)
singleton Provides strategies to compare tuples.