Software Overview  |  Sitemap  |  Downloads  |  Developers  |  Forums
Small_clear_logo_llc

Programmable Device

The Programmable Device is a general purpose logic Device. It can function as any combinational logic Device or any combination of combinational logic Devices. It has this capability because it is programmable. The Programmable Device has a single output terminal, "out", and takes either a "logic_function" or "file_name" input parameter which determines its function. Here are some examples of "logic_function" parameter values:

A 2 input And Device with inputs "a" and "b": "a && b"
A 3 input Or Device with inputs "a", "b" and "c": "a || b || c"
A 2 input Xor Device with inputs "a" and "b": "a ^ b"
A 3 input Nand Device with inputs "a", "b" and "c": "!(a && b && c)"

The names within a logic_function (here the names are "a", "b", and "c") are treated as inputs to the function and will become input terminals when you create the Programmable Device.

Sometimes, your logic functions will be complex enough that you won't want to squeeze them into a "logic_function" parameter. Instead, you can use a "file_name" parameter, and the function will be read from a Script file. When using a Script file, you can spread your functions across lines and add optional comments. Here is a file which Ands 3 Ors:

# this is a comment
(a || b || c)
&&                 # this is another comment
(c || !d || e)
&& f

Programmable logic Devices are created by running the Programmable Script. The Script takes the following parameters (you need either a file_name or logic_function parameter, but not both):

  • file_name : a quoted string containing the name of the Script file
  • logic_function : a quoted string containing the desired logic function
  • output : the name of the function's output terminal (default is "out")

"logic_function" understands the following operations (highest precedence operation to lowest):

  • () : parentheses
  • ! : inverts (turns on to off and off to on)
  • ==, != : equality and inequality checkers
  • ^ : Xor function
  • && : And function
  • || : Or function

Running the Programmable Script with the parameters listed below will create a Programmable Device which turns its "alarm" output on whenever its "mode" input is enabled, and either its "temp_ok" input is off or its "motion" input is on:

id : "my_alarm"
output : "alarm"
logic_function : "mode == \"enabled\" && (!temp_ok || motion)"

Running the Programmable Script with the parameters listed below will create a Programmable Device which turns its "alarm" output on using the function contained in the "Scripts/user/alarm_function" Script:

id : "my_alarm"
output : "alarm"
file_name : "Scripts/user/alarm_function"

Note that the == and != operators can compare values other than off/on values. They check for equality or inequality of any values. If you wish to compare an input value with a constant value (and not another input value), you must embed another set of quotes around the constant value (see example above). Embedded quotes tell the system the value is a constant and not another input.

Catalina Computing, LLC.

Copyright © Catalina Computing, LLC. (2013-2018)




Page last updated: Wed Jan 7 16:07:02 2015 (UTC)