%% Usage of Logical Operator, Bitwise Operator, and Bit Reduce Blocks

% Copyright 2018 The MathWorks, Inc.

%% Guideline ID
% |2.2.2|

%% Severity
% _Informative_

%% Description
% To learn how you can use logical and bitwise operations, open
% the model |hdlcoder_logical_bitwise_operations.slx|.
load_system('hdlcoder_logical_bitwise_operations')
sim('hdlcoder_logical_bitwise_operations')
open_system('hdlcoder_logical_bitwise_operations')
%%
% For single-bit operations that use |Boolean| or |ufix1| data types, use
% a Logical Operator block. To view the operation as a logical circuit symbol,
% in the Block Parameters dialog box of the block, specify the *Icon shape* 
% as |Distinctive|. You can also input vectors that have |Boolean| or 
% |ufix1| data types to the block. 
%
% *Note: |Boolean| and |ufix1| are different data types. Mixing these data
% types within the same model or using them interchangeably is not
% recommended. For more information, see 
% <matlab:helpview(fullfile(docroot,'hdlcoder/ug/simulink-data-type-considerations.html'))
% Simulink Data Type Considerations>.*
%
% For an example of using the block, open the |Logical Operations| Subsystem.
open_system('hdlcoder_logical_bitwise_operations/Logical Operations')
%%
% For bitwise operations on two or more bits that use integer or
% fixed-point data types, use the Bitwise Operator block. For an example, double-click
% the |Bitwise Operations| Subsystem.
open_system('hdlcoder_logical_bitwise_operations/Bitwise Operations')
%%
% To perform a bit-by-bit reduction operation on a vector that uses |Boolean| 
% or |ufix1| and return a 1-bit value, use the Bit Reduce block. For an
% example, double-click the |Reduction Operations| Subsystem.
open_system('hdlcoder_logical_bitwise_operations/Reduction Operations')
%%
% The MATLAB Function block inside the Subsystem converts the 8-bit vector
% to a vector of |8| 1-bit |ufix1| elements.
open_system('hdlcoder_logical_bitwise_operations/Reduction Operations/convert bin2vec')