virtual class bit_stream #( type T = bit ) extends data_stream #( T, 1 )
A parameterized class that manages a bit stream.
| T | optional The type of the bit stream. The T must be the single bit data types (bit, logic, or reg). The default type is bit. |
| bit_stream | A parameterized class that manages a bit stream. |
| Types | |
| bs_type | The bit stream type. |
| Functions | |
| alternate | static Returns a new bit stream with the elements whose values alternate between 0 and 1. |
| count_zeros | static Counts the number of bit-stream items having value 0. |
| count_ones | static Counts the number of bit-stream items having value 1. |
| count_unknowns | static Counts the number of bit-stream items having value X. |
| count_hizs | static Counts the number of bit-stream items having value Z. |
static function bs_type alternate( int unsigned length, T init_value = 0, bit randomize_init_value = 0 )
static Returns a new bit stream with the elements whose values alternate between 0 and 1.
| length | The length of the output bit stream. |
| init_value | optional The value of the first element (0 or 1). The default is 0. |
| randomize_init_value | optional If 1, the value of the first element is randomized (the init_value argument is ignored). The default is 0. |
A new bit stream with the elements whose values alternate between 0 and 1.
bit expected[] = new[8]( '{ 1, 0, 1, 0, 1, 0, 1, 0 } );
assert( bit_stream#(bit)::alternate( 8, .init_value( 1 ) ) == expected );
static function int count_zeros( bs_type bs )
static Counts the number of bit-stream items having value 0.
| bs | A bit stream. |
The number of items having value 0. If the type T is not a single-bit data type, -1 is returned.
bit bs[] = new[16]( '{ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1 } );
assert( bit_stream#(bit)::count_zeros( bs ) == 8 );
static function int count_ones( bs_type bs )
static Counts the number of bit-stream items having value 1.
| bs | A bit stream. |
The number of items having value 1. If the type T is not a single-bit data type, -1 is returned.
bit bs[] = new[16]( '{ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1 } );
assert( bit_stream#(bit)::count_ones( bs ) == 8 );
static function int count_unknowns( bs_type bs )
static Counts the number of bit-stream items having value X.
| bs | A bit stream. |
The number of items having value X. If the type T is not a single-bit data type, -1 is returned.
logic bs[] = new[16]( '{ 0, 0, 0, 0, 1, 1, 1, 1, 'x, 'x, 'x, 'x, 'z, 'z, 'z, 'z } );
assert( bit_stream#(logic)::count_unknowns( bs ) == 4 );
static function int count_hizs( bs_type bs )
static Counts the number of bit-stream items having value Z.
| bs | A bit stream. |
The number of items having value Z. If the type T is not a single-bit data type, -1 is returned.
logic bs[] = new[16]( '{ 0, 0, 0, 0, 1, 1, 1, 1, 'x, 'x, 'x, 'x, 'z, 'z, 'z, 'z } );
assert( bit_stream#(logic)::count_hizs( bs ) == 4 );A parameterized class that manages a bit stream.
virtual class bit_stream #( type T = bit ) extends data_stream #( T, 1 )
The bit stream type.
typedef T bs_type[]
static Returns a new bit stream with the elements whose values alternate between 0 and 1.
static function bs_type alternate( int unsigned length, T init_value = 0, bit randomize_init_value = 0 )
static Counts the number of bit-stream items having value 0.
static function int count_zeros( bs_type bs )
static Counts the number of bit-stream items having value 1.
static function int count_ones( bs_type bs )
static Counts the number of bit-stream items having value X.
static function int count_unknowns( bs_type bs )
static Counts the number of bit-stream items having value Z.
static function int count_hizs( bs_type bs )