Electronic Products & Technology

How to Create Digital Dice

Designing a true random number generator from 1 to 6

July 28, 2020  By Dialog Semiconductor

Introduction

Modern technology makes it possible to conduct more and more processes in a digital manner. In this article, there is presented an application on how to design Digital Dice, a true random number generator from 1 to 6. This device can be used instead of a commonly used dice. It has a 1-digit 7-segment LED display and two buttons: “Run” and “Display Previous”.

Figure 1: Digital Dice Schematic Diagram

The Digital Dice can be powered from a single CR-2032 battery. It has no power-on switch due to negligibly low power consumption when idle. In this design, the integrated circuit which was designed is Dialog Semiconductor’s SLG46826V. The IC is the most suitable for the design as it has the lowest current consumption when idle which allows to get rid of the power switch. Also it has all the necessary macrocells, including three asynchronous oscillators with a variety of dividers. Moreover, the whole design was created in the GreenPAK Designer software which allows to perform such projects without knowledge of any programming language.

Device Architecture

Figure 2: GreenPAK6 Designer Project

The design consists of the following blocks:

  • Entropy Generator
  • Linear Feedback Shift Register
  • Binary to 7-Segment Decoder
  • Control Unit
  • Macrocell Settings

 

  1. Entropy Generator

The entropy generator is built of four asynchronous oscillators. Two of which are built using an inverted closed-loop LUT with delay (1 MHz and 6.5 MHz). Two others are GreenPAK’s OSC1 (2.048 MHz along with a divide by 3) and OSC2 (25 MHz divided by 2).

Inputting a few asynchronous clock signals to XNOR gate is enough to get an unpredictable signal on its output (noise or entropy). But the macrocells within the SLG46826V allow making even more complicated solutions. Using one more oscillator and DFF we get a completely random signal.

Figure 3: Entropy Generator

  1. Linear Feedback Shift Register

The 3-bit LFSR is built using three DFFs and one XNOR gate. This block with each input clock generates a 3-bit pseudo-random number. Here, instead of a clock pulse, the noise signal goes into the LFSR’s input, generating a true random 3-bit number.

Figure 4: LFSR

  1. Binary to 7-Segment Decoder

In order to convert the 3-bit random number generated by the LSFR, the Binary to 7-segment decoder is used, see Figure 3. The decoder is built of 3-bit LUTs.

Figure 5: Binary to 7 Segment Decoder

  1. Control Unit

The control unit is a part of the device designed to start it and stop after the 3-second period. Two pins are configured as inputs and two buttons must be connected from VDD to those pins. While the button “Run” is pressed, the device continuously generates random numbers. Right after the button is released, the generation stops and LFSR latches its outputs. The decoder subsequently drives a 7-segment display. After a 3 second period, the Digital Dice goes idle. The device is still powered on, but because all oscillations have been turned off, the current consumption is extremely low.

Figure 6: Control Unit

This allows the device to “remember” the last generated random number. If the button “Display Previous” is pressed, the last generated random number will be displayed until the button is released. Because Digital Dice is designed to replace usual dice, the 3-bit LUT12 is used to restart it when “0” or “7” occurs. This ensures the device will generate a random number in the range of 1 to 6.

  1. Macrocell Settings

For each macrocell, settings refer to the tables below.

Table 1. LUT Settings

 

 

Conclusion

The Digital Dice can be used as a replacement of usual dice in casinos or when playing any other games where dice are needed. It has an entropy generator that is constantly generating 3-bit random numbers while the button ‘Run’ is pressed.

Table 2: DFF Settings

It stops and displays the result only when the button is released, so the human factor also affects the generated random number. Four asynchronous oscillators together with human button push variability make the device completely and desirably unpredictable.

Above there are presented all the necessary steps required to build the whole design of the Digital Dice. However, it is possible just to get the result without the whole project performance.

Table 3: CNT/DLY Settings

Table 4: FILTER Settings

 

Table 5: P DLY Settings

Table 6: OSC Settings

Table 7: PIN Settings


Print this page

Related Stories

Leave a Reply

Your email address will not be published. Required fields are marked *

*