//D0 Card Tester Program for EtherNet
//Test2B: Output Buffer Test
//R. Garner August 1, 1978  1:03 AM
//R. Crane November 20, 1978  11:28 PM

get "testdefs.d"
get "spgxwtest.d"

//{IData:IData.00,IData.01,IData.02,IData.03,IData.04,IData.05,IData.06,IData.07,IData.08,IData.09,IData.10,IData.11,IData.12,IData.13,IData.14,IData.15}
//{OData:OData.00,OData.01,OData.02,OData.03,OData.04,OData.05,OData.06,OData.07,OData.08,OData.09,OData.10,OData.11,OData.12,OData.13,OData.14,OData.15}
//{CTask:CTask.0,CTask.1,CTask.2,CTask.3}
//{U57A':U57A'.0,U57A'.1,U57A'.2,U57A'.3}
//{U57D:U57D.0,U57D.1,U57D.2,U57D.3}
//{U57Q':U57Q'.0,U57Q'.1,U57Q'.2,U57Q'.3}
//{IAddr:IAddr.0,IAddr.1,IAddr.2,IAddr.3,IAddr.4,IAddr.5,IAddr.6,IAddr.7}
//{IConds:InDiffNE0,InDiffNE15,InDiffGE4,InDiffLE11}
//{RData':RData.0',RData.1',RData.2',RData.3',RData.4',RData.5',RData.6',RData.7'}
//{TData':TData.0',TData.1',TData.2',TData.3',TData.4',TData.5',TData.6',TData.7'}
//{RamClock:RamClockFeed',RamClockFeed'}
//{EClock:EdgeClockFeed',EdgeClockFeed'}
//{PreRClk:PreRClock,PreRClock}
//{TClk:TClock,TClock',TClock,TClock'}
//{LoadHalfCAddr:SRClock,SRClock,SRDataIn',SRClock,SRClock,SRDataIn',SRClock,SRClock,SRDataIn',SRClock,SRClock,SRDataIn'}


let Test2B(TChar,Size,S,enable) be
[
//Continue with Test 2.
//go to CRCMode
	if TChar eq $y then
	[
		{Collision}=1
		{OValid'}=0
		{EClock}=Eclick
		{Collision}=0
		{OFault'}=0
		{OValid'}=1
		{EClock}=Eclick
		{TClk}=Tclick;	//enough for Jam to kill PacketOutMode
		{TClk}=Tclick
		{TClk}=Tclick
		goto BadStat
	]
	if Size ge 12 then goto BadStat
	Compare({PacketOutMode},1,"PacketOutMode")
	Compare({SendMode},1,"SendMode")
	Compare({LoadOutSR},1,"LoadOutSR")
	Compare({CRCMode},0,"CRCMode")
	{TClk}=Tclick
	Compare({CRCMode},1,"CRCMode")
	{TClk}=Tclick
//Flush CRC & Quit
	for i = 2 to 16 do {TClk}=Tclick 
BadStat:	Compare({SendMode},0,"SendMode")
	Compare({CRCMode},0,"CRCMode")
	Compare({PacketOutMode},0,"PacketOutMode")
	Compare({Transmit},0,"Transmit")
	{CTask}=0
	{OValid'}=1
	{Phase1Next'}=0;
	//enough for OAttnReq,OWakeReq,Transmit,WakeOutTime,OMeF
	for i = 1 to 17 do {EClock}=Eclick;
	Compare({Transmit},1,"Transmit")
//Read output status
	{IAddr}=302B;	//IAddr[0..3]=12;	IAddr[4..7]=2
	{IValid'}=0
	{EClock}=Eclick
	S={IData}
	test TChar eq $y ifso Compare(S & 1000B,1000B,"Bad Parity Status")
		ifnot Compare(S & 1000B,0,"Bad Parity Status")
	test Size ge 12 ifso Compare(S & 40000B,40000B,"UnderRun Status")
		ifnot Compare(S & 40000B,0,"UnderRun Status")
	test TChar eq $y ifso Compare(S & 10000B,10000B,"Collision Status")
		ifnot Compare(S & 10000B,0,"Collision Status")
	test TChar eq $y ifso Compare(S & 2000B,2000B,"OFault Status")
		ifnot Compare(S & 2000B,0,"OFault Status")
// reset output & check for zero status
	LoadState(300B,100B)
	{IAddr}=122B;	//IAddr[0..3]=5;	IAddr[4..7]=2
	{IValid'}=0
	{EClock}=Eclick
	Compare({IData},0,"Status-State")
	Wss(D,"*nEnd of Test 2")
]