Challenge - 5 Problems
UART Receiver Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateUART Receiver: Output Data Value
Given the UART receiver module below, what is the value of
data_out after receiving the byte 8'b10110011?Verilog
module uart_rx( input wire clk, input wire rst, input wire rx, output reg [7:0] data_out, output reg data_ready ); // Simplified UART receiver logic reg [3:0] bit_cnt = 0; reg [7:0] shift_reg = 0; reg receiving = 0; always @(posedge clk or posedge rst) begin if (rst) begin bit_cnt <= 0; shift_reg <= 0; data_out <= 0; data_ready <= 0; receiving <= 0; end else begin if (!receiving && rx == 0) begin // start bit detected receiving <= 1; bit_cnt <= 0; data_ready <= 0; end else if (receiving) begin if (bit_cnt < 8) begin shift_reg[bit_cnt] <= rx; bit_cnt <= bit_cnt + 1; end else begin data_out <= shift_reg; data_ready <= 1; receiving <= 0; end end end end endmodule
Attempts:
2 left
💡 Hint
Remember UART sends LSB first, so bits are shifted in order starting from bit 0.
✗ Incorrect
The UART receiver shifts in bits starting from the least significant bit (bit 0). The input byte 8'b10110011 is received bit by bit in order, so the shift register ends up holding the same value 8'b10110011.
🧠 Conceptual
intermediateUART Receiver Start Bit Detection
In a UART receiver module, why is the start bit detected by checking if the
rx line is low (0) when the receiver is idle?Attempts:
2 left
💡 Hint
Think about the default voltage level on the UART line when no data is sent.
✗ Incorrect
UART lines stay at logic high (1) when idle. The start bit is a low (0) signal that tells the receiver data is coming. Detecting a low on the line when idle means the start bit has arrived.
🔧 Debug
advancedIdentify the Bug in UART Receiver Bit Counting
What error will occur in the following UART receiver snippet when receiving 8 bits, and why?
Verilog
always @(posedge clk or posedge rst) begin if (rst) begin bit_cnt <= 0; end else if (receiving) begin if (bit_cnt <= 8) begin bit_cnt <= bit_cnt + 1; end else begin receiving <= 0; end end end
Attempts:
2 left
💡 Hint
Check the condition that controls bit_cnt increment and when receiving stops.
✗ Incorrect
The condition 'bit_cnt <= 8' allows bit_cnt to reach 9, which is one more than the 8 bits expected. This off-by-one error causes the receiver to shift in an extra bit, corrupting data.
📝 Syntax
advancedSyntax Error in UART Receiver Always Block
Which option contains a syntax error in the always block of a UART receiver module?
Verilog
always @(posedge clk or posedge rst) begin if (rst) begin bit_cnt <= 0 end else begin bit_cnt <= bit_cnt + 1; end end
Attempts:
2 left
💡 Hint
Check each line for missing punctuation.
✗ Incorrect
In Verilog, each statement inside begin-end must end with a semicolon. The line 'bit_cnt <= 0' is missing a semicolon, causing a syntax error.
🚀 Application
expertUART Receiver: Number of Data Bits Received
In a UART receiver module configured for 8 data bits, no parity, and 1 stop bit, how many bits in total does the receiver process per frame including start and stop bits?
Attempts:
2 left
💡 Hint
Count start bit + data bits + stop bit(s).
✗ Incorrect
A UART frame includes 1 start bit, 8 data bits, and 1 stop bit, totaling 10 bits per frame.
