我正在合成一个数字模块,我需要一个具有2个异步复位的D型触发器。(原因是我将使用可用时钟来驱动一次复位,而我将使用第二次复位来复位数字模块的所有寄存器)我准备了以下代码:
module dff_2rst(q,qn,clk,d, rst,clear);
input clk,d, rst, clear ;
output q,qn;
reg q,qn;
always @(posedge clk or posedge rst or posedge clear) //asynchronous reset
begin
(* full_case, parallel_case *)
case({rst, clear})
2'b00: begin
q <= d;
qn<=~d;
end
default: begin
q <= 1'b0;
qn <=1'b1;
end
endcase
end
endmodule
但我收到以下错误:
The statements in this 'always' block are outside the scope of the synthesis policy. Only an 'if' statement is allowed at the top level in this always block. (ELAB-302)
*** Presto compilation terminated with 1 errors. ***
我也尝试过
if(~rst & ~clear)
但我也有错误
您有更正我代码的想法吗?非常感谢!
在Verilog RTL中编写异步复位,设置(清除)触发器的标准方法是:
always @(posedge clk or posedge rst or posedge clear) begin
if (rst) begin
// Aysnc Reset
q <= 'b0 ;
end
else if (clear) begin
// Async Clear
q <= 'b0 ;
end
else begin
// Sync logic here
q <= d;
end
end
assign qn = ~n;
qn的小技巧要求qn是导线,当前定义为reg。reg q,qn;
应该只是reg q;
同样对于更干净的代码,新的标头类型也更干净,并且避免重复:
module dff_2rst(
input clk,
input d,
input rst,
input clear,
output reg q,
output qn );
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句