Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You must write a MIPS assembly language program to generate pseudo-random numbers. They are not true random numbers because the algorithm always generates the same

You must write a MIPS assembly language program to generate pseudo-random numbers. They are not true random numbers because the algorithm always generates the same sequence when started with the same initial "seed" value.

Write a 32 bit pseudo-random number generator function, using a 32 bit LFSR (Linear Feedback Shift Register)

The initial value loaded into the LFSR is called the "seed" for the random number sequence. LFSRs must not be initialized to all zeros because they would remain stuck in that state, and the pseudo-random sequence must not generate all zeros.

The LFSR must be stored as a 32 bit word in the .data memory area and the argument in $a0 = 0 at entry to the subroutine for normal operation, and the next pseudo-random value is returned in $a0 and stored in the LFSR .data memory location. If the value of $a0 is not 0, then the value in $a0 is to be used as the seed and is simply stored in the LFSR .data memory location like this:

.data lfsr: .word 0 # a place to store the random number

# The value in $a0 is an argument passed from the main program to the random number routine

# if argument $a0==0 the subroutine calculates the next 32 bit pseudo-random number and

# stores it in memory location lfsr, and returns it in $a0

# if argument $a0!=0 then the content of $a0 is stored in .data memory as the initial "seed" value

#

Note that one bit shift generates one bit and 32 NEW bits must be generated for each time the function is called.

You must write your MIPS assembly lfsr function and display the first ten 32 bit values generated when starting with a seed value of 0x F00F5AA5. The LFSR assembly function should use the following "taps" or bit numbers to XOR together: 32 30 26 and 25 (Where bit 32 is the rightmost bit, the LS Bit.) Those 4 bits are XOR'd and the result is shifted into bit 1, the MSB, and all the other bits are shifted right one position (what was in bit 1 shifts to bit 2, bit 2 shifts to 3, and so on). When XOR is performed on those 4 bits, the XOR result is 1 iff the input has an odd number of ones, and 0 otherwise.

The selection of taps for the LFSR above generates a maximum length pseudo-random sequence with all 4294967295 possible unique values not including 0.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago