设计要求在时钟上升沿的特定情况下激活信号,并在时钟下降沿的另一种情况下停用信号。这是我的想法:
always@(posedge CLK) begin
signal1 <= 1'b0; // reset flag
if(circumstance1) signal1 <=1'b1; // raise flag if circumstance occurs
end
always@(negedge CLK) begin
signal2 <= 1'b1; // reset flag (actually set alternate to signal1)
if(circumstance2) signal2 <=1'b0; // raise flag if circumstance occurs
end
always@(posedge signal1 or negedge signal2) begin
if(signal1) outsignal <= 1'b0; // activate outsignal
else outsignal <= 1'n1; // deactivate outsignal
end
那会奏效吗?是否有更好的选择(加倍时钟和捕捉单边不是这里的选择)。
在罗素的回复后进行编辑。罗素,我认为您提出以下建议:
wire nCLK = ~CLK;
always@(posedge CLK or posedge nCLK or negedge nRESET) begin
if(!nRESET) outsignal <= 1'b0;
else if(nCLK) outsignal <= 1'b1;
else outsignal <= 1'b0;
end
我理解正确吗?