/* --- help-DataPath --- Cheung ----------------- */

#include "basic.h"
#include "mir1"

/* -------------- **** You provide these files **** -------------- */
#include "clock.h"
#include "datapath.h"
/* -------------- **** You provide these files **** -------------- */

Probe "Ph1" gw Phase[1];
Probe "Ph2" gx Phase[2];
Probe "Ph3" gy Phase[3];
Probe "Ph4" gz Phase[4];
Four-Phase-Clock hw-hz Reset Tick | Phase[1..4];

Switch "0:RS" kz Reset ONE;

Switch "1:T" iz Tick ZERO;


/* ----
   Switches to select a micro-instruction from the MIR ROM
   ---- */
Switch "2:A5" ct Addr[5] ZERO;
Switch "3:A4" ct Addr[4] ZERO;
Switch "4:A3" dt Addr[3] ZERO;
Switch "5:A2" dt Addr[2] ZERO;
Switch "6:A1" et Addr[1] ZERO;
Switch "7:A0" et Addr[0] ZERO;

/* MIR (it's a ROM in this project, will change to RAM later project) */
MIR du-dy Addr[5..0] | mir[31..0];

Probe "AMUX" ao mir[31];
Probe "CD" ap.aa mir[30];
Probe "CD" ap.ab mir[29];
Probe "AL" aq.aa mir[28];
Probe "AL" aq.ab mir[27];
Probe "SH" ar.aa mir[26];
Probe "SH" ar.ab mir[25];
Probe "MB" as.aa mir[24];
Probe "MA" as.ab mir[23];
Probe "WR" at.aa mir[22];
Probe "RD" at.ab mir[21];
Probe "ENC" au.aa mir[20];
Probe "C" av.aa mir[19];
Probe "C" av.ab mir[18];
Probe "C" aw.aa mir[17];
Probe "C" aw.ab mir[16];
Probe "B" br.aa mir[15];
Probe "B" br.ab mir[14];
Probe "B" bs.aa mir[13];
Probe "B" bs.ab mir[12];
Probe "A" bt.aa mir[11];
Probe "A" bt.ab mir[10];
Probe "A" bu.aa mir[9];
Probe "A" bu.ab mir[8];
Probe "NA" bv.aa mir[7];
Probe "NA" bv.ab mir[6];
Probe "NA" bw.aa mir[7];
Probe "NA" bw.ab mir[6];
Probe "NA" bx.aa mir[5];
Probe "NA" bx.ab mir[4];
Probe "NA" by.aa mir[3];
Probe "NA" by.ab mir[2];
Probe "NA" bz.aa mir[1];
Probe "NA" bz.ab mir[0];


/* --
   Dummy MBR input to DataPath
   -- */
Define MBR | MBR-out[15-0];
   Or aa ONE MBR-out[15]; Or aa ONE MBR-out[14];
   Or aa ZERO MBR-out[13]; Or aa ZERO MBR-out[12];
   Or aa ONE MBR-out[11]; Or aa ONE MBR-out[10];
   Or aa ZERO MBR-out[9]; Or aa ZERO MBR-out[8];
   Or aa ONE MBR-out[7]; Or aa ONE MBR-out[6];
   Or aa ZERO MBR-out[5]; Or aa ZERO MBR-out[4];
   Or aa ONE MBR-out[3]; Or aa ONE MBR-out[2];
   Or aa ZERO MBR-out[1]; Or aa ZERO MBR-out[0];
Endef;

MBR la-lf | mbr[15-0];

Byte-probe-h "MBR" ka-kc mbr[15-8];
Byte-probe-h "MBR" kd-kf mbr[7-0];



/* DataPath */
DataPath fp-hr mir[31..0] mbr[15-0] Phase [1-4] Reset | 
	R0[15..0] R1[15..0] R2[15..0] R3[15..0] R4[15..0] R5[15..0] 
	R6[15..0] R7[15..0] R8[15..0] R9[15..0] R10[15..0] R11[15..0]
	R12[15..0] R13[15..0] R14[15..0] R15[15..0]
	ABus[15-0] BBus[15-0] A[15-0] B[15-0] AMUX[15-0] 
	ALU[15-0] C[15-0] N Z;


/* ---
   Probes for registers: 8 x 2 matrix of registers
   --- */
Byte-probe-h "R0" aa-ac R0[15..8]; Byte-probe-h "R0" ad-af R0[7..0]; 
Byte-probe-h "R1" ba-bc R1[15..8]; Byte-probe-h "R1" bd-bf R1[7..0]; 
Byte-probe-h "R2" ca-cc R2[15..8]; Byte-probe-h "R2" cd-cf R2[7..0]; 
Byte-probe-h "R3" da-dc R3[15..8]; Byte-probe-h "R3" dd-df R3[7..0]; 
Byte-probe-h "R4" ea-ec R4[15..8]; Byte-probe-h "R4" ed-ef R4[7..0]; 
Byte-probe-h "R5" fa-fc R5[15..8]; Byte-probe-h "R5" fd-ff R5[7..0]; 
Byte-probe-h "R6" ga-gc R6[15..8]; Byte-probe-h "R6" gd-gf R6[7..0]; 
Byte-probe-h "R7" ha-hc R7[15..8]; Byte-probe-h "R7" hd-hf R7[7..0]; 

Byte-probe-h "R8"  ah-aj R8[15..8];  Byte-probe-h "R8"  ak-am R8[7..0]; 
Byte-probe-h "R9"  bh-bj R9[15..8];  Byte-probe-h "R9"  bk-bm R9[7..0]; 
Byte-probe-h "R10" ch-cj R10[15..8]; Byte-probe-h "R10" ck-cm R10[7..0]; 
Byte-probe-h "R11" dh-dj R11[15..8]; Byte-probe-h "R11" dk-dm R11[7..0]; 
Byte-probe-h "R12" eh-ej R12[15..8]; Byte-probe-h "R12" ek-em R12[7..0]; 
Byte-probe-h "R13" fh-fj R13[15..8]; Byte-probe-h "R13" fk-fm R13[7..0]; 
Byte-probe-h "R14" gh-gj R14[15..8]; Byte-probe-h "R14" gk-gm R14[7..0]; 
Byte-probe-h "R15" hh-hj R15[15..8]; Byte-probe-h "R15" hk-hm R15[7..0]; 

Byte-probe-h "A-bus" jk-jm ABus[15..8]; 
Byte-probe-h "A-bus" jn-jp ABus[7..0];
Byte-probe-h "B-bus" jr-jt BBus[15..8]; 
Byte-probe-h "B-bus" ju-jw BBus[7..0];

Byte-probe-h "A" kk-km A[15..8]; Byte-probe-h "A" kn-kp A[7..0]; 
Byte-probe-h "B" kr-kt B[15..8]; Byte-probe-h "B" ku-kw B[7..0]; 

Byte-probe-h "AMUX" lk-lm AMUX[15..8]; Byte-probe-h "AMUX" ln-lp AMUX[7..0]; 

Byte-probe-h "ALU"  no-nq ALU[15..8];    
Byte-probe-h "ALU"  nr-nt ALU[7..0]; 
Probe "N" nm N;
Probe "Z" nm Z;

Byte-probe-h "C"    oo-oq C[15..8];    Byte-probe-h "C"    or-ot C[7..0]; 
