/* From bbavett: file `/home/bbavett/cs355/pj5/clock.h' as assignment pj5 */
Define Four-Phase-Clock Reset Tick | Phase[1..4];
  Not aa Reset nReset;
  Dff aa nReset D1 Tick ONE Q1 nQ1;
  Dff aa nReset D2 Tick ONE Q2 nQ2;
  And aa nQ1 nQ2 S00;
  And aa nQ1 Q2 S01;
  And aa Q1 nQ2 S10;
  And aa Q1 Q2 S11;
  Or aa S01 S10 D1;
  Or aa S00 S10 D2;
  Decoder2x4 aa Q1 Q2 | Phase[1] Phase[4..2];
Endef;

Define Eight-bit-inc a[7..0] | out[7..0];
  Full_Adder aa ZERO a[0] ONE | c[0] out[0];
  Full_Adder aa c[0] a[1] ZERO | c[1] out[1];
  Full_Adder aa c[1] a[2] ZERO | c[2] out[2];
  Full_Adder aa c[2] a[3] ZERO | c[3] out[3];
  Full_Adder aa c[3] a[4] ZERO | c[4] out[4];
  Full_Adder aa c[4] a[5] ZERO | c[5] out[5];
  Full_Adder aa c[5] a[6] ZERO | c[6] out[6];
  Full_Adder aa c[6] a[7] ZERO | c[7] out[7];
Endef;

Define MPC-With-Reset Reset Tick | MPC[7..0];
  Not aa Reset nReset;
  Dff aa ONE d[0] Tick nReset MPC[0] nMPC[0];
  Dff aa ONE d[1] Tick nReset MPC[1] nMPC[1];
  Dff aa ONE d[2] Tick nReset MPC[2] nMPC[2];
  Dff aa ONE d[3] Tick nReset MPC[3] nMPC[3];
  Dff aa ONE d[4] Tick nReset MPC[4] nMPC[4];
  Dff aa ONE d[5] Tick nReset MPC[5] nMPC[5];
  Dff aa ONE d[6] Tick nReset MPC[6] nMPC[6];
  Dff aa ONE d[7] Tick nReset MPC[7] nMPC[7];
  Eight-bit-inc aa MPC[7..0] | d[7..0];
Endef;