## Interview Question

A digital computer has a memory unit with 32-bit instructions and a register file with 32 registers. The instruction set consists of 95 different operations. The instruction consists of an opcode, a two register file addresses, and an immediate operand part. Each instruction is stored in one word of memory.

(a) How many bits are needed for the opcode part of the instruction?
(b) How many bits are needed to indicate the registers?
(c) How many bits remain for the immediate operand part?
(d) If the immediate operand is always a memory address, what is the maximum number of words that can be addressed in memory?
(e) What are the largest and smallest algebraic values of signed 2’s complement binary numbers that can be accommodated as an immediate operand?

## Interview Question

Draw the circuit diagram for barrel-shifter that can shift 3 bits in either direction. The shifter should take 3 bits as selectors: one bit is a selector, one bit indicates whether the shift is in the positive (value of 1) or negative (value of 0) direction, one bit indicates whether the shift is a distance of 1 (value of 0) or 2 (value of 1). You may use multiplexers in your design without drawing the inner workings of the multiplexer.

## Modelsim Tips & Tricks

In this article we will see how to create a simple Tcl script that tests for certain values on a signal and then adds bookmarks that zoom the Wave window when that value exists. Bookmarks allow you to save a particular zoom range and scroll position in the Wave window. The Tcl script also creates buttons in the Main window that call these bookmarks.

1. Create the script.
a. In a text editor, open a new file and enter the following lines:

echo "Bookmarking wave \$num"
bookmark add wave "bk\$num" "[expr \$stime - 50] [expr \$stime + 100]" 0
add button "\$num" [list bookmark goto wave bk\$num]
}

These commands do the following:
• Create a new procedure called "add_wave_zoom" that has two arguments, stime and num.
• Create a bookmark with a zoom range from the current simulation time minus 50 time units to the current simulation time plus 100 time units.
• Add a button to the Main window that calls the bookmark.
b. Now add these lines to the bottom of the script:
Assuming:
You have a RTL counter module with a bus called count..

when {clk'event and clk="1"} {
echo "Count is [exa count]"
if {[exa count]== "00100111"} {
} elseif {[exa count]== "01000111"} {
}
}

These commands do the following:
• Add all signals to the Wave window.
• Use a when statement to identify when clk transitions to 1.
• Examine the value of count at those transitions and add a bookmark if it is a certain value.