//  MemProms.bcpl      Last Updated:  September 26, 1979

// change change tomemx-16k-j13 from -j14. comment-out the memx-4k option.September 26, 1979  4:21 PM  
external MemProms
get "DoradoProms.defs"


let MemProms(mem) be
	[
	let buff = vec 300
	if StEq(mem,"Mem") then mem!0 = DoAll
	if StEq(mem,"ST") & ICtype eq MC10139 then  // define the write Prom
		[
		MakeST(buff)
		Header("ST",16,buff,32,0)
		PromCommand("MemX-h11") //command to blow the left half
		PromCommand("MemX-i12","8")  //command to blow the right half
		]

	if StEq(mem,"EC-1") & ICtype eq MC10139 then  // define the EC-1 Prom
		[
		MakeEC1(buff)
		Header("EC-1",8,buff,32,8)
		PromCommand("MemX-l12")
		]

	if StEq(mem,"EC-2") & ICtype eq MC10139 then  // define the EC-2 Prom
		[
		MakeEC2(buff)
		Header("EC-2",8,buff,32,8)
		PromCommand("MemX-l11")
		]

	if StEq(mem,"Map-Mem") & ICtype eq MC10139 then  // define the Map-Mem Prom
		[
		MakeMapMem(buff)
		Header("Map-Mem",8,buff,32,10)
		PromCommand("MemX-i14")
		]

	if StEq(mem,"Map-Map") & ICtype eq MC10139 then  // define the Map-Map Prom
		[
		MakeMapMap(buff)
		Header("Map-Map",8,buff,32,8)
		PromCommand("MemX-g15")
		]

//	if StEq(mem,"4k-Mem") & ICtype eq MC10139 then  // define the Mem-4k Prom
//		[
//		MakeMem4(buff)
//		Header("4k-Mem",8,buff,32,8)
//		PromCommand("MX4k-j14")
//		]
	if StEq(mem,"16k-Mem") & ICtype eq MC10139 then  // define the Mem-16k Prom
		[
		MakeMem16(buff)
		Header("16k-Mem",8,buff,32,8)
		PromCommand("MX16k-j13")
		]
	]


and MakeST(buff) =valof  //first specify the STate memory contents.
	[
	let TableDef = table
		[                                                                       //11 cycles IO store
		#052600; #012600; #052600; #012600; #056600; #016600; #056200; #136000
		#177000; #175000; #063600; #063600; #177000; #177000; #177000; #177000
		                                                                        //12 cycles Victim store
		#063406; #052406; #012406; #052406; #012406; #056406; #016406; #056404
		#136000; #177000; #175000; #173002; #177000; #177000; #177000; #177000
		]
	MoveBlock(buff,TableDef,32)
	]


and MakeEC1(buff) be  //now specify the EC-1 memory contents.
	[
	let TableDef = table
		[
		#003; #207; #203; #203; #203; #202; #201; #203  //Write
		#003; #207; #313; #313; #313; #312; #201; #203  //Cache Load
		#003; #207; #203; #223; #223; #222; #201; #203  //Clean or miss IO fetch
		#003; #207; #303; #343; #363; #362; #201; #203  //Dirty hit IO fetch
		]
	MoveBlock(buff,TableDef,32)
	]


and MakeEC2(buff) be  //now specify the EC-2 memory contents.
	[
	let TableDef = table
		[
		#005; #001; #001; #001; #001; #001; #011; #001  //Write
		#226; #222; #222; #002; #000; #000; #011; #222  //Cache Load
		#045; #041; #041; #041; #001; #001; #011; #041  //Clean or miss IO fetch
		#347; #343; #343; #143; #041; #001; #011; #343  //Dirty hit IO fetch
		]
	MoveBlock(buff,TableDef,32)
	]


and MakeMapMem(buff) be  //now specify the Map-Mem memory contents.
	[
	let TableDef = table
		[
		#12; #12; #12; #46; #12; #12; #10; #12  // Refresh
		#12; #12; #13; #07; #12; #12; #10; #12  // Read
		#12; #12; #13; #07; #12; #12; #10; #12  // Write
		#12; #12; #13; #13; #12; #12; #10; #12  // Map write
		]
	MoveBlock(buff,TableDef,32)
	]


and MakeMapMap(buff) be  //now specify the Map-Map memory contents.
	[
	let TableDef = table
		[
		#037; #037; #037; #235; #275; #337; #327; #007  // Refresh
		#007; #007; #007; #005; #045; #107; #127; #007  // Read
		#007; #007; #007; #004; #044; #107; #127; #007  // Write
		#007; #007; #007; #000; #040; #107; #127; #007  // Map write
		]
	MoveBlock(buff,TableDef,32)
	]


and MakeMem4(buff) be  //now specify the Mem-4 timing memory contents.
	[
	let TableDef = table
		[
		#303; #313; #113; #153; #153; #053; #153; #363  // Read or write
		#302; #302; #302; #306; #303; #306; #306; #306
		#303; #303; #303; #343; #343; #343; #343; #343  // Refresh
		#302; #302; #302; #306; #303; #306; #306; #306
		]
	MoveBlock(buff,TableDef,32)
	]

and MakeMem16(buff) be  //now specify the Mem-16 timing memory contents.
	[
	let TableDef = table
		[
		#353; #053; #153; #373; #352; #340; #306; #303  // Read or write
		#306; #306; #306; #306; #306; #306; #306; #306  // Idle state
		#303; #303; #303; #303; #302; #300; #306; #303  // Refresh
		#306; #306; #306; #306; #306; #306; #306; #306  // Idle state
		]
	MoveBlock(buff,TableDef,32)
	]