具有 2 个复位的 D 型触发器:综合错误
D-flip flop with 2 reset: synthesis error
我正在对一个数字块进行综合,我需要一个具有 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 中编写异步复位、设置(清除)flip-flop 的标准方法是:
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;
另外,对于更简洁的代码,新的 header 类型更简洁并且避免了重复:
module dff_2rst(
input clk,
input d,
input rst,
input clear,
output reg q,
output qn );
谢谢摩根。你的代码对我很有启发。我无法使用
assign qn=~q;
因为我得到了错误:
qn is not a valid left-hand side of a continuous assignment.
但我按以下方式修改了您的代码并且它起作用了:
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
if (rst) begin
// Aysnc Reset
q <= 'b0 ;
qn<= 'b1 ;
end
else if (clear) begin
// Async Clear
q <= 'b0 ;
qn<= 'b1 ;
end
else begin
// Sync logic here
q <= d;
qn<= ~d;
end
end
endmodule
我正在对一个数字块进行综合,我需要一个具有 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 中编写异步复位、设置(清除)flip-flop 的标准方法是:
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;
另外,对于更简洁的代码,新的 header 类型更简洁并且避免了重复:
module dff_2rst(
input clk,
input d,
input rst,
input clear,
output reg q,
output qn );
谢谢摩根。你的代码对我很有启发。我无法使用
assign qn=~q;
因为我得到了错误:
qn is not a valid left-hand side of a continuous assignment.
但我按以下方式修改了您的代码并且它起作用了:
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
if (rst) begin
// Aysnc Reset
q <= 'b0 ;
qn<= 'b1 ;
end
else if (clear) begin
// Async Clear
q <= 'b0 ;
qn<= 'b1 ;
end
else begin
// Sync logic here
q <= d;
qn<= ~d;
end
end
endmodule