Question

Design an up-down counter in Verilog such that the digital system counts up to the desired...

Design an up-down counter in Verilog such that the digital system counts up to the desired number. Then, it counts downward to zero. When the count value reaches zero, the output should be logic level 1. Write in verilog please.

Homework Answers

Answer #1

module up_down_counter(input clk, reset,up_down, output[3:0] counter

);

reg [3:0] counter_up_down;

// down counter

always @(posedge clk or posedge reset)

begin

if(reset)

counter_up_down <= 4'h0;

else if(~up_down)

counter_up_down <= counter_up_down + 4'd1;

else

counter_up_down <= counter_up_down - 4'd1;

end

assign counter = counter_up_down;

endmodule

// Testbench Verilog code for up-down counter

module updowncounter_testbench();

reg clk, reset,up_down;

wire [3:0] counter;

up_down_counter dut(clk, reset,up_down, counter);

initial begin

clk=0;

forever #5 clk=~clk;

end

initial begin

reset=1;

up_down=0;

#20;

reset=0;

#200;

up_down=1;

end

endmodule

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Design 2 bits counter that count down by using T flip flop when input x =1...
Design 2 bits counter that count down by using T flip flop when input x =1 and counts up when x=0. Find the following 1. Derive the state table 2. Derive the K‐map simplifications. 3. Draw the logic diagram
Use JK Flip Flop to design a 2-bit synchronous counter (up counter) that counts down as...
Use JK Flip Flop to design a 2-bit synchronous counter (up counter) that counts down as given: AB = 01, 11, 00, 10, and then again 01. Show the design steps (e.g state table, j and k inputs for k-maps etc) and draw the final circuit.
Design a synchronous up/down 2-bit counter. The circuit has a single input (X), when X=1, the...
Design a synchronous up/down 2-bit counter. The circuit has a single input (X), when X=1, the counter counts up (i.e. 0,1,2,3,0,1.....), when X=0, the counter counts down (i.e. 3,2,1,0,3,2,....). Show work, including a next-state table and circuit diagram.
digital logic A digital circuit consists of four inputs and two outputs. One of the outputs...
digital logic A digital circuit consists of four inputs and two outputs. One of the outputs takes the value logical one "only when there is a majority of inputs to one". The other output is activated only if there is equal number of inputs to one "than to zero". a) Write the truth table. b) Draw the necessary digital circuit with logic gates. ----------------------------------------------------------------------------- A drip irrigation system has three sensors that measure different physical parameters. A Sensor H measures...
Design a counter which counts in the sequence that has been assigned to you. Use D...
Design a counter which counts in the sequence that has been assigned to you. Use D flip flops and NAND gates. Simulate your design using SimUaid. Submit the state table, D flip-flop input equations, and transition graph determined in Part 6. The D flip-flop equations can be derived using Karnaugh maps or using LogicAid by entering a state table with zero input variables. Sequence: 000,100,001,110,101,111,(repeat) 000,... Also, please answer the following questions: How can a D flip-flop be set to...
We wish to design a digital system with two flip-flops, say B and C, and one...
We wish to design a digital system with two flip-flops, say B and C, and one 10 bit binary Counter A, in which the individual flip-flops are denoted by A10, A9, A8, A7, A6, A5, A4, A3, A2, A1. A start signal S initiates the system operation by clearing the counter A and flip-flop C, and setting flip-flop B to one. The counter is then incremented by one starting from the next clock pulse and continues to increment until the...
Using Quartus II and the DE2 board, design and demonstrate a 3-bit up-counter; use D flip...
Using Quartus II and the DE2 board, design and demonstrate a 3-bit up-counter; use D flip flops for this project. Use one of the debounce switches for a clock and 3 LEDs to indicate the count. Implementing PRE and CLR will improve your design. 1. Please hand in a schematic and functional and timing simulation of your circuit.
Design a circuit for a synchronous 4-bit counter. Your counter should count up starting from 0...
Design a circuit for a synchronous 4-bit counter. Your counter should count up starting from 0 to 9 (00002 to 10012) and then wind back to 0 (00002) – after 9, it should go back to 0. Use 4 JK flip-flops and any other gates you need. Include your design documentation in your submission: a. Truth table b. Simplification (show your work) 2. Build this circuit in Logisim. Please label each gate, including flip-flops. You may need the following wiring...
Using the programing language of Verilog I attempted to make a counter to count from 0...
Using the programing language of Verilog I attempted to make a counter to count from 0 to 9 then loop back to 0 using the internal clock of the FPGA cyclone IV from altera. the code is posted at the bottom counts from 0 to 1 then loop back to 0 instead of counting up to 9. Can someone help me spot the error so it can count up to 9 module Encryption(SW, CLOCK_50, OUT, HEX0); input[1:0]SW; input CLOCK_50; output...
Using T-Flip-flops, design a 3-bit register/counter circuit with bits [A2 A1 A0]. The circuit operations are...
Using T-Flip-flops, design a 3-bit register/counter circuit with bits [A2 A1 A0]. The circuit operations are described in the following table. Show all design details, i.e., write down steps and equations and draw the detailed circuit diagram. S2 S1 S0 Operation 0 0 0 No change 0 0 1 Rotate left 0 1 0 Rotate right 0 1 1 Reset 1 0 0 Set 1 0 1 Count down 1 1 0 Count up 1 1 1 Load external bits...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT