C7 · Problem set 10
Problem set 10: Verilog, design and logic in code
These problems use lessons 48 to 51: reading Verilog, writing Verilog, the adder and vending-machine sandbox, and the logic lab.
Check
A module declares wire [15:0] bus;.
(a)
How many wires is that?
(b)
How many bits does bus[15:0] select?
Check
Registers a = 7 and b = 5 run one clock of a <= b; b <= a + b; (nonblocking).
(a)
What is a afterward?
(b)
What is b afterward?
Check
The same registers (a = 7, b = 5) instead run a = b; b = a + b; (blocking) once.
(a)
What is a afterward?
(b)
What is b afterward?
Check
A clocked block assigns reg [4-1:0] x, reg [1-1:0] y and reg [32-1:0] z, all with <=.
(a)
How many flip-flops does it create?
(b)
What is the largest value x can hold?
Check
A reg [4-1:0] c starts at 15 and runs c <= c + 1; each clock.
(a)
What does it hold after 50 clocks?
(b)
How many times has it wrapped through 0?
Check
What does assign y = a ? b : c; compute? Write it with AND, OR and NOT (inputs A, B, C).
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
A 4-bit ripple-carry adder adds A = 9 and B = 5.
(a)
What is its 4-bit sum?
(b)
What is its carry out?
Check
The sandbox's vending machine sells a 15¢ item for nickels, one coin per clock, and vends on the third.
(a)
How many items have vended after 7 nickels?
(b)
How many cents is it holding toward the next?
Check
In Quine–McCluskey for 5 variables, a pattern has 1 dashes.
(a)
How many literals does its term have?
(b)
How many minterms does it cover?
Check
A 4-input truth table numbers its rows with the first input as the top bit.
(a)
What is input 0 (counting from 0 at the first input) in row 11?
(b)
Which row has every input inverted?
Check
A running-parity Mealy machine outputs the parity of all the 1s seen so far. A stream of 10 bits contains 6 ones.
(a)
What does it output after the last bit?
(b)
How many states does it need?
Check
Find a minimal cover of using three of its prime implicants.
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
always @(posedge clk) c <= c + 1; with an N = 12-bit c runs at 10 MHz.
(a)
What frequency comes out of its top bit?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
(b)
What's its largest value?
Check
Write the logic of a 4:1 multiplexer: case ({S1, S0}) selecting a, b, c, d for 00, 01, 10, 11.
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
always @(posedge clk) r <= {r[N-2:0], d}; with N = 8, followed by 1 more registers in a chain.
(a)
How many flip-flops in all?
(b)
After how many clocks does a bit of d reach the last register?
Have paper and a calculator ready. Work each problem out by hand, then enter the answer. Your first try on each one counts toward your score.
Practice
Keep practicing
12 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.