-- File: [Indigo]<Sakura>Dragon>DragonMapImpl.sak
-- 14-Mar-82 19:37:18

DIRECTORY
  DragonCache,
  DragonMap,
  SakuraRT;

DragonMapImpl: MONITOR
  IMPORTS SakuraRT
  EXPORTS DragonMap = {
  
MapProcessor: PUBLIC DEVICE = {
  IN ClockA, ClockB, CMDIn: BOOLEAN, MDataIn: DragonCache.MbusType
  OUT CMDOut: BOOLEAN, MDataOut: DragonCache.MbusType
  GUARDIAN {}
  CONTROL {
    DO
      WHEN ClockB UP: NULL;
      IF CMDIn THEN
        WITH m: MDataIn SELECT FROM
          Instruction =>  
  	    SELECT m.command FROM  
	      ReadQuad => NULL;  
	      WriteQuad => NULL;
	      WriteSingle => NULL;
	      NotReady => ERROR;
	      ReadMap => ERROR;
	      ReadMapAndSetRpDirty => ERROR;
	      DoMapOp => ERROR;
	      SetRpDirty => {
	        WHEN ClockA UP: CMDOut ← TRUE;
		MDataOut ← [MapCommand[MapOpDone, , , , ]];
		WHEN ClockA UP: CMDOut ← FALSE;
		};
	      MapOpDone => ERROR;
  	      ENDCASE;
	  MapCommand => 
	    SELECT m.command FROM
	      ReadMap => {
		WHEN ClockB UP: CMDOut ← TRUE;
		MDataOut ← [MapCommand[MapOpDone, , FALSE, FALSE, m.vp]];
		WHEN ClockA UP: CMDOut ← FALSE;
		};
	      ReadMapAndSetRpDirty => {
		WHEN ClockB UP: CMDOut ← TRUE;
		MDataOut ← [MapCommand[MapOpDone, , FALSE, TRUE, m.vp]];
		WHEN ClockA UP: CMDOut ← FALSE;
		};
	      ReadQuad => NULL;
	      MapOpDone => NULL;
	      ENDCASE => ERROR;
	  Data => ERROR;
	  ENDCASE => ERROR;
      ENDLOOP}
  };
  
}.