{"id":10344,"date":"2026-10-21T13:44:13","date_gmt":"2026-10-21T13:44:13","guid":{"rendered":"https:\/\/inskill.in\/training\/?p=10344"},"modified":"2026-10-22T13:47:31","modified_gmt":"2026-10-22T13:47:31","slug":"verilog-coding-problems-rtl-freshers","status":"publish","type":"post","link":"https:\/\/inskill.in\/training\/vlsi\/verilog-coding-problems-rtl-freshers\/","title":{"rendered":"Verilog Coding Problems Every RTL Fresher Should Practice"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"10344\" class=\"elementor elementor-10344\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-541d847 elementor-section-boxed elementor-section-height-default elementor-section-height-default wpr-particle-no wpr-jarallax-no wpr-parallax-no wpr-sticky-section-no wpr-column-slider-no wpr-equal-height-no\" data-id=\"541d847\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-ffe35b4\" data-id=\"ffe35b4\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-aedb66c elementor-widget elementor-widget-text-editor\" data-id=\"aedb66c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"font-weight: 400;\">Verilog coding is a core skill for freshers applying for RTL design and digital design roles. Technical interviews often require candidates to write a small hardware module, explain its behavior, identify edge cases, or modify the code when the interviewer introduces a new requirement.<\/span><\/p><p><span style=\"font-weight: 400;\">Knowing Verilog syntax alone is not enough. You must understand whether a design is combinational or sequential, how reset and enable signals behave, how registers update at clock edges, and whether your code describes the intended hardware.<\/span><\/p><p><span style=\"font-weight: 400;\">This guide covers practical <\/span><b>Verilog coding problems every RTL fresher should practice<\/b><span style=\"font-weight: 400;\">, with code examples, explanations, and common mistakes. Start by solving each problem independently, then compare your approach with the examples.<\/span><\/p><h3><span style=\"font-weight: 400;\">1. Write a 2:1 Multiplexer<\/span><\/h3><p><b>Problem:<\/b><span style=\"font-weight: 400;\"> Design a 2:1 multiplexer with inputs <\/span><span style=\"font-weight: 400;\">a<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">b<\/span><span style=\"font-weight: 400;\">, and select signal <\/span><span style=\"font-weight: 400;\">sel<\/span><span style=\"font-weight: 400;\">. When <\/span><span style=\"font-weight: 400;\">sel<\/span><span style=\"font-weight: 400;\"> is zero, the output should be <\/span><span style=\"font-weight: 400;\">a<\/span><span style=\"font-weight: 400;\">; otherwise, it should be <\/span><span style=\"font-weight: 400;\">b<\/span><span style=\"font-weight: 400;\">.<\/span><\/p><p><span style=\"font-weight: 400;\">module mux2to1 (<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire a,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire b,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire sel,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0output wire y<\/span><\/p><p><span style=\"font-weight: 400;\">);<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0assign y = sel ? b : a;<\/span><\/p><p><span style=\"font-weight: 400;\">endmodule<\/span><\/p><p><b>Explanation:<\/b><span style=\"font-weight: 400;\"> This is combinational logic. The output depends on the current input values, not on a clock edge. The conditional operator selects one of the two inputs.<\/span><\/p><p><b>Interview follow-up:<\/b><span style=\"font-weight: 400;\"> How would you implement a 4:1 multiplexer? You could use nested conditional operators, a <\/span><span style=\"font-weight: 400;\">case<\/span><span style=\"font-weight: 400;\"> statement inside a combinational process, or multiple 2:1 multiplexers.<\/span><\/p><p><b>Common mistake:<\/b><span style=\"font-weight: 400;\"> Introducing a clocked process for a circuit that does not require storage.<\/span><\/p><h3><span style=\"font-weight: 400;\">2. Design a D Flip-Flop With Synchronous Reset<\/span><\/h3><p><b>Problem:<\/b><span style=\"font-weight: 400;\"> Create a D flip-flop that captures <\/span><span style=\"font-weight: 400;\">d<\/span><span style=\"font-weight: 400;\"> on the rising edge of <\/span><span style=\"font-weight: 400;\">clk<\/span><span style=\"font-weight: 400;\">. If <\/span><span style=\"font-weight: 400;\">reset<\/span><span style=\"font-weight: 400;\"> is high at that edge, the output must become zero.<\/span><\/p><p><span style=\"font-weight: 400;\">module dff_sync_reset (<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire clk,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire reset,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire d,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0output reg\u00a0 q<\/span><\/p><p><span style=\"font-weight: 400;\">);<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0always @(posedge clk) begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (reset)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0q &lt;= 1&#8217;b0;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0q &lt;= d;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0end<\/span><\/p><p><span style=\"font-weight: 400;\">endmodule<\/span><\/p><p><b>Explanation:<\/b><span style=\"font-weight: 400;\"> The output changes only on the rising clock edge. Reset is synchronous because it is checked inside the clocked process and does not independently trigger an update.<\/span><\/p><p><span style=\"font-weight: 400;\">Non-blocking assignment (<\/span><span style=\"font-weight: 400;\">&lt;=<\/span><span style=\"font-weight: 400;\">) is the standard choice for modeling sequential register updates.<\/span><\/p><p><b>Interview follow-up:<\/b><span style=\"font-weight: 400;\"> How would you implement an asynchronous reset? You would normally include the reset edge in the sensitivity list, such as <\/span><span style=\"font-weight: 400;\">negedge reset_n<\/span><span style=\"font-weight: 400;\"> for an active-low reset, and define the reset branch accordingly.<\/span><\/p><p><b>Common mistake:<\/b><span style=\"font-weight: 400;\"> Confusing synchronous and asynchronous reset behavior.<\/span><\/p><h3><span style=\"font-weight: 400;\">3. Implement an Up Counter With Enable<\/span><\/h3><p><b>Problem:<\/b><span style=\"font-weight: 400;\"> Design an 8-bit counter that increments on each rising clock edge when <\/span><span style=\"font-weight: 400;\">enable<\/span><span style=\"font-weight: 400;\"> is high and resets to zero when synchronous <\/span><span style=\"font-weight: 400;\">reset<\/span><span style=\"font-weight: 400;\"> is asserted.<\/span><\/p><p><span style=\"font-weight: 400;\">module up_counter (<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 clk,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 reset,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 enable,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0output reg [7:0]\u00a0 count<\/span><\/p><p><span style=\"font-weight: 400;\">);<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0always @(posedge clk) begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (reset)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count &lt;= 8&#8217;d0;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else if (enable)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count &lt;= count + 1&#8217;b1;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0end<\/span><\/p><p><span style=\"font-weight: 400;\">endmodule<\/span><\/p><p><b>Explanation:<\/b><span style=\"font-weight: 400;\"> Reset has priority over enable. When both are low, no assignment occurs to <\/span><span style=\"font-weight: 400;\">count<\/span><span style=\"font-weight: 400;\">, so the register retains its previous value.<\/span><\/p><p><span style=\"font-weight: 400;\">Because the counter is eight bits wide, it wraps from 255 to 0 under ordinary unsigned arithmetic.<\/span><\/p><p><b>Interview follow-up:<\/b><span style=\"font-weight: 400;\"> How would you create a counter that stops at 99? Add a terminal-count condition so the counter holds its value when it reaches the required limit. Be clear about whether the design should wrap, saturate, or restart at zero.<\/span><\/p><p><b>Common mistake:<\/b><span style=\"font-weight: 400;\"> Ignoring overflow behavior or failing to clarify the required counting range.<\/span><\/p><h3><span style=\"font-weight: 400;\">4. Write a Shift Register<\/span><\/h3><p><b>Problem:<\/b><span style=\"font-weight: 400;\"> Create a four-bit serial-in, serial-out shift register. On every rising edge, shift the stored bits toward the most significant bit and insert <\/span><span style=\"font-weight: 400;\">serial_in<\/span><span style=\"font-weight: 400;\"> into bit zero.<\/span><\/p><p><span style=\"font-weight: 400;\">module shift_register (<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 clk,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 reset,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 serial_in,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0output reg [3:0]\u00a0 q<\/span><\/p><p><span style=\"font-weight: 400;\">);<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0always @(posedge clk) begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (reset)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0q &lt;= 4&#8217;b0000;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0q &lt;= {q[2:0], serial_in};<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0end<\/span><\/p><p><span style=\"font-weight: 400;\">endmodule<\/span><\/p><p><b>Explanation:<\/b><span style=\"font-weight: 400;\"> The concatenation <\/span><span style=\"font-weight: 400;\">{q[2:0], serial_in}<\/span><span style=\"font-weight: 400;\"> constructs the next four-bit value. The previous bits move one position toward the most significant bit, and the new serial bit enters at the least significant position.<\/span><\/p><p><b>Practical example:<\/b><span style=\"font-weight: 400;\"> Shift registers are useful in serial data handling and in circuits that need to move data through a sequence of register stages.<\/span><\/p><p><b>Interview follow-up:<\/b><span style=\"font-weight: 400;\"> Add an <\/span><span style=\"font-weight: 400;\">enable<\/span><span style=\"font-weight: 400;\"> input so shifting occurs only when enabled. The register should hold its value when enable is low.<\/span><\/p><p><b>Common mistake:<\/b><span style=\"font-weight: 400;\"> Reversing the shift direction or inserting the serial bit into the wrong position.<\/span><\/p><h3><span style=\"font-weight: 400;\">5. Design a Mod-10 Counter<\/span><\/h3><p><b>Problem:<\/b><span style=\"font-weight: 400;\"> Design a counter that cycles through values 0 to 9 and then returns to zero.<\/span><\/p><p><span style=\"font-weight: 400;\">module mod10_counter (<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire\u00a0 \u00a0 \u00a0 clk,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire\u00a0 \u00a0 \u00a0 reset,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0output reg [3:0] count<\/span><\/p><p><span style=\"font-weight: 400;\">);<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0always @(posedge clk) begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (reset)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count &lt;= 4&#8217;d0;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else if (count == 4&#8217;d9)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count &lt;= 4&#8217;d0;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count &lt;= count + 1&#8217;b1;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0end<\/span><\/p><p><span style=\"font-weight: 400;\">endmodule<\/span><\/p><p><b>Explanation:<\/b><span style=\"font-weight: 400;\"> Four bits are sufficient to represent values 0 through 9. The terminal-count condition ensures that the counter returns to zero after reaching nine rather than continuing to 15.<\/span><\/p><p><b>Interview follow-up:<\/b><span style=\"font-weight: 400;\"> What happens if the counter starts in an illegal state such as 12? In this implementation, it increments normally until it wraps around. If recovery from illegal states is required, add an explicit recovery condition based on the specification.<\/span><\/p><p><b>Common mistake:<\/b><span style=\"font-weight: 400;\"> Using an incorrect terminal count or choosing a width without considering the required range.<\/span><\/p><h3><span style=\"font-weight: 400;\">6. Implement a Combinational ALU<\/span><\/h3><p><b>Problem:<\/b><span style=\"font-weight: 400;\"> Design a simple 4-bit arithmetic logic unit that supports addition, subtraction, AND, and OR operations.<\/span><\/p><p><span style=\"font-weight: 400;\">module simple_alu (<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire [3:0] a,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire [3:0] b,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire [1:0] op,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0output reg\u00a0 [3:0] y<\/span><\/p><p><span style=\"font-weight: 400;\">);<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0always @(*) begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0case (op)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02&#8217;b00: y = a + b;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02&#8217;b01: y = a &#8211; b;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02&#8217;b10: y = a &amp; b;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02&#8217;b11: y = a | b;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0default: y = 4&#8217;b0000;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0endcase<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0end<\/span><\/p><p><span style=\"font-weight: 400;\">endmodule<\/span><\/p><p><b>Explanation:<\/b><span style=\"font-weight: 400;\"> The <\/span><span style=\"font-weight: 400;\">case<\/span><span style=\"font-weight: 400;\"> statement selects the operation according to <\/span><span style=\"font-weight: 400;\">op<\/span><span style=\"font-weight: 400;\">. Since all possible two-bit values are covered, every valid operation has a defined assignment. The default assignment provides an explicit fallback.<\/span><\/p><p><span style=\"font-weight: 400;\">The output is four bits wide, so arithmetic results are truncated to four bits. If a carry-out is required, the design needs a wider intermediate result or a separate carry output.<\/span><\/p><p><b>Interview follow-up:<\/b><span style=\"font-weight: 400;\"> Add XOR, comparison, or a zero flag. Explain how you would handle signed versus unsigned arithmetic.<\/span><\/p><p><b>Common mistake:<\/b><span style=\"font-weight: 400;\"> Forgetting that output width affects the result of arithmetic operations.<\/span><\/p><h3><span style=\"font-weight: 400;\">7. Design an FSM for a Simple Sequence Detector<\/span><\/h3><p><b>Problem:<\/b><span style=\"font-weight: 400;\"> Detect the serial bit pattern <\/span><span style=\"font-weight: 400;\">101<\/span><span style=\"font-weight: 400;\"> in an incoming data stream. For this example, use a Moore-style FSM with overlapping sequence detection.<\/span><\/p><p><span style=\"font-weight: 400;\">A practical solution requires defining states that represent the amount of the pattern matched so far. The following example uses four states: no match, matched <\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">, matched <\/span><span style=\"font-weight: 400;\">10<\/span><span style=\"font-weight: 400;\">, and matched <\/span><span style=\"font-weight: 400;\">101<\/span><span style=\"font-weight: 400;\">.<\/span><\/p><p><span style=\"font-weight: 400;\">module sequence_detector (<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire clk,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire reset,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire din,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0output reg\u00a0 detected<\/span><\/p><p><span style=\"font-weight: 400;\">);<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0localparam IDLE = 2&#8217;b00,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0S1 \u00a0 = 2&#8217;b01,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0S10\u00a0 = 2&#8217;b10,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0S101 = 2&#8217;b11;<\/span><\/p><p>\u00a0<\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0reg [1:0] state, next_state;<\/span><\/p><p>\u00a0<\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0always @(posedge clk) begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (reset)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0state &lt;= IDLE;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0state &lt;= next_state;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0end<\/span><\/p><p>\u00a0<\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0always @(*) begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0next_state = IDLE;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0detected = 1&#8217;b0;<\/span><\/p><p>\u00a0<\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0case (state)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0IDLE: begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (din)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0next_state = S1;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0next_state = IDLE;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0end<\/span><\/p><p>\u00a0<\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0S1: begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (din)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0next_state = S1;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0next_state = S10;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0end<\/span><\/p><p>\u00a0<\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0S10: begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (din)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0next_state = S101;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0next_state = IDLE;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0end<\/span><\/p><p>\u00a0<\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0S101: begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0detected = 1&#8217;b1;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (din)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0next_state = S1;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0next_state = S10;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0end<\/span><\/p><p>\u00a0<\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0default: next_state = IDLE;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0endcase<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0end<\/span><\/p><p><span style=\"font-weight: 400;\">endmodule<\/span><\/p><p><b>Explanation:<\/b><span style=\"font-weight: 400;\"> The state represents the matched prefix of the sequence. After detecting <\/span><span style=\"font-weight: 400;\">101<\/span><span style=\"font-weight: 400;\">, the machine retains a valid suffix for the next input, allowing overlap.<\/span><\/p><p><b>Interview follow-up:<\/b><span style=\"font-weight: 400;\"> Explain how you would modify the machine to detect a different pattern or implement a Mealy version. Be prepared to trace the state transitions for an input stream such as <\/span><span style=\"font-weight: 400;\">10101<\/span><span style=\"font-weight: 400;\">.<\/span><\/p><p><b>Common mistake:<\/b><span style=\"font-weight: 400;\"> Writing the state transitions without checking overlapping patterns or failing to assign defaults in combinational next-state logic.<\/span><\/p><h3><span style=\"font-weight: 400;\">8. Find and Fix an Unintended Latch<\/span><\/h3><p><b>Problem:<\/b><span style=\"font-weight: 400;\"> An interviewer provides the following code and asks what is wrong.<\/span><\/p><p><span style=\"font-weight: 400;\">always @(*) begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0if (enable)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0y = a;<\/span><\/p><p><span style=\"font-weight: 400;\">end<\/span><\/p><p><b>What is the issue?<\/b><span style=\"font-weight: 400;\"> When <\/span><span style=\"font-weight: 400;\">enable<\/span><span style=\"font-weight: 400;\"> is low, <\/span><span style=\"font-weight: 400;\">y<\/span><span style=\"font-weight: 400;\"> is not assigned. It must retain its previous value, which implies storage and can infer a latch.<\/span><\/p><p><span style=\"font-weight: 400;\">If combinational behavior is intended, provide a default assignment:<\/span><\/p><p><span style=\"font-weight: 400;\">always @(*) begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0y = 1&#8217;b0;<\/span><\/p><p>\u00a0<\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0if (enable)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0y = a;<\/span><\/p><p><span style=\"font-weight: 400;\">end<\/span><\/p><p><span style=\"font-weight: 400;\">This version assigns <\/span><span style=\"font-weight: 400;\">y<\/span><span style=\"font-weight: 400;\"> in every execution of the process. The correct default value depends on the required functionality.<\/span><\/p><p><b>Interview follow-up:<\/b><span style=\"font-weight: 400;\"> How can you identify unintended latch inference? Review RTL and lint warnings, inspect synthesis reports, and check that every output of a combinational process receives an assignment on every possible path.<\/span><\/p><p><b>Common mistake:<\/b><span style=\"font-weight: 400;\"> Assuming that <\/span><span style=\"font-weight: 400;\">always @(*)<\/span><span style=\"font-weight: 400;\"> automatically makes every design combinational. The assignments inside the process determine whether storage is required.<\/span><\/p><h3><span style=\"font-weight: 400;\">9. Write a Parameterized Counter<\/span><\/h3><p><b>Problem:<\/b><span style=\"font-weight: 400;\"> Create a reusable counter whose width can be changed through a parameter.<\/span><\/p><p><span style=\"font-weight: 400;\">module parameter_counter #(<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0parameter WIDTH = 8<\/span><\/p><p><span style=\"font-weight: 400;\">) (<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 clk,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 reset,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 enable,<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0output reg [WIDTH-1:0]\u00a0 count<\/span><\/p><p><span style=\"font-weight: 400;\">);<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0always @(posedge clk) begin<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (reset)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count &lt;= {WIDTH{1&#8217;b0}};<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else if (enable)<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count &lt;= count + 1&#8217;b1;<\/span><\/p><p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0end<\/span><\/p><p><span style=\"font-weight: 400;\">endmodule<\/span><\/p><p><b>Explanation:<\/b><span style=\"font-weight: 400;\"> The <\/span><span style=\"font-weight: 400;\">WIDTH<\/span><span style=\"font-weight: 400;\"> parameter controls the number of counter bits. The replication expression <\/span><span style=\"font-weight: 400;\">{WIDTH{1&#8217;b0}}<\/span><span style=\"font-weight: 400;\"> creates a zero value with the configured width.<\/span><\/p><p><span style=\"font-weight: 400;\">For an unsigned counter of width (N), the representable range is (0) through (2^N-1), and normal incrementing wraps around after the maximum value.<\/span><\/p><p><b>Interview follow-up:<\/b><span style=\"font-weight: 400;\"> How would you support a programmable terminal count? Explain how you would handle parameter values and prevent invalid configurations.<\/span><\/p><p><b>Common mistake:<\/b><span style=\"font-weight: 400;\"> Hard-coding the width in part of the logic, which makes a supposedly reusable module harder to maintain.<\/span><\/p><h3><span style=\"font-weight: 400;\">10. How Should You Test Your Verilog Solutions?<\/span><\/h3><p><span style=\"font-weight: 400;\">Writing code is only part of an RTL coding problem. You should also explain how you would verify the implementation.<\/span><\/p><p><span style=\"font-weight: 400;\">For each design, consider:<\/span><\/p><ul><li style=\"font-weight: 400;\" aria-level=\"1\"><b>Normal behavior:<\/b><span style=\"font-weight: 400;\"> Does it work for typical input sequences?<\/span><\/li><li style=\"font-weight: 400;\" aria-level=\"1\"><b>Reset behavior:<\/b><span style=\"font-weight: 400;\"> Does it reset correctly at the specified time?<\/span><\/li><li style=\"font-weight: 400;\" aria-level=\"1\"><b>Boundary conditions:<\/b><span style=\"font-weight: 400;\"> What happens at zero, maximum count, or a terminal state?<\/span><\/li><li style=\"font-weight: 400;\" aria-level=\"1\"><b>Control priority:<\/b><span style=\"font-weight: 400;\"> What happens if reset and enable are asserted together?<\/span><\/li><li style=\"font-weight: 400;\" aria-level=\"1\"><b>Combinational completeness:<\/b><span style=\"font-weight: 400;\"> Are all outputs assigned on every path?<\/span><\/li><li style=\"font-weight: 400;\" aria-level=\"1\"><b>Width and signedness:<\/b><span style=\"font-weight: 400;\"> Could an operation overflow or truncate unexpectedly?<\/span><\/li><\/ul><p><span style=\"font-weight: 400;\">For example, a counter testbench should check reset, incrementing, holding when disabled, and wrap-around. An FSM testbench should check expected state transitions and detection behavior. A combinational ALU should be tested for every operation code and representative input values.<\/span><\/p><p><span style=\"font-weight: 400;\">Use a simulator to validate your assumptions. Passing a few test cases does not prove correctness, but systematic tests make functional mistakes easier to find.<\/span><\/p><p><span style=\"font-weight: 400;\">For additional practice, read VLSIGuru\u2019s<\/span><a href=\"https:\/\/vlsiguru.com\/blog\/verilog-coding-interview-questions\"> <span style=\"font-weight: 400;\">Verilog Coding Interview Questions in VLSI<\/span><\/a><span style=\"font-weight: 400;\"> and InSkill\u2019s<\/span><a href=\"https:\/\/inskill.in\/training\/vlsi\/top-systemverilog-coding-questions-vlsi-interviews\/\"> <span style=\"font-weight: 400;\">Top SystemVerilog Coding Questions for VLSI Interviews<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p><h4><span style=\"font-weight: 400;\">Conclusion<\/span><\/h4><p><span style=\"font-weight: 400;\">Verilog coding interviews assess whether you can translate a specification into correct <\/span><a href=\"https:\/\/inskill.in\/training\/vlsi\/how-to-prepare-for-technical-vlsi-rounds-as-a-fresher\/\"><span style=\"font-weight: 400;\">RTL<\/span><\/a><span style=\"font-weight: 400;\"> and explain the hardware behavior clearly. Freshers should practise multiplexers, flip-flops, counters, shift registers, ALUs, FSMs, parameterized designs, and common coding-error scenarios.<\/span><\/p><p><span style=\"font-weight: 400;\">For every problem, clarify reset behavior, input and output requirements, edge cases, and whether the design is combinational or sequential before writing code. Then explain the solution, identify its limitations, and describe how you would test it.<\/span><\/p><p><span style=\"font-weight: 400;\">Consistent practice with simulation and debugging will help you develop the skills expected in entry-level RTL design interviews.<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Verilog coding is a core skill for freshers applying for RTL design and digital design roles. Technical interviews often require candidates to write a small hardware module, explain its behavior, identify edge cases, or modify the code when the interviewer introduces a new requirement. Knowing Verilog syntax alone is not enough. You must understand whether a design is combinational or sequential, how reset and enable signals behave, how registers update at clock edges, and whether your code describes the intended hardware. This guide covers practical Verilog coding problems every RTL fresher should practice, with code examples, explanations, and common mistakes. Start by solving each problem independently, then compare your approach with the examples. 1. Write a 2:1 Multiplexer Problem: Design a 2:1 multiplexer with inputs a, b, and select signal sel. When sel is zero, the output should be a; otherwise, it should be b. module mux2to1 ( \u00a0\u00a0\u00a0\u00a0input\u00a0 wire a, \u00a0\u00a0\u00a0\u00a0input\u00a0 wire b, \u00a0\u00a0\u00a0\u00a0input\u00a0 wire sel, \u00a0\u00a0\u00a0\u00a0output wire y ); \u00a0\u00a0\u00a0\u00a0assign y = sel ? b : a; endmodule Explanation: This is combinational logic. The output depends on the current input values, not on a clock edge. The conditional operator selects one of the two inputs. Interview follow-up: How would you implement a 4:1 multiplexer? You could use nested conditional operators, a case statement inside a combinational process, or multiple 2:1 multiplexers. Common mistake: Introducing a clocked process for a circuit that does not require storage. 2. Design a D Flip-Flop With Synchronous Reset Problem: Create a D flip-flop that captures d on the rising edge of clk. If reset is high at that edge, the output must become zero. module dff_sync_reset ( \u00a0\u00a0\u00a0\u00a0input\u00a0 wire clk, \u00a0\u00a0\u00a0\u00a0input\u00a0 wire reset, \u00a0\u00a0\u00a0\u00a0input\u00a0 wire d, \u00a0\u00a0\u00a0\u00a0output reg\u00a0 q ); \u00a0\u00a0\u00a0\u00a0always @(posedge clk) begin \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (reset) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0q &lt;= 1&#8217;b0; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0q &lt;= d; \u00a0\u00a0\u00a0\u00a0end endmodule Explanation: The output changes only on the rising clock edge. Reset is synchronous because it is checked inside the clocked process and does not independently trigger an update. Non-blocking assignment (&lt;=) is the standard choice for modeling sequential register updates. Interview follow-up: How would you implement an asynchronous reset? You would normally include the reset edge in the sensitivity list, such as negedge reset_n for an active-low reset, and define the reset branch accordingly. Common mistake: Confusing synchronous and asynchronous reset behavior. 3. Implement an Up Counter With Enable Problem: Design an 8-bit counter that increments on each rising clock edge when enable is high and resets to zero when synchronous reset is asserted. module up_counter ( \u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 clk, \u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 reset, \u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 enable, \u00a0\u00a0\u00a0\u00a0output reg [7:0]\u00a0 count ); \u00a0\u00a0\u00a0\u00a0always @(posedge clk) begin \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (reset) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count &lt;= 8&#8217;d0; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else if (enable) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count &lt;= count + 1&#8217;b1; \u00a0\u00a0\u00a0\u00a0end endmodule Explanation: Reset has priority over enable. When both are low, no assignment occurs to count, so the register retains its previous value. Because the counter is eight bits wide, it wraps from 255 to 0 under ordinary unsigned arithmetic. Interview follow-up: How would you create a counter that stops at 99? Add a terminal-count condition so the counter holds its value when it reaches the required limit. Be clear about whether the design should wrap, saturate, or restart at zero. Common mistake: Ignoring overflow behavior or failing to clarify the required counting range. 4. Write a Shift Register Problem: Create a four-bit serial-in, serial-out shift register. On every rising edge, shift the stored bits toward the most significant bit and insert serial_in into bit zero. module shift_register ( \u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 clk, \u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 reset, \u00a0\u00a0\u00a0\u00a0input\u00a0 wire \u00a0 \u00a0 \u00a0 serial_in, \u00a0\u00a0\u00a0\u00a0output reg [3:0]\u00a0 q ); \u00a0\u00a0\u00a0\u00a0always @(posedge clk) begin \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (reset) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0q &lt;= 4&#8217;b0000; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0q &lt;= {q[2:0], serial_in}; \u00a0\u00a0\u00a0\u00a0end endmodule Explanation: The concatenation {q[2:0], serial_in} constructs the next four-bit value. The previous bits move one position toward the most significant bit, and the new serial bit enters at the least significant position. Practical example: Shift registers are useful in serial data handling and in circuits that need to move data through a sequence of register stages. Interview follow-up: Add an enable input so shifting occurs only when enabled. The register should hold its value when enable is low. Common mistake: Reversing the shift direction or inserting the serial bit into the wrong position. 5. Design a Mod-10 Counter Problem: Design a counter that cycles through values 0 to 9 and then returns to zero. module mod10_counter ( \u00a0\u00a0\u00a0\u00a0input\u00a0 wire\u00a0 \u00a0 \u00a0 clk, \u00a0\u00a0\u00a0\u00a0input\u00a0 wire\u00a0 \u00a0 \u00a0 reset, \u00a0\u00a0\u00a0\u00a0output reg [3:0] count ); \u00a0\u00a0\u00a0\u00a0always @(posedge clk) begin \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (reset) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count &lt;= 4&#8217;d0; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else if (count == 4&#8217;d9) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count &lt;= 4&#8217;d0; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count &lt;= count + 1&#8217;b1; \u00a0\u00a0\u00a0\u00a0end endmodule Explanation: Four bits are sufficient to represent values 0 through 9. The terminal-count condition ensures that the counter returns to zero after reaching nine rather than continuing to 15. Interview follow-up: What happens if the counter starts in an illegal state such as 12? In this implementation, it increments normally until it wraps around. If recovery from illegal states is required, add an explicit recovery condition based on the specification. Common mistake: Using an incorrect terminal count or choosing a width without considering the required range. 6. Implement a Combinational ALU Problem: Design a simple 4-bit arithmetic logic unit that supports addition, subtraction, AND, and OR operations. module simple_alu ( \u00a0\u00a0\u00a0\u00a0input\u00a0 wire [3:0] a, \u00a0\u00a0\u00a0\u00a0input\u00a0 wire [3:0] b, \u00a0\u00a0\u00a0\u00a0input\u00a0 wire [1:0] op, \u00a0\u00a0\u00a0\u00a0output reg\u00a0 [3:0] y ); \u00a0\u00a0\u00a0\u00a0always @(*) begin \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0case (op) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02&#8217;b00: y = a + b; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02&#8217;b01: y = a &#8211; b; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02&#8217;b10: y = a &amp; b; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02&#8217;b11: y = a | b; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0default: y = 4&#8217;b0000; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0endcase \u00a0\u00a0\u00a0\u00a0end endmodule Explanation: The case statement selects the operation according to op. Since all possible two-bit values are covered, every valid operation has a defined assignment. The default assignment provides an explicit fallback. The output is four bits wide, so arithmetic results are truncated to four bits. If a carry-out is required, the<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[8],"tags":[],"class_list":["post-10344","post","type-post","status-publish","format-standard","hentry","category-vlsi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Verilog Coding Problems Every RTL Fresher Should Practice<\/title>\n<meta name=\"description\" content=\"Practise Verilog coding problems for RTL interviews, including muxes, counters, shift registers, FSMs, sequence detectors, and debugging examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/inskill.in\/training\/blog\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Verilog Coding Problems Every RTL Fresher Should Practice\" \/>\n<meta property=\"og:description\" content=\"Practise Verilog coding problems for RTL interviews, including muxes, counters, shift registers, FSMs, sequence detectors, and debugging examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/inskill.in\/training\/blog\/\" \/>\n<meta property=\"og:site_name\" content=\"Inskill VLSIGURU Elearning Platform\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-21T13:44:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-22T13:47:31+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/blog\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/blog\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/#\\\/schema\\\/person\\\/9abb65edd31606e6675ad9c153f2d42f\"},\"headline\":\"Verilog Coding Problems Every RTL Fresher Should Practice\",\"datePublished\":\"2026-10-21T13:44:13+00:00\",\"dateModified\":\"2026-10-22T13:47:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/blog\\\/\"},\"wordCount\":1777,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/#organization\"},\"articleSection\":[\"VLSI\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/inskill.in\\\/training\\\/blog\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/blog\\\/\",\"url\":\"https:\\\/\\\/inskill.in\\\/training\\\/blog\\\/\",\"name\":\"Verilog Coding Problems Every RTL Fresher Should Practice\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/#website\"},\"datePublished\":\"2026-10-21T13:44:13+00:00\",\"dateModified\":\"2026-10-22T13:47:31+00:00\",\"description\":\"Practise Verilog coding problems for RTL interviews, including muxes, counters, shift registers, FSMs, sequence detectors, and debugging examples.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/blog\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/inskill.in\\\/training\\\/blog\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/blog\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/inskill.in\\\/training\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Verilog Coding Problems Every RTL Fresher Should Practice\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/#website\",\"url\":\"https:\\\/\\\/inskill.in\\\/training\\\/\",\"name\":\"Inskill VLSIGURU Elearning Platform\",\"description\":\"Best VLSI Training Institute\",\"publisher\":{\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/inskill.in\\\/training\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/#organization\",\"name\":\"Inskill VLSIGURU Elearning Platform\",\"url\":\"https:\\\/\\\/inskill.in\\\/training\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/inskill.in\\\/training\\\/wp-content\\\/uploads\\\/2025\\\/01\\\/inskill-2.png\",\"contentUrl\":\"https:\\\/\\\/inskill.in\\\/training\\\/wp-content\\\/uploads\\\/2025\\\/01\\\/inskill-2.png\",\"width\":207,\"height\":89,\"caption\":\"Inskill VLSIGURU Elearning Platform\"},\"image\":{\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/inskill.in\\\/training\\\/#\\\/schema\\\/person\\\/9abb65edd31606e6675ad9c153f2d42f\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ae1b84b5e32e75453917297a43292af55fcc34a59a0d20dc5403287472a37c28?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ae1b84b5e32e75453917297a43292af55fcc34a59a0d20dc5403287472a37c28?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ae1b84b5e32e75453917297a43292af55fcc34a59a0d20dc5403287472a37c28?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/inskill.in\\\/training\"],\"url\":\"https:\\\/\\\/inskill.in\\\/training\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Verilog Coding Problems Every RTL Fresher Should Practice","description":"Practise Verilog coding problems for RTL interviews, including muxes, counters, shift registers, FSMs, sequence detectors, and debugging examples.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/inskill.in\/training\/blog\/","og_locale":"en_US","og_type":"article","og_title":"Verilog Coding Problems Every RTL Fresher Should Practice","og_description":"Practise Verilog coding problems for RTL interviews, including muxes, counters, shift registers, FSMs, sequence detectors, and debugging examples.","og_url":"https:\/\/inskill.in\/training\/blog\/","og_site_name":"Inskill VLSIGURU Elearning Platform","article_published_time":"2026-10-21T13:44:13+00:00","article_modified_time":"2026-10-22T13:47:31+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/inskill.in\/training\/blog\/#article","isPartOf":{"@id":"https:\/\/inskill.in\/training\/blog\/"},"author":{"name":"admin","@id":"https:\/\/inskill.in\/training\/#\/schema\/person\/9abb65edd31606e6675ad9c153f2d42f"},"headline":"Verilog Coding Problems Every RTL Fresher Should Practice","datePublished":"2026-10-21T13:44:13+00:00","dateModified":"2026-10-22T13:47:31+00:00","mainEntityOfPage":{"@id":"https:\/\/inskill.in\/training\/blog\/"},"wordCount":1777,"commentCount":0,"publisher":{"@id":"https:\/\/inskill.in\/training\/#organization"},"articleSection":["VLSI"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/inskill.in\/training\/blog\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/inskill.in\/training\/blog\/","url":"https:\/\/inskill.in\/training\/blog\/","name":"Verilog Coding Problems Every RTL Fresher Should Practice","isPartOf":{"@id":"https:\/\/inskill.in\/training\/#website"},"datePublished":"2026-10-21T13:44:13+00:00","dateModified":"2026-10-22T13:47:31+00:00","description":"Practise Verilog coding problems for RTL interviews, including muxes, counters, shift registers, FSMs, sequence detectors, and debugging examples.","breadcrumb":{"@id":"https:\/\/inskill.in\/training\/blog\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/inskill.in\/training\/blog\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/inskill.in\/training\/blog\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/inskill.in\/training\/"},{"@type":"ListItem","position":2,"name":"Verilog Coding Problems Every RTL Fresher Should Practice"}]},{"@type":"WebSite","@id":"https:\/\/inskill.in\/training\/#website","url":"https:\/\/inskill.in\/training\/","name":"Inskill VLSIGURU Elearning Platform","description":"Best VLSI Training Institute","publisher":{"@id":"https:\/\/inskill.in\/training\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/inskill.in\/training\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/inskill.in\/training\/#organization","name":"Inskill VLSIGURU Elearning Platform","url":"https:\/\/inskill.in\/training\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/inskill.in\/training\/#\/schema\/logo\/image\/","url":"https:\/\/inskill.in\/training\/wp-content\/uploads\/2025\/01\/inskill-2.png","contentUrl":"https:\/\/inskill.in\/training\/wp-content\/uploads\/2025\/01\/inskill-2.png","width":207,"height":89,"caption":"Inskill VLSIGURU Elearning Platform"},"image":{"@id":"https:\/\/inskill.in\/training\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/inskill.in\/training\/#\/schema\/person\/9abb65edd31606e6675ad9c153f2d42f","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ae1b84b5e32e75453917297a43292af55fcc34a59a0d20dc5403287472a37c28?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ae1b84b5e32e75453917297a43292af55fcc34a59a0d20dc5403287472a37c28?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ae1b84b5e32e75453917297a43292af55fcc34a59a0d20dc5403287472a37c28?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/inskill.in\/training"],"url":"https:\/\/inskill.in\/training\/author\/admin\/"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/inskill.in\/training\/wp-json\/wp\/v2\/posts\/10344","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/inskill.in\/training\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inskill.in\/training\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inskill.in\/training\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/inskill.in\/training\/wp-json\/wp\/v2\/comments?post=10344"}],"version-history":[{"count":4,"href":"https:\/\/inskill.in\/training\/wp-json\/wp\/v2\/posts\/10344\/revisions"}],"predecessor-version":[{"id":10350,"href":"https:\/\/inskill.in\/training\/wp-json\/wp\/v2\/posts\/10344\/revisions\/10350"}],"wp:attachment":[{"href":"https:\/\/inskill.in\/training\/wp-json\/wp\/v2\/media?parent=10344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inskill.in\/training\/wp-json\/wp\/v2\/categories?post=10344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inskill.in\/training\/wp-json\/wp\/v2\/tags?post=10344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}