module my_piporeg (q,qbar,d,clk,reset);
output [0 : 3]q,qbar;
input [0 : 3] d;
input clk,reset;
my_dff pipo0
(q[0],qbar[0],d[0],clk,reset);
my_dff pipo1
(q[1],qbar[1],d[1],clk,reset);
my_dff pipo2
(q[2],qbar[2],d[2],clk,reset);
my_dff pipo3
(q[3],qbar[3],d[3],clk,reset);
endmodule
module my_dff:
module my_dff (q,qbar,d,clk,reset);
output q,qbar;
input d,clk,reset;
reg temp0,temp1,temp2,temp3,q,qbar;
always @ (posedge clk or reset )
begin
if (reset)
begin
assign temp0 = !(temp3 &&
temp1);
assign temp1 = !(temp0 && ~clk);
assign temp2 = !(temp1 && ~clk
&& temp3);
assign temp3 = ! (temp2 && d);
assign q = !(temp1 && qbar);
assign qbar = !(temp2 && q);
end
else
begin
deassign q;
deassign qbar;
q = 1'b0;
qbar = 1'b1;
end
end
endmodule
CIRCUIT
DIAGRAM
OUTPUT
WAVEFORM
No comments:
Post a Comment