⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 randomm.nc

📁 tinyos密钥管理组件 用在tinyos仿真里的
💻 NC
字号:
module RandomM {  provides interface Random;}implementation{  uint16_t shiftReg;  uint16_t initSeed;  uint16_t mask;  /* Initialize the seed from the ID of the node */  async command result_t Random.init() {    dbg(DBG_BOOT, "RANDOM_LFSR initialized.\n");    atomic {      shiftReg = 119 * 119 * (1 + 1);      initSeed = shiftReg;      mask = 137 * 29 * (1 + 1);    }    return SUCCESS;  }  /* Return the next 16 bit random number */  async command uint16_t Random.rand() {    bool endbit;    uint16_t tmpShiftReg;    atomic {      tmpShiftReg = shiftReg;      endbit = ((tmpShiftReg & 0x8000) != 0);      tmpShiftReg <<= 1;      if (endbit) 	tmpShiftReg ^= 0x100b;      tmpShiftReg++;      shiftReg = tmpShiftReg;      tmpShiftReg = tmpShiftReg ^ mask;    }    return tmpShiftReg;  }  //  uint16_t TOSH_rand() __attribute__((C)) {//    return call Random.rand();//  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -