Truth tables

module top_module( 
    input x3,
    input x2,
    input x1,  // three inputs
    output f   // one output
);
assign f = ( ~x3 & x2 & ~x1 ) | ( ~x3 & x2 & x1 ) | ( x3 & ~x2 & x1 ) | ( x3 & x2 & x1 );


endmodule

根据SoP方法,对于每一行输出为1的情况,我们需要构建一个 AND 门的条件(即该行对应的输入组合为真),然后用 OR 门将这些条件组合起来。