/* ** HDL4SE: 软件Verilog综合仿真平台 ** Copyright (C) 2021-2021, raoxianhong ** LCOM: 轻量级组件对象模型 ** Copyright (C) 2021-2021, raoxianhong ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are met: ** ** * Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright notice, ** this list of conditions and the following disclaimer in the documentation ** and/or other materials provided with the distribution. ** * The name of the author may be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF ** THE POSSIBILITY OF SUCH DAMAGE. */ /* * bignumber.h 202105201110: rxh, initial version */ #ifndef __BIGNUMBER_H #define __BIGNUMBER_H #ifdef __cplusplus extern "C" { #endif #ifndef _ASMLANGUAGE #include "guid.h" DEFINE_GUID(IID_BIGNUMBER, 0x80dc5305, 0x1ca6, 0x4678, 0xbf, 0xc3, 0xd0, 0x1b, 0x9c, 0xd3, 0x63, 0x62); typedef struct sIBigNumber { OBJECT_INTERFACE int (*GetBitsCount)(HOBJECT object); int (*SetBitsCount)(HOBJECT object, int count); int (*GetInt)(HOBJECT object, int* pvalue); int (*GetInt64)(HOBJECT object, long long* pvalue); int (*GetStr)(HOBJECT object, int base, char * str, int buflen); int (*AssignStr)(HOBJECT object, const char * str, const char ** nstr); int (*AssignInt)(HOBJECT object, int value); int (*AssignInt64)(HOBJECT object, long long value); int (*Assign)(HOBJECT object, HOBJECT src); int (*AssignSub)(HOBJECT object, HOBJECT src, int from, int width); int (*Bind)(HOBJECT object, HOBJECT src); int (*Neg)(HOBJECT object); int (*AddInt)(HOBJECT object, int value); int (*Add)(HOBJECT object, HOBJECT src); int (*SubInt)(HOBJECT object, int value); int (*Sub)(HOBJECT object, HOBJECT src); int (*MulInt)(HOBJECT object, int value); int (*Mul)(HOBJECT object, HOBJECT src); int (*DivInt)(HOBJECT object, int value); int (*Div)(HOBJECT object, HOBJECT src); int (*SHL)(HOBJECT object, int bits); int (*SHR)(HOBJECT object, int bits); int (*Not)(HOBJECT object); int (*uAnd)(HOBJECT object); int (*uOr)(HOBJECT object); int (*uXor)(HOBJECT object); int (*And)(HOBJECT object, HOBJECT src); int (*Or)(HOBJECT object, HOBJECT src); int (*Xor)(HOBJECT object, HOBJECT src); int (*IsZero)(HOBJECT object); int (*IsNeg)(HOBJECT object); int (*IsEQ)(HOBJECT object, HOBJECT src); int (*IsLE)(HOBJECT object, HOBJECT src); int (*IsLT)(HOBJECT object, HOBJECT src); }IBigNumber; #define BIGNUMBER_VARDECLARE #define BIGNUMBER_VARINIT(_objptr, _sid) #define BIGNUMBER_FUNCDECLARE(_obj, _clsid, _localstruct) \ static int _obj##_bn_GetBitsCount(HOBJECT object); \ static int _obj##_bn_SetBitsCount(HOBJECT object, int count); \ static int _obj##_bn_GetInt(HOBJECT object, int* pvalue); \ static int _obj##_bn_GetInt64(HOBJECT object, long long* pvalue); \ static int _obj##_bn_GetStr(HOBJECT object, int base, char* str, int buflen); \ static int _obj##_bn_AssignStr(HOBJECT object, const char* str, const char ** nstr); \ static int _obj##_bn_AssignInt(HOBJECT object, int value); \ static int _obj##_bn_AssignInt64(HOBJECT object, long long value); \ static int _obj##_bn_Assign(HOBJECT object, HOBJECT src); \ static int _obj##_bn_AssignSub(HOBJECT object, HOBJECT src, int from, int width); \ static int _obj##_bn_Bind(HOBJECT object, HOBJECT src); \ static int _obj##_bn_Neg(HOBJECT object); \ static int _obj##_bn_AddInt(HOBJECT object, int value); \ static int _obj##_bn_Add(HOBJECT object, HOBJECT src); \ static int _obj##_bn_SubInt(HOBJECT object, int value); \ static int _obj##_bn_Sub(HOBJECT object, HOBJECT src); \ static int _obj##_bn_MulInt(HOBJECT object, int value); \ static int _obj##_bn_Mul(HOBJECT object, HOBJECT src); \ static int _obj##_bn_DivInt(HOBJECT object, int value); \ static int _obj##_bn_Div(HOBJECT object, HOBJECT src); \ static int _obj##_bn_SHL(HOBJECT object, int bits); \ static int _obj##_bn_SHR(HOBJECT object, int bits); \ static int _obj##_bn_Not(HOBJECT object); \ static int _obj##_bn_uAnd(HOBJECT object); \ static int _obj##_bn_uOr(HOBJECT object); \ static int _obj##_bn_uXor(HOBJECT object); \ static int _obj##_bn_And(HOBJECT object, HOBJECT src); \ static int _obj##_bn_Or(HOBJECT object, HOBJECT src); \ static int _obj##_bn_Xor(HOBJECT object, HOBJECT src); \ static int _obj##_bn_IsZero(HOBJECT object); \ static int _obj##_bn_IsNeg(HOBJECT object); \ static int _obj##_bn_IsEQ(HOBJECT object, HOBJECT src); \ static int _obj##_bn_IsLE(HOBJECT object, HOBJECT src); \ static int _obj##_bn_IsLT(HOBJECT object, HOBJECT src); \ static const IBigNumber _obj##_bn_interface = { \ INTERFACE_HEADER(_obj, IBigNumber, _localstruct) \ _obj##_bn_GetBitsCount, \ _obj##_bn_SetBitsCount, \ _obj##_bn_GetInt, \ _obj##_bn_GetInt64, \ _obj##_bn_GetStr, \ _obj##_bn_AssignStr, \ _obj##_bn_AssignInt, \ _obj##_bn_AssignInt64, \ _obj##_bn_Assign, \ _obj##_bn_AssignSub, \ _obj##_bn_Bind, \ _obj##_bn_Neg, \ _obj##_bn_AddInt, \ _obj##_bn_Add, \ _obj##_bn_SubInt, \ _obj##_bn_Sub, \ _obj##_bn_MulInt, \ _obj##_bn_Mul, \ _obj##_bn_DivInt, \ _obj##_bn_Div, \ _obj##_bn_SHL, \ _obj##_bn_SHR, \ _obj##_bn_Not, \ _obj##_bn_uAnd, \ _obj##_bn_uOr, \ _obj##_bn_uXor, \ _obj##_bn_And, \ _obj##_bn_Or, \ _obj##_bn_Xor, \ _obj##_bn_IsZero, \ _obj##_bn_IsNeg, \ _obj##_bn_IsEQ, \ _obj##_bn_IsLE, \ _obj##_bn_IsLT \ }; DEFINE_GUID(CLSID_BIGINTEGER, 0xabde0235, 0x8f00, 0x4f30, 0x92, 0xbf, 0x95, 0x2e, 0x35, 0x8b, 0x1a, 0xeb); DEFINE_GUID(PARAMID_BIGINTEGERWIDTH, 0xb3a21034, 0x27d5, 0x4e09, 0xba, 0xfd, 0x2, 0xeb, 0x0, 0xfc, 0x28, 0xfb); IBigNumber** bigintegerCreate(int width); #endif /* _ASMLANGUAGE */ #ifdef __cplusplus } #endif #endif /* __BIGNUMBER_H */