Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

else branch elided in generated Verilog #274

Description

@McSherry

I have the following in a Migen module:

self.comb += [
    # Always valid
    self.tx.tvalid_i.eq(1),

    # Throw away receiver data
    self.rx.tready_i.eq(1),

    # Clear an error if one occurs
    self.rx.error_clear_i.eq(self.rx.error_o),

    # If we get input from our RTIO interface and our receiver is locked, write
    # it to the transmitter. Otherwise, just continually write /IDLE/.
    If(self.rtlink.o.stb & self.rx.lock_o,
        # D-code if address is 0xDC, else K-code
        If(self.rtlink.o.address == 0xDC, self.tx.tid_i.eq(0)
        ).Else(self.tx.tid_i.eq(1)),

        # Connect RTIO data directly to transmitter
        self.tx.tdata_i.eq(self.rtlink.o.data),
    ).Else(
        self.tx.tid_i.eq(1),
        self.tx.tdata_i.eq(0b0010_0010)
    ),
]

The important part is the If at the bottom. All the inputs to self.rx and self.tx are registered within those modules.

When translated to Verilog, this module produces the following output:

always @(*) begin
	ustransmitter_tid_i <= 1'd0;
	ustransmitter_tdata_i <= 8'd0;
	if ((ointerface_stb & usreceiver_lock_o)) begin
		if ((ointerface_address == 8'd220)) begin
			ustransmitter_tid_i <= 1'd0;
		end else begin
			ustransmitter_tid_i <= 1'd1;
		end
		ustransmitter_tdata_i <= ointerface_data;
	end else begin
		ustransmitter_tdata_i <= 6'd34;
	end
// synthesis translate_off
	dummy_d_84 <= dummy_s;
// synthesis translate_on
end

This is wrong—the assignment self.tx.tid_i.eq(1) in the .Else() has been elided, which produces different behaviour (self.tx.tid_i now has the value '0 when there is no RTIO input instead of 1'b1). I'm also suspicious of the generated Verilog using the nonblocking assignment when it should be combinatorial.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions