Skip to content

PE/PA bit operands: add bit access support#39

Open
occamsshavingkit wants to merge 3 commits into
mbuesch:masterfrom
occamsshavingkit:upstream-pr/pe-pa-bit-tests
Open

PE/PA bit operands: add bit access support#39
occamsshavingkit wants to merge 3 commits into
mbuesch:masterfrom
occamsshavingkit:upstream-pr/pe-pa-bit-tests

Conversation

@occamsshavingkit

Copy link
Copy Markdown

Adds PE/PA and PI/PQ bit operand parsing and byte-backed peripheral bit access, with regression coverage.

Validated locally:

  • git diff --check upstream/master
  • ./tests/run.sh -i python3 tests/tc100_instructions/periphery_bit_operands.py

Rollback: close the PR before merge, or revert the three commits after merge.

Add 1-bit operand descriptors for direct peripheral input and output areas so bit instructions can parse PE/PA operands alongside the existing PEB/PEW/PED and PAB/PAW/PAD forms.

Also add the English PI/PQ aliases to keep bit operands consistent with the existing PIB/PIW/PID and PQB/PQW/PQD aliases.
The direct peripheral hardware callback API accepts a byte offset and an access width, but no bit offset. For PE/PA bit operands, route hardware access as an 8-bit access at the operand byte offset, then extract or update the addressed bit in the CPU process image.

PE bit reads now refresh the process-image byte when direct hardware returns data, then return the requested bit. PA bit stores update the process-image bit first, then write the resulting byte to hardware so neighboring bits are preserved.

PA bit stores outside the output process image are rejected because the current hardware API cannot read-modify-write an isolated peripheral output bit without a backing byte image.
Cover PE bit process-image fallback, PA bit process-image preservation, and direct hardware PE/PA bit access. The hardware-facing test uses a temporary module that requires byte-wide direct access, which catches regressions that pass width 1 to the hardware API.

The direct hardware test also exercises English PI/PQ bit aliases under English mnemonics.
@mbuesch

mbuesch commented May 17, 2026

Copy link
Copy Markdown
Owner

Thanks for your contribution.

Peripheral bit access was left out because I thought it doesn't exist on the real S7 hardware.
Did this change? Or was I wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants