Currently the only way to set a specific bit for a multi-bit component such as a register is to rewrite the entire value
myRegister = 3; // will set my register to 0b11
Need to implement ability to set specific bits such as
myRegister[1] = 1;
This should only be allowed for components where setting a specific bit makes sense = registers, multibit buffers/wires.
This will be best accomplished by refactoring "gates" into component class hierarchy:
- Component {state:Numeric, inputs:[], update(), setValue(), getValue()}
- Gate extends Component {logicFn: and, or etc, function in update}
- SevenSeg
- Number
- MaskableComponent { inputMasks: [] = which bits the input contributes to, setValue(x, mask), update calls setValue for each input }
- Register
- Wire
Currently the only way to set a specific bit for a multi-bit component such as a register is to rewrite the entire value
myRegister = 3; // will set my register to 0b11Need to implement ability to set specific bits such as
myRegister[1] = 1;This should only be allowed for components where setting a specific bit makes sense = registers, multibit buffers/wires.
This will be best accomplished by refactoring "gates" into component class hierarchy: