Skip to content

Support setting specific bits of multi-bit components #2

@dkilfoyle

Description

@dkilfoyle

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:

  1. Component {state:Numeric, inputs:[], update(), setValue(), getValue()}
    1. Gate extends Component {logicFn: and, or etc, function in update}
    2. SevenSeg
    3. Number
    4. MaskableComponent { inputMasks: [] = which bits the input contributes to, setValue(x, mask), update calls setValue for each input }
      1. Register
      2. Wire

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions