draft

nazarijtipusak080/shift-4-bytes/draft

No description
draft
@/draft
BITboolean
INCpulse
Triggers a single increment.
RSTpulse
Resets the accumulated value to zero.
nnumber
Value 0-7
inxnumber
Value 0-3
draft
BIT
INC
RST
n
inx
first
inxByte
nBit
transfer
UPD
NUMB
NUMBxod/core/micros
UPDpulse
Pulses when resulting Byte is updated
transferboolean
nBitboolean
inxBytebyte
firstboolean
To use the node in your project you should have the nazarijtipusak080/shift-4-bytes library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

node {
    // Internal state variables defined at this level persists across evaluations

    void evaluate(Context ctx) {

           uint32_t  count = getValue<output_NUMB>(ctx);
                 uint8_t inx = getValue<input_inx>(ctx);
         uint8_t in0 = getValue<input_n>(ctx);
         uint8_t in1 = (ctx, pow( 2, in0));
        uint8_t in3 = 128;
        uint32_t val = count;
         uint8_t byt3= (val >> 24);
        uint8_t byt2= (val >> 16);
        uint8_t byt1= (val >> 8);
         uint8_t byt0 = val;
         uint8_t  charData[4]={byt0,byt1, byt2, byt3,};
        emitValue<output_first>(ctx, 0x00000001 & charData[0]);
        emitValue<output_inxByte>(ctx, charData[inx]);
       emitValue<output_nBit>(ctx, in1 & charData[inx]);
        emitValue<output_transfer>(ctx, in3 & charData[3]);
         uint8_t transf = getValue<output_transfer>(ctx);

        if (isInputDirty<input_RST>(ctx))
            count = 0;
        else if (isInputDirty<input_INC>(ctx))
                        count >>= (transf);
                        count <<= 1;
         uint32_t cond = (count >= 0xFFFFFFFF);
        uint32_t trueVal = count;
        uint32_t falseVal =(count += getValue<input_BIT>(ctx));
        emitValue<output_NUMB>(ctx, cond ? trueVal : falseVal);
        emitValue<output_UPD>(ctx, 1);
      }
}