Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   logic gates question (http://www.chiefdelphi.com/forums/showthread.php?t=113675)

Ether 16-02-2013 15:13

logic gates question
 
1 Attachment(s)

Could this be implemented in LabVIEW? And if so, what would it do?

note: the intent of the small circle on the bottom input of each AND gate is that the bottom input is inverted



Nirvash 16-02-2013 16:16

It can be, I coded it up quickly while I was waiting for something, but I'm not sure what it is trying to do.

The second set of ANDs require the last output to be True, so unless you initialized the output to be true, the Ands would never let the code output True.

Ether 16-02-2013 17:16

Re: logic gates question
 

note: the intent of the small circle on the bottom input of each AND gate is that the bottom input is inverted



Greg McKaskle 16-02-2013 17:47

Re: logic gates question
 
1 Attachment(s)
I wasn't sure who the question was for. Here is what it looks like in LV if you use the growable logic nodes.

I'll let others do the implementation to see the end result. There are many many ways to write this by the way.

Greg McKaskle

Omar 16-02-2013 18:01

Re: logic gates question
 
1 Attachment(s)
Greg beat me with the exact implimentation for a toggle

Here is a simple one that has been posted before

Attachment 14053

Nirvash 16-02-2013 18:25

Quote:

Originally Posted by Ether (Post 1234482)

note: the intent of the small circle on the bottom input of each AND gate is that the bottom input is inverted



Ah, missed that first time I looked at it.

Ether 16-02-2013 20:15

Re: logic gates question
 
Quote:

Originally Posted by Omar (Post 1234509)
Greg beat me with the exact implimentation for a toggle

Here is a simple one that has been posted before

Attachment 14053

That's very concise.

@ Greg: how much different is the code that LabVIEW generates for the following two different approaches?

http://www.chiefdelphi.com/forums/at...3&d=1361055503

http://www.chiefdelphi.com/forums/at...8&d=1360772515



Cecil 17-02-2013 00:55

Re: logic gates question
 
Quote:

Originally Posted by Greg McKaskle (Post 1234497)
I wasn't sure who the question was for. Here is what it looks like in LV if you use the growable logic nodes.

Whoah, there are growable logic nodes? Time to go get rid of the 3 and statements I have hooked together...

Greg McKaskle 17-02-2013 08:18

Re: logic gates question
 
The LV compiler supports optimization transforms, but I don't expect there to be one that will turn the select and negate into the XOR. So I expect the XOR to be just a bit more efficient. I put the code into timing sequences and ran it 100,000,000 times and indeed, at least for intel code gen, the XOR is just a bit faster.

Greg McKaskle

Ether 17-02-2013 16:44

Re: logic gates question
 
1 Attachment(s)
Quote:

Originally Posted by Greg McKaskle (Post 1234892)
The LV compiler supports optimization transforms, but I don't expect there to be one that will turn the select and negate into the XOR. So I expect the XOR to be just a bit more efficient. I put the code into timing sequences and ran it 100,000,000 times and indeed, at least for intel code gen, the XOR is just a bit faster.

Thanks Greg. I realize the difference, if any, is likely miniscule, but would it be reasonable to assume (based on your testing above) that the bottom sketch in the attached PNG is also slightly more efficient than the top one?

Greg McKaskle 17-02-2013 18:20

Re: logic gates question
 
My testing showed that at least on Intel, the top one that used XOR was more efficient.

I rewrote the other to use a case statement instead of a select and it was then the fastest. Selects tend to execute both the true and false and then select the appropriate one whereas case statements will only execute one or the other.

But at this level for toggle on a button on a joystick, we are in the weeds. Write what is readable.

Greg McKaskle

Ether 17-02-2013 18:33

Re: logic gates question
 
Quote:

Originally Posted by Greg McKaskle (Post 1235185)
My testing showed that at least on Intel, the top one that used XOR was more efficient.

Sorry, my previous post made no sense since I forgot to attach the PNG it was referencing. It's attached now:

http://www.chiefdelphi.com/forums/sh...5&postcount=10

Quote:

I rewrote the other to use a case statement instead of a select and it was then the fastest. Selects tend to execute both the true and false and then select the appropriate one whereas case statements will only execute one or the other.
Interesting. Thanks.

Quote:

But at this level for toggle on a button on a joystick, we are in the weeds. Write what is readable.
I agree 100%. My questions here are purely academic.



Greg McKaskle 17-02-2013 18:44

Re: logic gates question
 
The > was a bit faster than the logic. This is again only on testing on intel and it was about 20% different.

Greg McKaskle


All times are GMT -5. The time now is 12:12.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi