//----------------------------------------------------------------------
// IAS0150 - Homework #2. Example task - into gates, step #1.
//----------------------------------------------------------------------
// (C) Peeter Ellervee - 2026 - Tallinn
//----------------------------------------------------------------------
module fs_opti (input x1, x2, x3, x4, output y1, y2, y3, y4);
  logic t1, t2, t3, t4, t5, t6, t7, t8, t9, t19, t68;

//assign t1 = (!x1) & x2 & (!x3) & x4;
  assign t1 = t4 & (!x1) & (!x3);
  assign t2 = x1 & x3 & x4;
  assign t3 = x2 & (!x3) & (!x4);
  assign t4 = x2 & x4;
  assign t5 = (!x2) & x3;
//assign t6 = (!x1) & x3 & (!x4);
  assign t6 = t7 & x3;
  assign t7 = (!x1) & (!x4);
  assign t8 = x1 & (!x2) & (!x4);
  assign t9 = x1 & x3;

  assign t19 = t1 | t9;
  assign t68 = t6 | t8;

//assign y1 = t1 | t3 | t7 | t9;
  assign y1 = t19 | t3 | t7;
//assign y2 = !(t1 | t8 | t9);
  assign y2 = !(t19 | t8);
//assign y3 = t3 | t4 | t6 | t8;
  assign y3 = t3 | t4 | t68;
//assign y4 = t2 | t5 | t6 | t8;
  assign y4 = t2 | t5 | t68;

endmodule
