-- NewFIFODriver.sak -- last edited by Suzuki: 28-Nov-81 22:45:19 DIRECTORY FIFO, SakuraRT, SimIO; NewFIFODriver: MONITOR IMPORTS FIFO, SakuraRT, SimIO = { Reader: DEVICE = { IN DataAv: BOOLEAN, DataOut: CARDINAL OUT ReadReq: BOOLEAN GUARDIAN {} CONTROL { data: CARDINAL; SimIO.WF0[" Reader started.*n"]; THROUGH [0..30) DO SakuraRT.Delay[20]; UNTIL DataAv=TRUE DO SakuraRT.StandardDelay[] ENDLOOP; ReadReq ← TRUE; data ← DataOut; SimIO.WF1["%u ", @data]; SakuraRT.Delay[10]; ReadReq ← FALSE; ENDLOOP; SimIO.WF0[" Reader terminated.*n"]} }; Writer: DEVICE = { IN SpaceAv: BOOLEAN OUT WriteReq: BOOLEAN, DataIn: CARDINAL GUARDIAN {} CONTROL { i: CARDINAL; SimIO.WF0[" Writer started.*n"]; FOR i IN [0..30) DO SakuraRT.Delay[20]; UNTIL SpaceAv=TRUE DO SakuraRT.StandardDelay[] ENDLOOP; DataIn ← i; WriteReq ← TRUE; SimIO.WF1["%u- ", @i]; SakuraRT.Delay[10]; WriteReq ← FALSE; ENDLOOP; SimIO.WF0[" Writer terminated.*n"]} }; Start: DEVICE = { IN OUT Init, ReadReq, WriteReq: BOOLEAN GUARDIAN {} CONTROL { ReadReq ← FALSE; WriteReq ← FALSE; SakuraRT.Delay[10]; Init ← TRUE; SakuraRT.Delay[5]; Init ← FALSE} }; SimIO.Start[]; CIRCUIT { COMPONENTS fifo: FIFO.FIFOFunc[size: 100], reader: Reader, writer: Writer, start: Start NODES init, write, read, in, space, data, out: NODE REPRESENTATION CONNECTIONS fifo[Init: init, WriteRequest: write, ReadRequest: read, DIn: in, SpaceAv: space, DataAv: data, DOut: out], reader[DataAv: data, DataOut: out, ReadReq: read], writer[SpaceAv: space, WriteReq: write, DataIn: in], start[Init: init, ReadReq: read, WriteReq: write]}; SimIO.Stop[]; }.