This library provides functions for data array manipulation.
Utilities
Functionality
- Repack data arrays to new data width, padding before or after
- Flip bits in data words or swap endianess
- Concatenate data array lengthwise or widthwise
- Search for token in data arrays
Other libraries in Utilities are:
More details in nw_util_pkg
Example use
Include the libraries:
library nw_util;
context nw_util.nw_util_context;
Bit-flip (reflect) and swap endianness of data arrays and std_logic_vectors:
array_8bit := (x"c1", x"67");
array_flipped := f_bitflip(array_8bit);
v_a := "1100001111";
v_a_flipped := f_bitflip(v_a);
array_32bit := (x"11223344", x"abcdef00);
array_swapped := f_swap_endian(array_32bit);
Concatenate data arrays:
array_8bit := (x"c1", x"67");
array2_8bit := (x"55", x"8f", x"42);
array_concat := f_concat(array_8bit, array2_8bit);
Repack data arrays to new data word width:
array_8bit := (x"11", x"22", x"33", x"44", x"55", x"66", x"77");
array_32bit := f_repack(array_8bit, 32, C_MSB_FIRST, C_PAD_BEFORE, x"ff");
array_32bit := f_repack(array_8bit, 32, C_LSB_FIRST, C_PAD_BEFORE, x"ff");
array_1bit := f_repack(array_8bit(0 to 0), 1, C_MSB_FIRST);
array_3bit := f_repack(array_1bit, 3, C_LSB_FIRST);
array_7bit := f_repack(f_repack(array_8bit, 1), 7);
Reverse data arrays:
array_8bit := (x"c1", x"67", x"42");
array_rev := f_reverse(array_8bit);
Stack data arrays to create wider data words:
array_8bit := (x"11", x"22", x"33", x"44", x"55", x"66", x"77");
array_4bit := (x"0", x"1", x"2", x"3");
array_12bit := f_stack(array_4bit, array_8bit);
See further examples in the test bench nw_util_tb.vhd.