Giter VIP home page Giter VIP logo

msp430-rng's Introduction

msp430-rng

Random and pseudorandom number generation for the MSP430, implemented in C.

Usage

  1. make rand
  2. #include "msp430-rng/rand.h"
  3. msp430-elf-gcc -o foo.elf foo.o rand.o

Generators

Random (rand())

Truly random number generator. Uses the time difference between the VLO and DCO, as outlined in SLAA338. It is self-contained, but it mucks about with clocks and timers, so it is only intended to be used very early on to generate the seed for a PRNG.

Pseudorandom (prand())

A very simple and fast PRNG implemented by a linear congruential generator with the following values:

  • modulus: 65536 (2^16)
  • multiplier: 49381
  • increment: 8643

Supported compilers

Currently only tested using the gcc msp430-elf cross-compiler (not mspgcc). Patches with modifications for other environments are welcome.

Tests

To run the tests, make test and run test.elf on your MSP430. They should take less than a minute to finish.

The test mechanism assumes that you are using a Launchpad, with LEDs on pins 0 and 6. While the tests are running, both LEDs are on; when the tests finish, one of the LEDs blinks (green: pass, red: fail).

Using mspdebug, it is easy to see which test is failing and possibly why:

prog test.elf
run
^C
md status 2
md sum_rand 2
md sum_prand 2

Monobit

An implementation of the Monobit algorithm outlined in section 2.1 of SP 800-22 Rev. 1a. Checks that the numbers of 0 and 1 bits in the produced values are equal to within a certain tolerance.

License

Provided under the terms of the MIT license. See LICENSE.txt for more information.

msp430-rng's People

Contributors

0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

msp430-rng's Issues

Can you please add a license?

Hi,

I'm working on an msp430 project and would like to incorporate this code into it. Can you please include a LICENSE.txt and annotate the source/headers and README file so I (and others who come after) can understand the guidelines you have in mind?

When no license is included, the legal implication is that the author is extending no license, that is, it cannot be used by anyone. Was this your intention?

Thanks for the library, in any event.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.