LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Four-bit AND,NAND, OR, NOR, and XOR calculator.

   This is the assigment:  " Build a VI that act as a four-bit AND, NAND,OR, NOR, and XOR calculator. The front panel will allow you to enter the four-bit word "A" and the four-bit "B". The calculator, depending on the selector switch setting, will  AND, NAND,OR, NOR, or XOR the two words and display the result in binary and hexadecimal. For example if "A" was set to 1100 and "B" was set to 1101 and the selector switch set on AND, the output should be show 1100 binary and C hex. Label the front panel for clarity."   I am attaching my VI, but some how does not work the way I want it.
0 Kudos
Message 1 of 6
(9,180 Views)
it seems you forgot to attach your vi...
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 2 of 6
(9,165 Views)
Oooooppppp!!!!! This my VI >>>>>>>>>>>  When I use the NAND and NOR the answers at the indicator shows 8 bit, I will like to be only 4 bits. How to solve it ?  Thanks.
Download All
0 Kudos
Message 3 of 6
(9,164 Views)
well the logic is still working:
00001100
00001101
nand:
11110011
 
so you cant expect to have only 4 bits. your only way out is to display only 4 bits:
use logical shift of 4, then rotate of 4, and taddaa!
 
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 4 of 6
(9,157 Views)
Well, we are not supposed to do your homework, but here are a few pointers:
 
Logical operations on integers are done bitwise, but the smallest integer available in LabVIEW is 8 bits. In some of your results, the upper nibble is all 1, so you just need to mask it off for the result you want. This is easily achieved by another logical operation with a diagram constant. Can you guess which one? 😉
 
For your inputs, you should really choose a binary format with a minimum width of 4 digits padded with zeroes. Same for the binary output.
0 Kudos
Message 5 of 6
(9,156 Views)
And no, you don't need to shift and/or rotate. 🙂
0 Kudos
Message 6 of 6
(9,138 Views)