新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 異步與同步清零Verilog hdl表達(dá)程序

異步與同步清零Verilog hdl表達(dá)程序

作者: 時(shí)間:2016-12-01 來源:網(wǎng)絡(luò) 收藏
異步清0、異步置1 的D 觸發(fā)器
module DFF1(q,qn,d,clk,set,reset);
input d,clk,set,reset;
output q,qn;
reg q,qn;
always @(posedge clk or negedge set or negedge reset)
begin
if (!reset) begin
q <= 0; //異步清0,低電平有效
qn <= 1;
end
else if (!set) begin
q <= 1; //異步置1,低電平有效
qn <= 0;
end
else begin
q <= d;
qn <= ~d;
end
end
endmodule

帶同步清0、同步置1 的D觸發(fā)器
module DFF2(q,qn,d,clk,set,reset);
input d,clk,set,reset;
output q,qn;
reg q,qn;
always @(posedge clk)
begin
if (reset) begin
q <= 0; qn <= 1; //同步清0,高電平有效
end
else if (set) begin
q <=1; qn <=0; //同步置1,高電平有效
end
else begin
q <= d; qn <= ~d;
end
end
endmodule

異步清零:
always@(posedge clk or negedge rst )
begin
if(!rst) out <= 0;
else
begin ·················································
end
end

同步清零
always@(posedgeclk)
begin
if(!rst) out <= 0;
else
begin ·················································
end
end


關(guān)鍵詞: 異步同步清零Veriloghd

評(píng)論


技術(shù)專區(qū)

關(guān)閉