Network Wizard for VHDL Test Benches
COBS

Consistent Overhead Byte Stuffing

This library provides functions for the COBS algorithm.

Functionality

  • Perform COBS encoding and decoding of 8bit arrays.

The COBS algorithm replaces all zeros in the data to be encoded. Worst case overhead for large packets is 0.4%.


More details in nw_cobs_pkg

Example use

Include the libraries:

library nw_codec;
context nw_codec.nw_codec_context;

The encoding process will replace all zeros in the data to be encoded.

v_data := (x"00", x"00", x"00", x"01", x"80", x"57", x"68", x"00", x"00", x"00"); -- data array to be encoded
v_len := f_cobs_enc_len(v_data); -- get length of encoded data (v_len is now 11)
v_encoded(0 to v_len - 1) := f_cobs_enc(v_data); -- v_encoded is now (x"01", x"01", x"01", x"05", x"01", x"80", x"57", x"68", x"01", x"01", x"01")

Decode the encoded data:

v_dlen := f_cobs_dec_len(v_encoded(0 to v_len - 1)); -- get length od decoded data (v_dlen is now 10)
v_decoded(0 to v_dlen - 1) := f_cobs_dec(v_encoded(0 to v_len - 1)); -- v_decoded is now equal to v_data

See further examples in the test bench nw_codec_tb.vhd.