You are here

My Pseudo Random Number Generator | Cypress Semiconductor

My Pseudo Random Number Generator

 The way I have previously built pseudo random number generators is to take a register of some width and toggle some bits if the MSBit is 1.  Then circular rotate left  (MSBit becomes LSBit).  The bits needed to be toggled, differ with the length of the register.

That is:

forever{

   if( MSBit == 1) toggle some bits;

   circular rotate left

}

 

 

This implementation has the problem that if the register value is zero, it remains zero.  This means for an 8 bit register, you get pseudo random values between 1 and 255.

 Instead I changed the process so that the bits are toggled  if the MSBit is 0.

forever{

   if( MSBit != 1) toggle some bits;

   circular rotate left

}

It can be implements with two of the datapath registers

 A0 = (A0 ^ D) <<1 (so conneted  to si)

  A0 = A0 <<1 (so connected to si)

Add two more states of A0=0 and you have a fix is case the register somehow gets a ff value.

 

Gawd I love datapaths!

 

 

Now the dead value is all ones and the PSoC logic starts up logic low. So for an 8 bit register, you get random values between 0 and 254.  This is nicer for density signal generation.  You do not have to initialize this hardware as it will start up with its initial values.

ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.