Repository navigation
Multi input AND/OR; #4720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi input AND/OR; #4720
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| component and "Multi input AND gate"; | ||
| pin in bool in##[128:personality] = 1 "input pins, up to personality-1"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is 128 not excessive? Can you give an example where you'd need more than 40..50 inputs AND'ed together?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the case I have here/that started here was steps control in a 2D conveyer belt/palletrizer is 4x5 position = 20 pallets x (8 mount sensors) + 5 normal interlocks. So I rounded up to the next multiple of 2. Happy to make that 64.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other case is a pneumatic sorter where I have two sets(in/out) of blockage/low-pressure/high pressure detects in each of the 41 (don't ask -- I suspect the designer mixed inches v.s metric) linear stations. Though in this case you could roll up each of the 2x3 sets into a 41 OR and then combine each pair with a normal OR into the 3 outputs needed for the pump/tank.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Convinced. I guess it would probably be better to use 255 instead of 128. That would give pins The reason for not having this at 256 is that |
||
| pin out bool out "output pin; the AND of all inputs"; | ||
|
|
||
| description """ | ||
| The *out* pin is set to *TRUE* if all the inputs are all *TRUE*; or *FALSE* if one or more are *FALSE*. | ||
|
|
||
| The value for a unconnected pin is TRUE; so it is fine to leave a pin unconnected. | ||
|
|
||
| Set the number of pins via personality. The default value is a single *AND* with 8 inputs; so personality=8. The maximum number of inputs is 128 (hardcoded). If there are no inputs specified (personality=0); then the output value | ||
| is TRUE. | ||
| """; | ||
|
|
||
| function _ "Logical AND"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you add a doc string. But in the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok - will fix by removing this for the AND |
||
|
|
||
| see_also """ | ||
| *or*(9), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't use emphasis. The post-processor cannot handle it and links will no longer be provided in the html version.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Grin :) took it from one of the other modules; now removed. |
||
| and2(9) | ||
| and | ||
| or2(9). | ||
| """; | ||
|
|
||
| option period no; | ||
| option default_personality 8; | ||
| option default_count 1; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default count is implicitly one. Why set it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Grin :) took it from one of the other modules - removed :) |
||
|
|
||
| license "ASLv2"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What type of license is that? It would probably fail for RTAI because anything not GPL will taint the kernel. Besides, if you need this specific license, then it must also be added to debian/copyright, which needs consensus to ensure compatibility.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed to GPL; Was the Apache Software License v2 |
||
| author "Dirk-Willem van Gulik <dirkx(at)webweaving(punto)org"; | ||
| ;; | ||
| FUNCTION(_) { | ||
| bool tmp = 1; | ||
| // we prefer constant time; so do not return 0 on the first 0. | ||
| for(int i = 0; i < personality; i++) | ||
| tmp = tmp && in(i); | ||
| out_set(tmp); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| component or "Arbitrary input OR gate"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The AND gate you use the term "Multi". Why is this "Arbitrary"? What is arbitrary about these inputs? Why not retain the comp doc string I wrote?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| pin in bool in##[128:personality] = 0 "in"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The doc string
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Grin :) took it from one of the other modules - elaborated :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok - was not able to remove it - as a "" or none will give corrupted output / seems to concatenate the in and out. So have instead made it a more elaborate string. |
||
| pin out bool out "output pin; the OR of all inputs"; | ||
|
|
||
| description """ | ||
| The *out* pin is set to *TRUE* if any the inputs is *TRUE*; or *FALSE* if all are *FALSE*. | ||
|
|
||
| The value for a unconnected pin is FALSE; so it is fine to leave a pin unconnected. | ||
|
|
||
| Set the number of pins via personality. The default value is a single *OR* with 8 inputs; so personality=8. The | ||
| maximum number of inputs is 128 (hardcoded). If there are no input pins at all (personality=0); then | ||
| the output is *FALSE*. | ||
| """ | ||
| ; | ||
| function _; | ||
| see_also """ | ||
| and(9), and2(9) and or2(9). | ||
| """; | ||
|
|
||
| option period no; | ||
| option default_personality 8; | ||
| option default_count 1; | ||
|
|
||
| license "ASLv2"; | ||
| author "Dirk-Willem van Gulik <dirkx(at)webweaving(punto)org"; | ||
| ;; | ||
| FUNCTION(_) { | ||
| bool tmp = 0; | ||
| // we prefer constant time; so do not return 0 on the first true | ||
| for(int i = 0; i < personality; i++) | ||
| tmp = tmp || in(i); | ||
| out_set(tmp); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component naming
andandormay prove confusing withand2andor2. That is why I called themand_nandor_n. The underscore is converted into a dash for the hal internals, but if you don't like that, then you can usenames=.So, any particular reason to the naming?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None particularly; but _n seeded a bit extra. Changed to _n.