FlipFlop / Readbit / Change Bit

Please add any feature requests for Flowcode version 6 here

Moderator: Benj

Forum rules
Only feature requests will be considered here. General questions should not be posted in this forum.
Post Reply
MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times

FlipFlop / Readbit / Change Bit

Post by MJU »

You've asked for it! :D

If you've got still some space on your "to-do" whiteboard, here some more suggestions:

Flipflop(var) -> Changes the state of the variable from 0 -> 1 or 1 -> 0

Maybe not the best suggestion but if you need to do that often it could be a great help..

ReadBit(var,position,number of bits): returns the value of certain bits in a byte.
So Readbit("10010100",2,2) would return "10" (starting from LSB).
Would come in handy to read values in registers from components.

ChangeBit(var,position,value): changes the value of a bit in a certain position in a byte to a specified..
So ChangeBit(10000000,4,1) will change the byte into: 10001000 (even if it was already 1)

Maybe these are not the most difficult things to do in Flowcode, but if you want the "fast" in "fast prototyping", they may come in handy..
Most of these suggestions can be done with masking, but... just suggestions.. :D

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: FlipFlop / Readbit / Change Bit

Post by Benj »

Hello,

Some more great suggestions there.

The flip flop to invert bits can be done with a ~ operator. I think this should simulate but I suppose it could be a lot more obvious to a new user.

The other two functions sound ok though, i'll get them on the list.

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times

Re: FlipFlop / Readbit / Change Bit

Post by MJU »

Benj wrote: The flip flop to invert bits can be done with a ~ operator. I think this should simulate but I suppose it could be a lot more obvious to a new user.
Can you please give an example of how the "~" operator works?
I have never crossed it and can't find anything about it on the Wiki..

I've tried to use it in a flowchart and it isn't recognised in several ways.. :(

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: FlipFlop / Readbit / Change Bit

Post by medelec35 »

To flip a bit of a variable,
I personally use

Code: Select all

variable = variable XOR BitToBeFlipped
e.g
With bits 0 to 7
to flip bit 1 I would use:

Code: Select all

variable = variable XOR 2
I thought
MJU wrote:ReadBit(var,position,number of bits): returns the value of certain bits in a byte.
&
MJU wrote:ChangeBit(var,position,value): changes the value of a bit in a certain position in a byte to a specified..
are both good ideas.
Martin

Post Reply