Newsgroups: comp.sys.transputer
From: thor@tordivel.no (Thor Vollset)
Subject: Re: Transputer and Coherent UNIX
Organization: TORDIVEL AS, Oslo, Norway
Date: Mon, 22 Aug 94 20:35:45 +0100
Message-ID: <hRUWuAhOBh107h@tordivel.no>

In <777558626snz@aiki.demon.co.uk> jdd@aiki.demon.co.uk (Jim Dixon) writes:
>In article <npeVuAnBBh107h@tordivel.no> thor@tordivel.no "Thor Vollset" writes:


>> D    If yo can access the IO-Port of the PC-BUS. Then anybody with knowledge
>>      can implement a B004 interface in 12 hours. The advantage/disadvantage
>>      ( how you feel about ) of this is that you have to define your application
>>      protocol. A B004 interface consists of these functions :
>> 
>>                 ReadByte
>>		  DataReady
>[and so forth]

>Read a little more carefully and you will find that your D = my A.  A decent
>implementation is a lot more than 200 lines, though, because you have to
>use assembler to get reasonable performance.

This is very soon a competition of who is the most clever boy in the class.

An implementation in a high level language in not very much more than 200 lines.
And with a 486 class computer the slow interface speed of B004 means that assembly language
is not necessary.

Here I will enclose some of the functions as I have implemented them
as DLL under MS-Windows. Not too many lines. Not to difficult and
the speed is ok for most applications.

  (*---------------------------------*)
  PROCEDURE Reset; EXPORT;


    CONST
      MilliSeconds = 500;

    BEGIN
      Port[analyseIMSB008] := 0;
      Port[resetIMSB008] := 1;
      Delay(MilliSeconds);
      Port[resetIMSB008] := 0;
      Delay(MilliSeconds);
    END; (* Reset *)
 
  (*---------------------------------*)
  FUNCTION DataPresent : BOOLEAN; EXPORT;

    VAR
      status : BYTE;

    BEGIN
      status := Port[inputStatus];
      DataPresent := ((1 and status) = 1);
    END; (* DataPresent *)

  (*---------------------------------*)
  FUNCTION OutputReady: BOOLEAN; EXPORT;

     VAR
      status : BYTE;

    BEGIN
      status := Port[outputStatus];
      OutputReady := ((1 and status) = 1);
    END; (* OutputReady *)

  (*---------------------------------*)
  FUNCTION Error : BOOLEAN; EXPORT;

    VAR
      status : BYTE;

    BEGIN
      status := Port[errorIMSB008];
      Error := ((1 and status) = 0);
    END;

  (*---------------------------------*)
  PROCEDURE ReadByte(VAR byte0 : BYTE); EXPORT;

    CONST
      NoOfTimeoutCounts = 12000;

    VAR
      ready : BOOLEAN;
      countOfTimeout : INTEGER;
      tickCount : LONGINT;

    BEGIN
      ready := DataPresent;
      IF ready THEN BEGIN
        byte0 := Port[inputData];
      END ELSE BEGIN
        tickCount := GetTickCount;
        WHILE NOT (ready OR Timeout OR Error) DO BEGIN
          ready := DataPresent;
          IF ready THEN BEGIN
            byte0 := Port[inputData];
          END ELSE IF GetTickCount > (tickCount+10000) THEN BEGIN
            SetTimeout(TRUE);
          END; (* if *)
        END; (* while *)
      END; (* if *)
    END; (* ReadByte *)

  (*---------------------------------*)
  PROCEDURE ReadBlock(
    VAR block;
    startElement,stopElement : WORD); EXPORT;

 
    TYPE
      ByteArray = ARRAY [0..MaxInt] OF BYTE;

    VAR
      w0 : WORD;

    BEGIN
      FOR w0 := startElement TO stopElement DO BEGIN
        ReadByte(ByteArray(block)[w0]);
      END (* for *);
    END; (* ReadBlock *)

  (*---------------------------------*)
  PROCEDURE Analyse; EXPORT;

    CONST
      MilliSeconds = 100;

    VAR
      l0 : LONGINT;

    BEGIN
      Port[analyseIMSB008] := 1;
      Delay(MilliSeconds);
      Port[resetIMSB008] := 1;
      Delay(MilliSeconds);
      Port[resetIMSB008] := 0;
      Delay(MilliSeconds);
      Port[analyseIMSB008] := 0;
      Delay(MilliSeconds);
    END; (* Analyse *)


>-- 
>+-----------------------------------+--------------------------------------+
>|  Jim Dixon<jdd@aiki.demon.co.uk>  |	    Compuserve: 100114,1027	   |
>|AIKI Parallel Systems Ltd + parallel processing hardware & software design|
>|	     voice +44 272 291 316  | fax +44 272 272 015		   |
>+-----------------------------------+--------------------------------------+

-- 
*****************************************************************
* Thor Vollset (thor@tordivel.no)                               *
* TORDIVEL AS  Waldemar Thranes gate 77  N-0175 OSLO  NORWAY    *
* phone +47 22 20 68 90  fax +47 22 20 68 91                    *
*****************************************************************

