Gambling dice

Dice – Generate and show random number between 1 and 6.

This example shows how easy it is to create a dice with Realizer Essentially, a dice is nothing else than generating and showing a random number between 1 and 6 every time it is activated. Next in this text is a description that eventually builds a complete application that implements a dice using a virtual hardware platform, a printed circuit board with a 7 segment LED display and a pushbutton. Each push on the button will result in a new random number shown on the display. The first part of the Realizer schematic is shown here:

It shows how a number generator running from 1..6. On the top left is an inverter it changes from 0 to 1 and from 1 to 0.
The counter has multiple inputs and outputs.
  • up is the value made by the inverter.
  • dn and clr have the constant value of 0.
  • pr (preset) has the value from the and symbol 1 or 0.
  • the number 1 in the counter symbol is the minimal number to start with value.
  • the output and can be 1 to 6 and zero is not used here (only if val is 0).

The symbol on the bottom is a Comparator. It compares the input at B with the input from A and C the Output is 1 when B is the same as A and C else the output is 0.

The randomizer:

The next part in this schematic is used to show the output on a 7 segment display. The D-Element on the left has 2 inputs and 2 outputs.The inputs on the D-Element are the number 1..6 and a link to a I/O switch, D shows the data input that is the random created number, the C is the port to the Switch. If the Switch is turned on the data is transferred to the IndexTable else not. The IndexTable converts a decimal number in to a binary number. The long symbol on the right is a byte unpack. It forwards a certain binary code into a boolean output. All the output segments are connected to leds on a 7 segment display.


The dice schematic can also be simulated in Realizer, when the simulator has started, the schematic will look like this. As you can see the output are 1’s and 0’s, they are places in a certain form. They are placed in the form of a 7-segment number.


Prepared for devices: ST7FLite10 PIC16F876 ansi-c other devices possible by reconnecting I/O pins.