// latch_bad.sv // WRONG ON PURPOSE: zero is not assigned in every branch and nothing is // assigned when mode == 3, so synthesis infers latches to hold the old values. // // The lint_off comments below hide Verilator's LATCH and CASEINCOMPLETE // warnings for this file. Delete them and lint again to see the warnings. /* verilator lint_off LATCH */ /* verilator lint_off CASEINCOMPLETE */ module latch_bad ( input logic [1:0] mode, input logic [7:0] a, input logic [7:0] b, output logic [7:0] y, output logic zero ); always_comb begin case (mode) 2'd0: begin y = a; zero = (a == 8'd0); end 2'd1: y = b; // zero not assigned 2'd2: y = a & b; // zero not assigned endcase // mode 3: nothing assigned end endmodule