//----------------------------------------------------------------------
// IAS0150 - Homework #2. Example task - gates, optimized.
//----------------------------------------------------------------------
// (C) Peeter Ellervee - 2026 - Tallinn
//----------------------------------------------------------------------
`timescale 1 ns / 100 ps
module fs_opti (input x1, x2, x3, x4, output y1, y2, y3, y4);
  logic x2i, t1i, t2i, t3x, t3i, t4i, t5i, t6;
  logic t7, t8x, t8, t68i, t9i, t19, t197i;

  assign #1.0 x2i = !(x2 & x2);

  assign #2.5 t1i = t4i | x1 | x3;
  assign #1.5 t2i = !(x1 & x3 & x4);
  assign #1.5 t3x = !(x3 | x4);
  assign #1.0 t3i = !(x2  & t3x);
  assign #1.0 t4i = !(x2 & x4);
  assign #1.0 t5i = !(x2i & x3);
  assign #2.0 t6  = t7  & x3;
  assign #1.5 t7  = !(x1 | x4);
  assign #1.5 t8x = !(x2 | x4);
  assign #2.0 t8  = x1 & t8x;
  assign #1.5 t68i = !(t6 | t8);
  assign #1.0 t9i  = !(x1 & x3);
  assign #1.0 t19  = !(t1i & t9i);
  assign #1.5 t197i = !(t19 | t7);

  assign #1.0 y1 = !(t197i & t3i);
  assign #1.5 y2 = !(t19 | t8);
  assign #1.5 y3 = !(t3i & t4i & t68i);
  assign #1.5 y4 = !(t2i & t5i & t68i);

endmodule
