public BitInt[] We = new BitInt[4]; public BitInt[] Wu = new BitInt[4]; ... We[0].Value = ....; //read hw input register Wu[0].Set(7); Wu[0].Rst(8); Wu[0].Ld(9, (We[0].Get(0) | Wu[0].Get(9)) & !We[0].Get(2)); writeHwRegister(Wu[0].Value);
In this example, I defined two arrays of four elements, the first one for reading input registers and the other to write the output registers.
The Set(int n) method, set the n(th) bit to true.
The Rst(int n) method, set the n(th) bit to false.
the Ld(int n, bool val) set the n(th) bit to the boolean state you pass, in this sample a start stop control.
A good way to improve flexibility and code interpretation, consists of using enum for identifying signals (bit) inside the registers
public enum we0names { powerOn ,alarm ,ready ,startBtn ,stopBtn ,nc5 ,forwardSwitch ,nc7 ,reverseSwitch }
...then replacing the numbers in the method call with enum reference
public BitInt[] We = new BitInt[4]; public BitInt[] Wu = new BitInt[4]; ... We[0].Value = ....; //read hw input register Wu[0].Set(7); Wu[0].Rst(8); Wu[0].Ld(9, (We[0].Get((int)we0names.power) | Wu[0].Get(9)) & !We[0].Get((int)we0names.ready)); writeHwRegister(Wu[0].Value);
If you are interested in the source, let me know.
Bye