#include "block.h" #include "random.h" class BitGen : public Block { private: OutPort < bool > * out; Parameter < long > * seed; Random generator; public: BitGen(const Blockopt & blockopt) : Block(blockopt) {} void makeParameters() { seed = new Parameter < long > (this, "seed", 12345); } void makeIOPorts() { out = new OutPort < bool > (this, "out", 1); } void initialize() { generator.setSeed(seed->value()); } void go() { out->write(generator.getRand() > 0.5); } }; PUBLISH(BitGen);