Operands and parameters
SrcP- Reg5 predicate source
SrcL- Reg5 true-value source
SrcR- Reg5 false-value source
SrcRType- CSEL-specific false-source modifier selector
RegDst- Reg5 destination or discard
CSEL snapshots three Reg5 sources, selects SrcL for a nonzero predicate or its optionally negated SrcR for zero, and publishes through the common scalar destination map.
PTO-SCALAR-CSELcsel SrcP, SrcL, SrcR<.neg>, ->{t, u, Rd}| Field | Bits | Signedness | Architectural role | Encoded zero |
|---|---|---|---|---|
RegDst | 5 | encoding-defined | Reg5 destination or discard | Encoded zero discards the result. |
SrcL | 5 | encoding-defined | Reg5 true-value source | Encoded zero reads the architectural zero GPR. |
SrcP | 5 | encoding-defined | Reg5 predicate source | Encoded zero reads the architectural zero GPR and therefore selects the false value. |
SrcR | 5 | encoding-defined | Reg5 false-value source | Encoded zero reads the architectural zero GPR. |
SrcRType | 2 | encoding-defined | CSEL-specific false-source modifier selector | Encoded zero is an assigned unmodified false-source alias. |
Loading WaveDrom diagram… The encoding table and WaveJSON remain available below.
| Decoded item | Bit range | Value |
|---|---|---|
| SrcP | 31:27 | variable |
| SrcRType | 26:25 | variable |
| SrcR | 24:20 | variable |
| SrcL | 19:15 | variable |
| Constant | 14:12 | 3'b000 |
| RegDst | 11:7 | variable |
| Constant | 6:0 | 7'b1110111 |
{
"reg": [
{
"bits": 7,
"name": "7'b1110111"
},
{
"bits": 5,
"name": "RegDst"
},
{
"bits": 3,
"name": "3'b000"
},
{
"bits": 5,
"name": "SrcL"
},
{
"bits": 5,
"name": "SrcR"
},
{
"bits": 2,
"name": "SrcRType"
},
{
"bits": 5,
"name": "SrcP"
}
],
"config": {
"bits": 32,
"fontsize": 13,
"hspace": 900,
"lanes": 1,
"offset": 0
}
}csel SrcP, SrcL, SrcR<.neg>, ->{t, u, Rd}
SrcPSrcLSrcRSrcRTypeRegDstThis Operation comes directly from the instruction owner; the page does not rewrite its behavior.
readonly func InstructionContractOperation_CSEL() => ScalarOperationbegin return ScalarOperation_CSEL;end;
pure func InstructionContractRightModifier_CSEL(encoded: bits(2)) => ScalarRightModifierbegin return DecodeScalarSelectRightModifier(encoded);end;readonly func InstructionContractHandler_CSEL() => ScalarSemanticHandlerbegin return ScalarHandler_ScalarConditionalSelect;end;
pure func InstructionContractFalseValue_CSEL( right: Word, encoded_modifier: bits(2)) => Wordbegin let modifier = InstructionContractRightModifier_CSEL(encoded_modifier); return ApplySelectModifier(right, modifier);end;
pure func InstructionContractResult_CSEL( predicate: Word, selected_true: Word, selected_false: Word, encoded_modifier: bits(2)) => Wordbegin let prepared_false = InstructionContractFalseValue_CSEL( selected_false, encoded_modifier); return ScalarConditionalSelect( predicate, selected_true, prepared_false);end;// PTO-INSTRUCTION: {"assembly":["csel SrcP, SrcL, SrcR<.neg>, ->{t, u, Rd}"],"block":[],"catalog_indices":[71],"catalog_records":[{"asm":"csel SrcP, SrcL, SrcR<.neg>, ->{t, u, Rd}","constraints":[],"encoding":[{"index":0,"mask":"0x0000707f","match":"0x00000077","width_bits":32}],"encoding_kind":"L32","fields":[{"name":"RegDst","pieces":[{"instruction_lsb":7,"value_lsb":0,"width":5}],"signedness":"encoding-defined","width":5},{"name":"SrcL","pieces":[{"instruction_lsb":15,"value_lsb":0,"width":5}],"signedness":"encoding-defined","width":5},{"name":"SrcP","pieces":[{"instruction_lsb":27,"value_lsb":0,"width":5}],"signedness":"encoding-defined","width":5},{"name":"SrcR","pieces":[{"instruction_lsb":20,"value_lsb":0,"width":5}],"signedness":"encoding-defined","width":5},{"name":"SrcRType","pieces":[{"instruction_lsb":25,"value_lsb":0,"width":2}],"signedness":"encoding-defined","width":2}],"form_id":"csel_32_ba77cbad3c99","length_bits":32,"mnemonic":"CSEL","semantic_family":"ALU","semantic_group":"ALU","semantic_handler":"ScalarConditionalSelect","semantic_summary":"CSEL snapshots three Reg5 sources, selects SrcL for a nonzero predicate or its optionally negated SrcR for zero, and publishes through the common scalar destination map.","status":"accepted"}],"classification":["alu"],"contract":{"block_composition":["none"],"canonical_assembly":["csel SrcP, SrcL, SrcR<.neg>, ->{t, u, Rd}"],"defaults":["SrcP, SrcL, SrcR, SrcRType, and RegDst are required encoded fields; no field can be omitted.","Assembly without .neg uses the canonical unmodified alias selected by the assembler. Raw SrcRType codes 00, 01, and 10 are assigned unmodified aliases; raw code 11 is .neg."],"encoding_class":"standalone-encoded","examples":["csel a0, a1, a2, ->a3","csel t#1, u#1, a0.neg, ->u","csel zero, a0, a1, ->zero"],"exceptions":["An unavailable selected T/U queue source raises Fault_IllegalInstruction before the destination effect and before TPC advances, including a source not selected by the predicate outcome.","CSEL raises no arithmetic, memory, alignment, permission, or control-flow exception."],"field_contracts":{},"field_zero_meanings":{"RegDst":"Encoded zero discards the result.","SrcL":"Encoded zero reads the architectural zero GPR.","SrcP":"Encoded zero reads the architectural zero GPR and therefore selects the false value.","SrcR":"Encoded zero reads the architectural zero GPR.","SrcRType":"Encoded zero is an assigned unmodified false-source alias."},"legality":["SrcP, SrcL, and SrcR codes 0..23 select absolute GPRs, 24..27 select T#1..T#4, and 28..31 select U#1..U#4 without consumption.","All four SrcRType values are assigned. Codes 00, 01, and 10 leave SrcR unchanged; code 11 negates the complete XLEN value modulo 2^PTO_XLEN.","RegDst codes 0 and 24..29 discard, codes 1..23 write GPRs, code 30 pushes U, and code 31 pushes T."],"memory_effects":["none"],"operands":[{"field":"SrcP","role":"Reg5 predicate source"},{"field":"SrcL","role":"Reg5 true-value source"},{"field":"SrcR","role":"Reg5 false-value source"},{"field":"SrcRType","role":"CSEL-specific false-source modifier selector"},{"field":"RegDst","role":"Reg5 destination or discard"}],"ordering":["Read all three Reg5 sources eagerly and non-consumingly before the destination write, even when the predicate outcome does not select one value.","Publish the selected value, then advance TPC by four bytes."],"standalone_opcode":true,"state_effects":["Snapshot SrcP, SrcL, and SrcR before any destination effect. Only an all-zero SrcP is false; every nonzero bit pattern is true.","For a true predicate publish the complete snapshotted SrcL. For a false predicate publish the complete snapshotted SrcR after the CSEL-specific raw modifier; negation wraps modulo 2^PTO_XLEN and does not fault.","No memory, reservation, descriptor, numeric-status, block, privilege, branch-target, or other control state changes. Successful execution advances TPC by four bytes."]},"depends_on":["PTO-BLOCK-MODEL-SCHEMA-PROFILE-ENCODING"],"id":"PTO-SCALAR-CSEL","mnemonic":"CSEL","summary":"CSEL snapshots three Reg5 sources, selects SrcL for a nonzero predicate or its optionally negated SrcR for zero, and publishes through the common scalar destination map.","surface":"scalar"}// PTO-REVIEW: {"review_method":"formal-definition-read","outcome":"FORMAL-COMPLETE","reviewed_fields":["assembly","encoding","defaults","operation","state","memory","ordering","faults","reserved"]}// DOC-BEGIN: decodereadonly func InstructionContractOperation_CSEL() => ScalarOperationbegin return ScalarOperation_CSEL;end;
pure func InstructionContractRightModifier_CSEL(encoded: bits(2)) => ScalarRightModifierbegin return DecodeScalarSelectRightModifier(encoded);end;// DOC-END: decode// DOC-BEGIN: operationreadonly func InstructionContractHandler_CSEL() => ScalarSemanticHandlerbegin return ScalarHandler_ScalarConditionalSelect;end;
pure func InstructionContractFalseValue_CSEL( right: Word, encoded_modifier: bits(2)) => Wordbegin let modifier = InstructionContractRightModifier_CSEL(encoded_modifier); return ApplySelectModifier(right, modifier);end;
pure func InstructionContractResult_CSEL( predicate: Word, selected_true: Word, selected_false: Word, encoded_modifier: bits(2)) => Wordbegin let prepared_false = InstructionContractFalseValue_CSEL( selected_false, encoded_modifier); return ScalarConditionalSelect( predicate, selected_true, prepared_false);end;// DOC-END: operation
CSEL is a 32-bit scalar ALU instruction. It selects the left value for a nonzero predicate, otherwise selecting the optionally negated right value; its current instruction contract defines the result publication path and any additional state effect.
Execution snapshots the encoded inputs, then selects the left value for a nonzero predicate, otherwise selecting the optionally negated right value, and only afterward performs the destination effects.
SrcRType chooses the right-source transformation before the operation-specific arithmetic or logical step.SrcP field selects the predicate value through Reg5.SrcL field selects the value used for a true predicate.SrcR field selects the value used for a false predicate.SrcRType field selects the CSEL transformation applied to the false-side source.RegDst field selects the Reg5 result target or discards the result.These roles come from the current instruction contract. T/U sources are read and snapshotted without being removed from their queues; exact encoded-zero meanings appear in the generated defaults below.
Every scalar source is snapshotted before the destination effect. The completed value is then routed through RegDst using the current scalar destination map.
This ALU operation has no memory effect. After its successful architectural effects, TPC advances by 4 bytes.
The operation does not introduce a hidden scalar publication target or an implicit memory access. Architectural changes remain limited to the state effects enumerated by the current contract.
All three sources are read before selection; an unavailable T/U source faults with Fault_IllegalInstruction before publication even when the predicate would choose the other side.
The generated legality table is authoritative for assigned field values, reserved encodings, and destination discard codes. Decode and source availability are checked before architectural effects.
This example illustrates the current ASL owner and does not replace the normative operation.
For a small CSEL example, predicate 0, false-side value 3, and the negating selector publish -3 modulo 2^PTO_XLEN.
Bodies come from owning ASL. Dragging or buttons change only this page-session view order.
No NDF clause is attached to this unit.
12 matching entries
PTO-AVS-SCALAR-CSEL-ALIASES-001tests/asl/scalar/alu/CSEL/scalar-bound-csel-aliases-001.asl8189404df01d4047752cc85b48f3afb4f45b4d2f8283d0e71947746019405c7ePTO-AVS-SCALAR-CSEL-DECODE-001tests/asl/scalar/alu/CSEL/scalar-decode-csel-canonical-001.asld737c823173a6e5b655f0ee1e8848febf1ded43f1c578e06c1b41cd1400df00ePTO-AVS-SCALAR-CSEL-MODIFIER-001tests/asl/scalar/alu/CSEL/scalar-bound-csel-modifier-001.aslee8bbc2c9f01e69fdf27b1e237503e9c92c7e33c8ce79bec2c6492f871f3fab1PTO-AVS-SCALAR-CSEL-READINESS-001tests/asl/scalar/alu/CSEL/scalar-fault-csel-readiness-001.asl7735a3865de594610fcc151ab00b03e8630be4d6da113d36b51730ec08493343PTO-AVS-SCALAR-CSEL-SELECT-001tests/asl/scalar/alu/CSEL/scalar-exec-csel-select-001.aslfa403f1fd88912b725154984d9154320c6fac4c596c6db17358014cebafab991PTO-EVIDENCE-RELEASE-TRACEABILITYPTO-EVIDENCE-RELEASE-TRACEABILITYspec/evidence/release-traceability-readiness.jsonc7327021d39dc67ac5564bc55073b3870a397d79ac8d9648284d56e33bc14a3ePTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSUREPTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSUREspec/evidence/instruction-contract-closure.json3ef2bb62421c79dff8fa77a1c7983923b523244b8090812883ef81286ca8106aPTO-EVIDENCE-ARCHITECTURE-READINESSPTO-EVIDENCE-ARCHITECTURE-READINESSspec/evidence/architecture-readiness.json4b0b85199101251bea744e0f3591cc31906909dc80d5ab651c417a936036a004PTO-EVIDENCE-RELEASE-GATE-READINESSPTO-EVIDENCE-RELEASE-GATE-READINESSspec/evidence/release-gate-readiness.jsona0f4d2b6920c08981ea55fd8ef820708a40d4feb5402c5150e8e9ab532d84ce0PTO-EVIDENCE-RELEASE-MANIFESTPTO-EVIDENCE-RELEASE-MANIFESTspec/release-manifest.json1a64c109ed7a90351c41e2a418b3c0ebaf8ad975838986d2101385186b85c0d8Loading ADR-0026…
ADR-0026docs/status/decisions/0026-scalar-alu-totality-and-alias-order.md41d126f224dddc371832120f1b02eab64e426872fdcbea452bad77c90bdec349Loading ADR-0059…
ADR-0059docs/status/decisions/0059-mnemonic-field-encoding-closure.mdf18d13f735cfaf9f2803c754c5818f4af33d1cc42c489f0d9ce060b07bb3a196{
"classification": [
"alu"
],
"documentation": "docs/scalar/alu/CSEL.md",
"id": "PTO-SCALAR-CSEL",
"instruction_contract": {
"artifact": "spec/evidence/instruction-contract-closure.json",
"mnemonic": "CSEL",
"ndf_clause": "PTO-INST-SCALAR-CSEL"
},
"mnemonic": "CSEL",
"readiness_subjects": [
"ADR-0026",
"ADR-0059"
],
"semantic_tests": [
"PTO-AVS-SCALAR-CSEL-ALIASES-001",
"PTO-AVS-SCALAR-CSEL-MODIFIER-001",
"PTO-AVS-SCALAR-CSEL-READINESS-001",
"PTO-AVS-SCALAR-CSEL-SELECT-001"
],
"source": "asl/scalar/alu/CSEL.asl",
"surface": "scalar",
"tests": [
"PTO-AVS-SCALAR-CSEL-ALIASES-001",
"PTO-AVS-SCALAR-CSEL-DECODE-001",
"PTO-AVS-SCALAR-CSEL-MODIFIER-001",
"PTO-AVS-SCALAR-CSEL-READINESS-001",
"PTO-AVS-SCALAR-CSEL-SELECT-001"
]
}0.58.5 · Release candidate7dc8b7e5b121d2b2499a2273bebff29e2cd8681279b14f86ccca58efb097e635b619db93e7d18188cf36ff488f5f8328c8c7a4440beb9ac79efc1efd0af89907073dcd9e80fe45dab0d4a750a7140be14cd9eea2asl/scalar/alu/CSEL.aslasl/scalar/alu/CSEL.asl