Saturday 22 January 2022

Verilog code for D Flipflop

 


Gate Level Modelling

module dflipflop(q,qbar,d,clk);

input d, clk;

output reg q,qbar;

wire x,y,z;

not g1(x,d);

nand g2(y, d, clk);

nand g3(z,x,clk);

nand g4(q,y,qbar);

nand g5(qbar, z, q);

endmodule


Behavioral Level Modelling

module dflipflop(q,qbar,d,clk);

input d, clk;

output reg q,qbar;

always@(posedge clk)

begin

case({d})

1'b0: begin q<=0; qbar <= 1; end

1'b1: begin q<=1; qbar <= 0; end

endcase

end

endmodule

No comments:

Post a Comment

Verilog Code for Universal Shift Register

  Universal Shift Register module universalshift (clr,clk,sel,in,out); input clr,clk; input [1:0]sel; input [3:0]parin; output reg[3:0]out; ...