JAVA QUESTION

profilea1103929875
HW8problem4solution.docx

Background: One possible consequence of an input change event on a logic gate is an output change. In a simple simulator, this occurs at a constant delay after the input change event, so the code in the input-change event routine would look something like this:

schedule( time + delay, ... );

Assum you have written class PRNG discussed in the notes for Lecture 15, with a method randomFloat(f) that returns a value from 0.0 to f (some positive floating point scale factor).

A problem: In a real logic simulator, gate delays are not constant. Rather, they vary slightly and randomly each time a gate's output is changed. Rewrite the above code fragment so that delays vary over approximately a 10% range from 0.95 to 1.05 times the base delay for the gate. (0.5 points)

schedule( time + (delay * 0.95) + PRNG.randomFloat( delay * 0.1 ), ... );