Question

In: Electrical Engineering

Design a synchronous counter of four-bit using D flip‐flops and gates (AND, OR etc.) *use verilog...

Design a synchronous counter of four-bit using D flip‐flops and gates (AND, OR etc.)

*use verilog language modules and test and explain briefly

Solutions

Expert Solution

the following contains Verilog code:

truth table:

Verilog code:

module d_ff(d,q,qbar,clk);// the main element d_ff
  input d,clk;
  output reg q=1;
  output qbar;
  assign qbar=~q;
  always@(posedge clk)
    begin
      q=d;
      //qbar=~q;
    end
endmodule

module d_ff(d,q,qbar,clk);
input d,clk;
output reg q;
output qbar;
assign qbar=~q;
always@(posedge clk)
begin
q=d;
end
endmodule

module up_counter(q_out,clk);
input clk;
output reg [3:0] q_out;
wire w1,w2,w3,w4;
d_ff d11(~q_out[0],q_out[0],w1,clk);// instanciating the d_Ff made above in order to make the above diagram
d_ff d22((q_out[1]^q_out[0]),q_out[1],w2,clk);
d_ff d33((q_out[2]&~(q_out[0])+q_out[2]&~(q_out[1])+~(q_out[2])&q_out[1]&q_out[0]),q_out[2],w3,clk);
d_ff d44((q_out[3]&~(q_out[2])+q_out[3]&~(q_out[0])+q_out[3]&(~q_out[1])+~(q_out[3])&q_out[2]&q_out[1]&q_out[0]),q_out[3],w4,clk);
endmodule
  

testbench:

// Code your testbench here
// or browse Examples
module test();
reg clk;
wire [3:0] q_out;
up_counter u1(q_out,clk);
initial
begin
clk=0;
#100 $finish;
end
initial
forever
#2 clk=~clk;// clock generator
initial
$monitor("q_out=%b",q_out);
initial
begin
$dumpfile("dump.vcd");// creating varible dump file for waveform viewing
$dumpvars(1);
end
endmodule

  


  


Related Solutions

Design a counter using JK Flip Flops and Gates, that counts 3,1,4,2,9,2,2,4 using a Moore Machine....
Design a counter using JK Flip Flops and Gates, that counts 3,1,4,2,9,2,2,4 using a Moore Machine. Show Moore machine state diagram, state table and cirucit.
Design a 5-bit binary counter using JK flip flops. Draw the flip-flop circuit diagram, the state...
Design a 5-bit binary counter using JK flip flops. Draw the flip-flop circuit diagram, the state graph, the timing diagram, the truth table (with clk pulse) and the state table (with present and next states).
Design a synchronous counter, using T flip-flops, that has the following sequence: 0010, 0110, 1000, 1001,...
Design a synchronous counter, using T flip-flops, that has the following sequence: 0010, 0110, 1000, 1001, 1100, 1101, and repeat. From the undesired states the counter must always go to 0010 on the next clock pulse.
(a) Design a 4-bit ring counter. Use an external asynchronous INIT input to initialize the flip-flops...
(a) Design a 4-bit ring counter. Use an external asynchronous INIT input to initialize the flip-flops to a valid initial state. Also remember to hook up the CLOCK to all flip-flops. (b) Design a 4-bit Johnson counter. Use an external asynchronous INIT input to initialize the flip-flops to a valid initial state. Also remember to hook up the CLOCK to all flip-flops. (c) How many states does the ring counter in part (a) have? How many states does the Johnson...
What is a ripple counter? How is it constructed using D flip-flops?
What is a ripple counter? How is it constructed using D flip-flops?
1. (20pts) Design a 3-bit counter that counts from 0000 to 1111 using JK flip/flops. Do...
1. (20pts) Design a 3-bit counter that counts from 0000 to 1111 using JK flip/flops. Do not forget to include the carry to detect overflow.
Design an up/down counter with four states (0, 1, 2, 3) using clocked JK flip flops....
Design an up/down counter with four states (0, 1, 2, 3) using clocked JK flip flops. A control signal x is used as follows: When x = 0 the machine counts forward (up), when x = 1, backward (down). Simulate using MultiSim and attach a simulation printout. Please address the following: State Table State Diagram Flip Flop Excitation Tables K-Map Simplification and Resulting Diagram MultiSim Simulation
Design a Count-up Counter in Aiken code with following flip flops: a) D-FF (Active edge is...
Design a Count-up Counter in Aiken code with following flip flops: a) D-FF (Active edge is high to low) b) SR-FF (Active edge is high to low) c) Use of output of circuit in part (b) and minimum number of logic gates for getting the Countdown counter in Aiken code
Design a synchronously settable flip-flop using a regular D flip-flop and additional gates.
Design a synchronously settable flip-flop using a regular D flip-flop and additional gates.
Using Multisim, design a 2-bit, synchronous binary counter and verify that it counts in the right...
Using Multisim, design a 2-bit, synchronous binary counter and verify that it counts in the right sequence, Can count up or down and use any FF you desire; 4 screen shots in total: 1 for each input combination
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT