Knowee
Questions
Features
Study Tools

Write a Verilog Code for 4 Bit Counter and the Counter should Reset at 1110

Question

Write a Verilog Code for 4 Bit Counter and the Counter should Reset at 1110

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple Verilog code for a 4-bit counter that resets at the binary number 1110 (decimal 14).

module counter (
    input wire clk,
    input wire reset,
    output wire [3:0] out
);

reg [3:0] count;

always @(posedge clk or posedge reset) begin
    if (reset) begin
        count <= 4'b0000; // Reset the counter
    end else if (count == 4'b1110) begin
        count <= 4'b0000; // Reset the counter when it reaches 1110
    end else begin
        count <= count + 1; // Otherwise, increment the counter
    end
end

assign out = count;

endmodule

This code defines a 4-bit counter that increments on every rising edge of the clock signal. If the reset signal is high or the counter value reaches 1110, the counter is reset to 0000. The current counter value is always output on the out wire.

This problem has been solved

Similar Questions

Using low-level verilog (no addition operations allowed), how many different assignment statements are needed to count the number of ones in a 4-bit binary number? Your answer should be an integer with no spaces or punctuation.

Design a four-bit binary synchronous countdown counter with JK flip-flops.

How many flip-flops are required to build a 4-bit binary counter?a. 1b. 2c. 4

A 4 bit binary counter has reached the state 1001. What is the output after a further 7 clock cycles in binary. Answer with just 4 characters (eg 1010)

How will the number -8’d4 (in Verilog) be internally represented as bits?

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.