1/*  File:    canny/octet.pl
    2    Author:  Roy Ratcliffe
    3    Created: Aug 13 2022
    4    Purpose: Canny Octet
    5
    6Copyright (c) 2022, Roy Ratcliffe, Northumberland, United Kingdom
    7
    8Permission is hereby granted, free of charge,  to any person obtaining a
    9copy  of  this  software  and    associated   documentation  files  (the
   10"Software"), to deal in  the   Software  without  restriction, including
   11without limitation the rights to  use,   copy,  modify,  merge, publish,
   12distribute, sublicense, and/or sell  copies  of   the  Software,  and to
   13permit persons to whom the Software is   furnished  to do so, subject to
   14the following conditions:
   15
   16    The above copyright notice and this permission notice shall be
   17    included in all copies or substantial portions of the Software.
   18
   19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT  WARRANTY OF ANY KIND, EXPRESS
   20OR  IMPLIED,  INCLUDING  BUT  NOT   LIMITED    TO   THE   WARRANTIES  OF
   21MERCHANTABILITY, FITNESS FOR A PARTICULAR   PURPOSE AND NONINFRINGEMENT.
   22IN NO EVENT SHALL THE AUTHORS  OR   COPYRIGHT  HOLDERS BE LIABLE FOR ANY
   23CLAIM, DAMAGES OR OTHER LIABILITY,  WHETHER   IN  AN ACTION OF CONTRACT,
   24TORT OR OTHERWISE, ARISING FROM,  OUT  OF   OR  IN  CONNECTION  WITH THE
   25SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   26
   27*/
   28
   29:- module(canny_octet,
   30          [ octet_bits/2                % ?Octet:integer,?Fields:list
   31          ]).   32:- use_module(bits).
 octet_bits(?Octet:integer, ?Fields:list) is semidet
Unifies integral eight-bit Octet with a list of Value:Width terms where the Width integers sum to eight and the Value terms unify with the shifted bit values encoded within the eight-bit byte.
Arguments:
Octet- an eight-bit byte by another name.
Fields- colon-separated value-width terms. The shifted value of the bits comes first before the colon followed by its integer bit width. The list of terms specify an octet by sub-spans of bits, or bit fields.
   47octet_bits(Octet, Fields) :-
   48    var(Octet),
   49    !,
   50    bit_fields(Fields, 8, 0, Octet).
   51octet_bits(Octet, Fields) :-
   52    bit_fields(Fields, 8, Octet)