lib/bistable.txt
author Mario de Sousa <msousa@fe.up.pt>
Thu, 10 Jan 2013 10:49:50 +0000
changeset 796 73e14a2ce5d1
parent 277 f88718b71b6c
permissions -rwxr-xr-x
merge
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     1
(*
277
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
     2
 *  This file is part of matiec - a compiler for the programming
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
     3
 *  languages defined in IEC 61131-3
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     4
 *
274
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
     5
 *  Copyright (C) 2011  Mario de Sousa (msousa@fe.up.pt)
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     6
 *
277
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
     7
 * See COPYING and COPYING.LESSER files for copyright details.
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
     8
 * This library is free software; you can redistribute it and/or
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
     9
 * modify it under the terms of the GNU Lesser General Public
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    10
 * License as published by the Free Software Foundation; either
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    11
 * version 3 of the License, or (at your option) any later version.
274
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    12
 *
277
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    13
 * This library is distributed in the hope that it will be useful,
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    16
 * Lesser General Public License for more details.
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    17
 * 
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    18
 * You should have received a copy of the GNU Lesser General Public
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    19
 * License along with this library; if not, write to the Free Software
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    20
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    21
 * USA
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    22
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    23
 * This code is made available on the understanding that it will not be
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    24
 * used in safety-critical situations without a full and competent review.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    25
 *)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    26
277
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    27
f88718b71b6c Changing to LGPL for library functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 274
diff changeset
    28
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    29
(*
274
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    30
 * An IEC 61131-3 compiler.
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    31
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    32
 * Based on the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    33
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    34
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    35
 *)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    36
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    37
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    38
(*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    39
 * This is part of the library conatining the functions
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    40
 * and function blocks defined in the standard.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    41
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    42
 * SR and RS function blocks
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    43
 * -------------------------
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    44
 *)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    45
274
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    46
(* The standard defines the SR FB thus: 
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    47
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    48
                  +-----+
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    49
S1----------------| >=1 |---Q1
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    50
         +---+    |     |
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    51
 R------O| & |----|     |
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    52
 Q1------|   |    |     |
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    53
         +---+    +-----+
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    54
*)
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    55
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    56
FUNCTION_BLOCK SR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    57
  VAR_INPUT
274
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    58
    S1, R : BOOL;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    59
  END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    60
  VAR_OUTPUT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    61
    Q1 : BOOL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    62
  END_VAR
274
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    63
  Q1 := S1 OR ((NOT R) AND Q1);
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    64
END_FUNCTION_BLOCK
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    65
274
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    66
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    67
(* The standard defines the RS FB thus: 
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    68
                   +---+
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    69
R1----------------O| & |---Q1
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    70
        +-----+    |   |
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    71
S-------| >=1 |----|   |
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    72
Q1------|     |    |   |
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    73
        +-----+    +---+
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    74
*)
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    75
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    76
FUNCTION_BLOCK RS
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    77
  VAR_INPUT
274
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    78
    S, R1 : BOOL;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    79
  END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    80
  VAR_OUTPUT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    81
    Q1 : BOOL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    82
  END_VAR
274
8d36d1f81170 New version of bistable.txt - due to license issues.
Mario de Sousa <msousa@fe.up.pt>
parents: 0
diff changeset
    83
  Q1 := (NOT R1) AND (S OR Q1);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    84
END_FUNCTION_BLOCK