Вы находитесь на странице: 1из 5

D FLIP FLOP

`timescale 1ns / 1ps


//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: Prachi Sharma
//
// Create Date: 22:44:58 10/02/2016
// Design Name:
// Module Name: dflipflop
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module dflipflop(
input d,
input clk,
input rst,
output reg q,
output reg qn
);

always @(posedge clk or negedge rst)


begin
if (rst == 1'b0)
begin
q <= 0;
qn <= 1;
end
else
begin
q <= d;
qn <= !d;
end
end

endmodule
JK FLIP FLOP

`timescale 1ns / 1ps


//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 00:12:16 10/03/2016
// Design Name:
// Module Name: jkflipflop
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module jkflipflop(
input J, K, clk, rst,
output reg q, qn
);

always @(posedge clk or poedge rst)


begin
if (rst)
begin
q <= 1'b0; qn <= 1'b1;
end
else begin
case ({J,K})
{2'b00}: begin q <= q; qn <= qn; end
{2'b01}: begin q <= 1'b0; qn <= 1'b1; end
{2'b10}: begin q <= 1'b1; qn <= 1'b0; end
{2'b11}: begin q <= (~q); qn <= (~qn); end
endcase
end
end
endmodule
T Flip Flop

`timescale 1ns / 1ps


//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: Prachi Sharma
//
// Create Date: 00:54:49 10/04/2016
// Design Name:
// Module Name: tflipflop
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module tflipflop(
input t, clk, rst,
output reg q, qn
);

always @(posedge clk or negedge rst)


begin
if (rst == 1'b0)
begin
q <= 0;
qn <= 1;
end
else
begin
case ({t})
{1'b0}: begin q <= q; qn <= qn; end
{1'b1}: begin q <= (~q); qn <= (~qn); end
endcase
end
end

endmodule
4-bit Ring Counter

`timescale 1ns / 1ps


//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: Prachi Sharma
//
// Create Date: 01:58:10 10/04/2016
// Design Name:
// Module Name: ring2
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
/////////////////////////////////////////////////////////////////////////////////
module ring2 (
input clk,
input rst,
output reg [3:0] q
);

always @(posedge clk or posedge rst)


if (rst)
q <= 4'b0001;

else
begin
q[3] <= q[0];
q[2] <= q[3];
q[1] <= q[2];
q[0] <= q[1];
end

endmodule
4-bit Twisted Ring Counter
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: Prachi Sharma
//
// Create Date: 02:28:00 10/04/2016
// Design Name:
// Module Name: twist
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module twist(
input rst, clk,
output reg [3:0] q
);

always @(posedge clk or posedge rst)


if (rst)
q <= 4'b0000;

else
begin
q[3] <= !q[0];
q[2] <= q[3];
q[1] <= q[2];
q[0] <= q[1];
end

endmodule

Вам также может понравиться