function [emsg] = hdlblkmask_errfcn(bh, errmsg)
% Error callback function (ErrFcn) for hdldemolib blocks

% Copyright 2007-2012 The MathWorks, Inc.
%   

% For now the only check is for the dual-port RAM
% But this function can be shared if more blocks are added to hdldemolib in
% the future

% If we are not producing any error return the last error
lerr = sllasterror;
emsg = lerr.Message;

minsize = 2;
maxsize = 32;
% Checks address port width
try
    addrsz = hdlslResolve('ram_size', bh);
    if (addrsz < minsize || addrsz > maxsize)
        emsg = error(message('hdlsllib:hdlsllib:addrportwidth',...
        sprintf('%d', minsize), sprintf('%d', maxsize)));
        return;
    end
end
