Reputation: 33
It is async reset. D flipflop when i change reset from one to zero, it doesn't immediately raise the output from zero to one. but when i add in @always ( posedge clk or posedge reset or negedge reset ) it immediately change
module dff_async_reset (
data , // Data Input
clk , // Clock Input
reset , // Reset input
q // Q output
);
//-----------Input Ports---------------
input data, clk, reset ;
//-----------Output Ports---------------
output q;
//------------Internal Variables--------
reg q;
//-------------Code Starts Here---------
always @ ( posedge clk or posedge reset)
begin
if (reset)
q =0;
else
q <= data;
end
endmodule //End Of Module dff_async_reset
Upvotes: 1
Views: 1583
Reputation: 1
module dff(data, clk, reset, q
);
input data, clk, reset ;
output q;
reg q;
always @ ( posedge clk)
if (~reset) begin
q <= 1'b0;
end
else begin
q <= data;
end
endmodule
module registar_IME(input clk, reset, [7:0] in, output [7:0] q);
dff dff_1(.data(in[7]), .clk(clk), .reset(reset), .q(q[7]));
dff dff_2(.data(in[6]), .clk(clk), .reset(reset), .q(q[6]));
dff dff_3(.data(in[5]), .clk(clk), .reset(reset), .q(q[5]));
dff dff_4(.data(in[4]), .clk(clk), .reset(reset), .q(q[4]));
dff dff_5(.data(in[3]), .clk(clk), .reset(reset), .q(q[3]));
dff dff_6(.data(in[2]), .clk(clk), .reset(reset), .q(q[2]));
dff dff_7(.data(in[1]), .clk(clk), .reset(reset), .q(q[1]));
dff dff_8(.data(in[0]), .clk(clk), .reset(reset), .q(q[0]));
endmodule
module registar_PREZIME(input clk, reset, [7:0] in, output [7:0] q);
dff dff_1(.data(in[7]), .clk(clk), .reset(reset), .q(q[7]));
dff dff_2(.data(in[6]), .clk(clk), .reset(reset), .q(q[6]));
dff dff_3(.data(in[5]), .clk(clk), .reset(reset), .q(q[5]));
dff dff_4(.data(in[4]), .clk(clk), .reset(reset), .q(q[4]));
dff dff_5(.data(in[3]), .clk(clk), .reset(reset), .q(q[3]));
dff dff_6(.data(in[2]), .clk(clk), .reset(reset), .q(q[2]));
dff dff_7(.data(in[1]), .clk(clk), .reset(reset), .q(q[1]));
dff dff_8(.data(in[0]), .clk(clk), .reset(reset), .q(q[0]));
endmodule
module DRUGI_ZADATAK(input clk, reset, [7:0] in, output [7:0] q
);
registar_IME r_IME(.clk(clk), .reset(reset),
.in(KOPIRAJ_SVOJE_IZ_KOMENTARA), .q(prvi));//OBRISI KAD KOPIRAS poki
1'b1011010 vlada 1'b110111 sveta 1'b1000110
registar_PREZIME r_PREZIME(.clk(clk), .reset(reset), .in(1'b101101),
.q(drugi));
endmodule
Upvotes: -1
Reputation: 1
module PRVO_SLOVO_IMENA(output x,input a,b);
assign x=a&b;
endmodule
module DRUGO_SLOVO_IMENA(output x,input a,b);
assign x=a|b;
endmodule
module TRECE_SLOVO_IMENA(output x,input a,b);
assign x=a^b;
endmodule
module PREZIME(output y, input a,b,c,d);
reg mand,mxor;
TRECE_SLOVO_IMENA o1(.x(mxor),.a(a),.b(b));
PRVO_SLOVO_IMENA o2(.x(mand),.a(mxor),.b(c));
DRUGO_SLOVO_IMENA o3(.x(y),.a(mand),.b(d));
endmodule
Upvotes: -1
Reputation: 1181
It does exactly what you tell it to do: mimic a flip-flop with an asynchronous active-high reset. The following line from your code
always @ (posedge clk or posedge reset)
says: "execute this procedural block when clk
makes the transition 0 --> 1
or when reset
makes the transition 0 --> 1
." In other words, when reset
makes the transition 1 --> 0
, this always block will not be evaluated.
You value q
will only be updated on the positive edge of clk
, which is exactly what you want if you want to design a flip-flop.
When you add negedge reset
to your sensitivity list, it will indeed immediatelly change when you go out of your reset state (which is 1 --> 0
in your logic). This is, however, usually not desired. Rather, you should synchronize the deassertion of your reset to your clock signal. To quote from the aforementioned website:
The way most of the designs have been modelled needs asynchronous reset assertion and synchronous de-assertion. The requirement of most of the designs these days is:
- When reset is asserted, it propagates to all designs; brings them to reset state whether or not clock is toggling; i.e. assertion should be asynchronous
- When reset is deasserted, wait for a clock edge, and then, move the system to next state as per the FSM (Finite State Machine); i.e. deassertion should be synchronous
Upvotes: 3