Skip to content

Optimize out self-assignment from DFF reset patterns #87

@georgerennie

Description

@georgerennie

Consider the below where a DFF is unassigned at reset only under some parameters. yosys-slang currently converts this to an $aldff with an asynchronous load of q, which introduces an error in check as there is a comb loop from Q to AD. Yosys proc_dff optimizes out asynchronous self assignment conditions from DFFs so creates a $dff here, and I think yosys-slang also does this on some other patterns (e.g. if q is unconditionally assigned itself in the reset branch) but it would be good to be able to handle these more general patterns

module top #(
	parameter bit RST_Q = 0
) (
	input logic clk,
	input logic rst,
	input logic d,
	output logic q
);

always_ff @(posedge clk or posedge rst) begin
	if (rst) begin
		if (RST_Q)
			q <= '0;
	end else begin
		q <= d;
	end
end

endmodule

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions