Exam Type D:: Monday PM Wednesday AM Wednesday PM
Exam Type D:: Monday PM Wednesday AM Wednesday PM
BA3135
BA3145
BA3155
Wednesday AM
BA3135
BA3145
BA3155
Wednesday PM
BA3135
BA3145
BA3155
Full Name:
Student Number:
UTORID:
MARKS
10
Total
/5
/6
/8
/7
/10
/6
/4
/8
/6
/10
/70
Question 1 [5 Marks]
(a) If you were only allowed to use one type of simple logic gate to build a large digital circuit,
which gate would you pick? Why?
Solution:
NAND or NOR gates are called universal gates and can implement
any logic function.
(b) Write the ModelSim commands to generate the following waveform:
1
Xin
0
20ns
10ns
15ns
Solution:
force Xin 0
run 10ns
force Xin 1
run 20ns
force Xin 0
run 15ns
(c) The signal OutputF is to be displayed on an LED connected to port pLED. The intended
behaviour is for the LED to turn on when OutputF is logic-1. You use the following assignment statement:
assign pLED = OutputF;
and find that the LED is off when OutputF = 1 and the LED is on when OutputF = 0. Write
the assignment statement to fix this.
Solution:
assign pLED = OutputF;
Question 1 continued . . .
(d) State both forms of DeMorgans Theorem (as Boolean equations).
Solution:
a+b=ab
or
ab=a +b
(e) What valuable information can be learned from simulation with ModelSim (vs. directly loading the design into the FPGA and testing the hardware)?
Solution:
In simulation, you can view ANY logic signal in the simulation (not
solely primary inputs + primary outputs). Or, some other response
about what can be observed in simulation that cannot be seen in the
actual hardware.
D3 D2 D1 D0
Resetb
4-Bit Register
Clock
Q3 Q2 Q1 Q0
Solution:
module reg4bit (D, Clock, Resetb, Q);
input [3:0] D;
input Clock, Resetb;
output reg [3:0] Q;
always @(posedge Clock)
if (!Resetb)
Q <= 0;
else
Q <= D;
endmodule
12
Question 10 continued . . .
(b) [3 Marks] Starting with the register described above, write a Verilog module that adds an
Enable signal to the register. The register will only load a new value when Enable = 1. The
schematic symbol is shown below. If convenient, you may number your lines in Part (a) and
for this part, indicate which lines change and how they are changed.
Enable
Resetb
D3 D2 D1 D0
4-Bit Register
Clock
Q3 Q2 Q1 Q0
Solution:
module reg4bit (D, Clock, Resetb, Enable, Q);
input [3:0] D;
input Clock, Resetb, Enable;
output reg [3:0] Q;
always @(posedge Clock)
if (!Resetb)
Q <= 0;
else if (Enable)
Q <= D;
endmodule
13
This page has been left blank intentionally. You may use it for answers to any questions.
14
This page has been left blank intentionally. You may use it for answers to any questions.
15