# HDLBits Dff8ar

Create 8 D flip-flops with active high asynchronous reset. All DFFs should be triggered by the positive edge of clk.

Module Declaration

module top_module (
input clk,
input areset,   // active high asynchronous reset
input [7:0] d,
output [7:0] q
);


Hint

The only difference in code between synchronous and asynchronous reset flip-flops is in the sensitivity list.

module top_module (
input clk,
input areset,   // active high asynchronous reset
input [7:0] d,
output [7:0] q
);

always @(posedge clk or posedge areset) begin
if (~areset) q <= d;
else q <= 8'b0;
end
endmodule


cannot match operand(s) in the condition to the corresponding edges in the enclosing event control of the always construct File: ...


This is more likely an issue with your synthesizer then your simulator. The likely problem is that the first code does not match any of it's templates for a synchronous flip-flop with asynchronous reset.
The common coding practice is to assign your reset logic before any other logic. This coding practice has been around for decades. I assume the rational behind this particular coding practice stems from:

• Reset logic is critical from many designs; especially as designs get larger and more complex. It is put at the top for it importance and the fact that it usually fewer lines of code then the synchronous logic.
• Early synthesizers were very limited and could only synthesize specific code structures.
• The coding style has become a precedence. No one is going to change it unless you can convince and prove something else is superior or has specific advantages.

In your case, your synthesizer is doing a lint check and has determined your code is not following the conventional coding practices. The creator of your synthesizer has decided to only support the common coding structure and there is little incentive to change.
FYI: you should be assigning synchronous logic with non-blocking assignments (<=). Blocking assignments (=) should be used for combinatonal logic. If you do not follow proper coding practices you increase the risk of introducing race-conditions, RTL vs gate mismatch, and other bugs.

module top_module (
input clk,
input areset,   // active high asynchronous reset
input [7:0] d,
output [7:0] q
);

always @(posedge clk or posedge areset) begin
if (areset) q <= 8'b0;
else q <= d;
end
endmodule


by SDUST weilinfox

posted @ 2021-04-26 18:11  八衛門狸  阅读(80)  评论(0编辑  收藏  举报