Ниже приведен код с синхронной и асинхронной перезагрузкой.
//Synchronous Reset
module test(clk,d,rst,a);
input clk,d,rst;
output reg a;
always @(posedge clk) //This clock makes the reset synchronized to a clock signal.
begin
if(rst)
a <= 1'b0;
else
a <= 1'b1; // assigned to a constant
end
endmodule
//Asynchronous
module test(clk,d,rst,a);
input clk,d,rst;
output reg a;
always @* //No clock to synchronize with.
begin //Reset signal will drive anytime a input value changes
if(rst)
a <= 1'b0;
else
a <= 1'b1; // assigned to a constant
end
endmodule