Capital University of Science and Technology Department of Electrical Engineering
Capital University of Science and Technology Department of Electrical Engineering
Instructions:
Q # 1. (20-Points)
(a). Write Verilog module in behavioral modeling for a 16-bit Random Number Generator.
Internally, module will use two 16-bit random number generators and select among them
based on output of a 4-bit Johnson counter. If output of the counter is multiple of 2, select 1st
random number, otherwise select 2nd random number. Random number generator should
use 5 XOR gates. Initialize first RNG with 16’h9090 and second RNG with 16’h0707.
(b). Write Stimulus module for testing of the 16-bit random number generator. Stimulus will
generate and give Clock and Reset signals to the random number generator and displays
generated random numbers on the screen using $monitor. Stimulus should display 10
random numbers on the screen.
Q # 2. (20-Points)
(a). Write Verilog module in Behavioral Modeling for a parameterized Clock Divider. Clock
Divider will use two parameters. One parameter will control output clock frequency and 2nd
parameter will control output Clock duty cycle.
parameter DivideFactor = X , parameter DutyCycle =Y
(b). Write a test-bench in Verilog, that will test the parameterized Clock divider for dividing
the input clock by 8 with duty cycle 25% and 20 with duty cycle 75%. It will also display
input and output clocks using $monitor.
Q # 3. (20-Points)
(a). Write Verilog module in Behavioral Modeling for a parameterized adder/subtractor.
Design can add or subtract N-bit numbers based upon an input control signal.
(b). Write an automated stimulus module in Behavioral Modeling that will exhaustively test
the parameterized module for adder/subtractor in part (a). Automated test-bench will only
Page 1 of 2
display inputs and outputs combinations on screen, when there is a mismatch between the
design module output and the simulated model results.
Q # 4. (20-Points)
(a). Convert the following no.’s from Qn.m fixed point format to decimal fractions ?
(c). Find the appropriate Qn.m format for given fractional data. Chosen Qn.m format
should represent the data in minimum possible bits?
» -14.315 in signed Qn.m format ?
Q # 5. For the two arrays X[4] and Y[4] do the following : (20-Points)
(a). Convert the array X[4] into signed Q1.3 format and array Y[4] into signed Q2.2
format
(b). Compute Z in fixed point arithmetic. If there is any overflow during the
computation, saturate the result. Also evaluate, what will be the Q format of Z?
Convert Z back to decimal as well ?
(c ). Compute Z in floating point arithmetic and compare it with the answer in part
(b) to find the error.
Page 2 of 2