Challenge - 5 Problems
Hardware vs Software Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of Verilog procedural block
What is the output of the following Verilog code when the clock triggers?
Verilog
module test; reg clk = 0; reg [1:0] state = 2'b00; always @(posedge clk) begin state <= state + 1; end initial begin #1 clk = 1; #1 clk = 0; #1 clk = 1; #1 clk = 0; $display("State: %b", state); end endmodule
Attempts:
2 left
💡 Hint
Remember that state updates on the positive edge of clk and uses non-blocking assignment.
✗ Incorrect
The state increments twice on two positive edges of clk, starting from 00, so it becomes 01 then 10.
🧠 Conceptual
intermediateDifference between hardware description and software programming
Which statement best describes a key difference between hardware description languages (HDL) like Verilog and software programming languages?
Attempts:
2 left
💡 Hint
Think about how HDLs model circuits versus how software runs on processors.
✗ Incorrect
HDLs describe hardware components and their parallel operation, while software languages provide sequential instructions for CPUs.
🔧 Debug
advancedIdentify the error in this Verilog code snippet
What error will this Verilog code produce when synthesized or simulated?
Verilog
module counter(input clk, output reg [1:0] count); always @(clk) begin count = count + 1; end endmodule
Attempts:
2 left
💡 Hint
Sequential logic requires edge-triggered sensitivity.
✗ Incorrect
The sensitivity list should use 'posedge clk' for proper sequential behavior; otherwise synthesis tools will error.
📝 Syntax
advancedWhich Verilog code snippet correctly models a 2-bit register with asynchronous reset?
Select the code that correctly implements a 2-bit register with asynchronous active-low reset.
Attempts:
2 left
💡 Hint
Asynchronous reset triggers on reset signal edge, not clock edge.
✗ Incorrect
Option C correctly uses posedge clk and negedge rst_n in sensitivity list and resets asynchronously when rst_n is low.
🚀 Application
expertPredict the final value of a register after mixed blocking and non-blocking assignments
Given the following Verilog code, what is the final value of 'reg_a' after the always block executes on a positive clock edge?
Verilog
module test; reg clk = 0; reg [3:0] reg_a = 4'b0000; always @(posedge clk) begin reg_a = reg_a + 1; // blocking assignment reg_a <= reg_a + 1; // non-blocking assignment end initial begin #1 clk = 1; #1 clk = 0; #1 $display("reg_a = %b", reg_a); end endmodule
Attempts:
2 left
💡 Hint
Remember how blocking and non-blocking assignments interact in the same always block.
✗ Incorrect
The blocking assignment updates reg_a immediately to 0001, then the non-blocking schedules reg_a to be updated to 0001 + 1 = 0010 after the block.
