跳到主要内容

PTO-ARCH-GQM

PTO-ARCH-GQM

ASL 伪代码

下面直接显示完整的 ASL 所有者。

// PTO-UNIT: {"id":"PTO-ARCH-GQM","surface":"arch","classification":["programming-model","general-queue-management"],"depends_on":["PTO-ARCH-PROGRAMMING-MODEL-EXECUTION-CONTEXT"]}// PTO-STATE: {"id":"PTO-STATE-ARCH-GQM","classification":["architecture","general-queue-management"],"scope":"system","owner":"PTO-ARCH-GQM","members":["_GQMQueueValid","_GQMQueueAddress","_GQMQueueCapacity","_GQMQueueCount","_GQMQueueHead","_GQMQueueSuspended","_GQMQueueCorrupt","_GQMQueueEntries","_GQMReleaseEpoch","_LastGQMAcquireEpoch","_GQMEventEpoch","_LastGQMEventAddress"],"depends_on":[]}
constant PTO_GQM_MAX_CAPACITY = 1023;
// This bound sizes executable verification backing. It is not an// architectural limit on the number of simultaneously initialized queues.config PTO_MODEL_GQM_QUEUE_SLOTS : integer {1..16} = 4;
type GQMQueueSlot of integer {0..PTO_MODEL_GQM_QUEUE_SLOTS-1};// The lookup result includes one sentinel value.  Use the configured maximum// as the static type bound so ASLRef can prove assignments for every allowed// PTO_MODEL_GQM_QUEUE_SLOTS value.type GQMQueueLookup of integer {0..16};type GQMQueueCapacity of integer {0..PTO_GQM_MAX_CAPACITY};type GQMQueueEntryIndex of integer {0..PTO_GQM_MAX_CAPACITY-1};
type GQMQueueEntry of record {    value: Word,    release_epoch: integer};
type GQMQueueEntryArray of array [[PTO_GQM_MAX_CAPACITY]] of GQMQueueEntry;type GQMQueueEntryStore of array [[PTO_MODEL_GQM_QUEUE_SLOTS]]    of GQMQueueEntryArray;
type GQMPopResult of record {    data: Word,    result: Word};
var _GQMQueueValid : array [[PTO_MODEL_GQM_QUEUE_SLOTS]] of boolean;var _GQMQueueAddress : array [[PTO_MODEL_GQM_QUEUE_SLOTS]] of Word;var _GQMQueueCapacity : array [[PTO_MODEL_GQM_QUEUE_SLOTS]]    of GQMQueueCapacity;var _GQMQueueCount : array [[PTO_MODEL_GQM_QUEUE_SLOTS]]    of GQMQueueCapacity;var _GQMQueueHead : array [[PTO_MODEL_GQM_QUEUE_SLOTS]]    of GQMQueueEntryIndex;var _GQMQueueSuspended : array [[PTO_MODEL_GQM_QUEUE_SLOTS]] of boolean;var _GQMQueueCorrupt : array [[PTO_MODEL_GQM_QUEUE_SLOTS]] of boolean;var _GQMQueueEntries : GQMQueueEntryStore;var _GQMReleaseEpoch : integer;var _LastGQMAcquireEpoch : integer;var _GQMEventEpoch : integer;var _LastGQMEventAddress : Word;
pure func GQMResult(primary: integer {0..8191},                    status: bits(2)) => Wordbegin    var result = Zeros{PTO_XLEN};    result[12:0] = Zeros{13} + primary;    result[63:62] = status;    return result;end;
readonly func FindGQMQueue(address: Word) => GQMQueueLookupbegin    var selected: GQMQueueLookup =        PTO_MODEL_GQM_QUEUE_SLOTS as GQMQueueLookup;    for candidate = 0 to PTO_MODEL_GQM_QUEUE_SLOTS - 1 do        let slot = candidate as GQMQueueSlot;        if selected == PTO_MODEL_GQM_QUEUE_SLOTS &&           _GQMQueueValid[[slot]] &&           _GQMQueueAddress[[slot]] == address then            selected = slot as GQMQueueLookup;        end;    end;    return selected;end;
readonly func FindFreeGQMQueue() => GQMQueueLookupbegin    var selected: GQMQueueLookup =        PTO_MODEL_GQM_QUEUE_SLOTS as GQMQueueLookup;    for candidate = 0 to PTO_MODEL_GQM_QUEUE_SLOTS - 1 do        let slot = candidate as GQMQueueSlot;        if selected == PTO_MODEL_GQM_QUEUE_SLOTS &&           !_GQMQueueValid[[slot]] then            selected = slot as GQMQueueLookup;        end;    end;    return selected;end;
readonly func GQMQueueInitialized(address: Word) => booleanbegin    return FindGQMQueue(address) != PTO_MODEL_GQM_QUEUE_SLOTS;end;
readonly func GQMQueueRemaining(address: Word) => GQMQueueCapacitybegin    let found = FindGQMQueue(address);    if found == PTO_MODEL_GQM_QUEUE_SLOTS then        return 0;    end;    let slot = found as GQMQueueSlot;    return (_GQMQueueCapacity[[slot]] - _GQMQueueCount[[slot]])        as GQMQueueCapacity;end;
readonly func GQMQueueSuspended(address: Word) => booleanbegin    let found = FindGQMQueue(address);    return if found == PTO_MODEL_GQM_QUEUE_SLOTS then        FALSE    else        _GQMQueueSuspended[[found as GQMQueueSlot]];end;
readonly func GQMQueueHeadValue(address: Word) => Wordbegin    let slot = FindGQMQueue(address) as GQMQueueSlot;    assert _GQMQueueCount[[slot]] > 0;    return _GQMQueueEntries[[slot]][[_GQMQueueHead[[slot]]]].value;end;
readonly func GQMQueueHeadReleaseEpoch(address: Word) => integerbegin    let slot = FindGQMQueue(address) as GQMQueueSlot;    assert _GQMQueueCount[[slot]] > 0;    return _GQMQueueEntries[[slot]][[_GQMQueueHead[[slot]]]].release_epoch;end;
func ResetGQMState()begin    for candidate = 0 to PTO_MODEL_GQM_QUEUE_SLOTS - 1 do        let slot = candidate as GQMQueueSlot;        _GQMQueueValid[[slot]] = FALSE;        _GQMQueueAddress[[slot]] = Zeros{PTO_XLEN};        _GQMQueueCapacity[[slot]] = 0;        _GQMQueueCount[[slot]] = 0;        _GQMQueueHead[[slot]] = 0;        _GQMQueueSuspended[[slot]] = FALSE;        _GQMQueueCorrupt[[slot]] = FALSE;    end;    _GQMReleaseEpoch = 0;    _LastGQMAcquireEpoch = 0;    _GQMEventEpoch = 0;    _LastGQMEventAddress = Zeros{PTO_XLEN};end;
func InitializeGQMQueue(address: Word,                        capacity: GQMQueueCapacity) => GQMQueueSlotbegin    var found = FindGQMQueue(address);    if found == PTO_MODEL_GQM_QUEUE_SLOTS then        found = FindFreeGQMQueue();    end;
    // The executable profile must provide enough backing for its workload.    // This assertion does not define an architectural queue-count limit.    assert found != PTO_MODEL_GQM_QUEUE_SLOTS;    let slot = found as GQMQueueSlot;    _GQMQueueValid[[slot]] = TRUE;    _GQMQueueAddress[[slot]] = address;    _GQMQueueCapacity[[slot]] = capacity;    _GQMQueueCount[[slot]] = 0;    _GQMQueueHead[[slot]] = 0;    _GQMQueueSuspended[[slot]] = FALSE;    _GQMQueueCorrupt[[slot]] = FALSE;    return slot;end;
func SetGQMQueueSuspended(address: Word, suspended: boolean)begin    let found = FindGQMQueue(address);    if found != PTO_MODEL_GQM_QUEUE_SLOTS then        _GQMQueueSuspended[[found as GQMQueueSlot]] = suspended;    end;end;
func SetGQMQueueCorrupt(address: Word, corrupt: boolean)begin    let found = FindGQMQueue(address);    if found != PTO_MODEL_GQM_QUEUE_SLOTS then        _GQMQueueCorrupt[[found as GQMQueueSlot]] = corrupt;    end;end;
func BroadcastGQMEvent(address: Word)begin    _GQMEventEpoch = _GQMEventEpoch + 1;    _LastGQMEventAddress = address;end;
func PushGQMQueueEntry(address: Word,                       value: Word,                       at_head: boolean,                       relaxed: boolean,                       notify_event: boolean) => Wordbegin    let found = FindGQMQueue(address);    if found == PTO_MODEL_GQM_QUEUE_SLOTS then        return GQMResult(0, '10');    end;
    let slot = found as GQMQueueSlot;    if _GQMQueueCorrupt[[slot]] then        return GQMResult(0, '10');    end;
    let remaining = GQMQueueRemaining(address);    if _GQMQueueSuspended[[slot]] || remaining == 0 then        return GQMResult(remaining, '01');    end;
    var entry_index: GQMQueueEntryIndex = 0;    if at_head then        if _GQMQueueHead[[slot]] == 0 then            entry_index = (_GQMQueueCapacity[[slot]] - 1)                as GQMQueueEntryIndex;        else            entry_index = (_GQMQueueHead[[slot]] - 1)                as GQMQueueEntryIndex;        end;        _GQMQueueHead[[slot]] = entry_index;    else        entry_index = ((_GQMQueueHead[[slot]] + _GQMQueueCount[[slot]])            MOD _GQMQueueCapacity[[slot]]) as GQMQueueEntryIndex;    end;
    var release_epoch: integer = 0;    if !relaxed then        _GQMReleaseEpoch = _GQMReleaseEpoch + 1;        release_epoch = _GQMReleaseEpoch;    end;    _GQMQueueEntries[[slot]][[entry_index]].value = value;    _GQMQueueEntries[[slot]][[entry_index]].release_epoch = release_epoch;    _GQMQueueCount[[slot]] = (_GQMQueueCount[[slot]] + 1)        as GQMQueueCapacity;
    if notify_event then        BroadcastGQMEvent(address);    end;    return GQMResult(GQMQueueRemaining(address), '00');end;
func PopGQMQueueEntry(address: Word,                      relaxed: boolean,                      notify_event: boolean) => GQMPopResultbegin    var response = GQMPopResult {        data = Zeros{PTO_XLEN},        result = GQMResult(0, '10')    };    let found = FindGQMQueue(address);    if found == PTO_MODEL_GQM_QUEUE_SLOTS then        return response;    end;
    let slot = found as GQMQueueSlot;    if _GQMQueueCorrupt[[slot]] then        return response;    elsif _GQMQueueCount[[slot]] == 0 then        response.result = GQMResult(0, '01');        return response;    end;
    let head = _GQMQueueHead[[slot]];    let entry = _GQMQueueEntries[[slot]][[head]];    let next_head = ((head + 1) MOD _GQMQueueCapacity[[slot]])        as GQMQueueEntryIndex;    _GQMQueueHead[[slot]] = next_head;    _GQMQueueCount[[slot]] = (_GQMQueueCount[[slot]] - 1)        as GQMQueueCapacity;    if _GQMQueueCount[[slot]] == 0 then        _GQMQueueHead[[slot]] = 0;    end;
    if !relaxed && entry.release_epoch != 0 then        _LastGQMAcquireEpoch = entry.release_epoch;    end;    if notify_event then        BroadcastGQMEvent(address);    end;    response.data = entry.value;    response.result = GQMResult(_GQMQueueCount[[slot]], '00');    return response;end;

架构行为

目的与范围

用途与范围

通用队列管理对按地址访问的队列、队列条目以及队列操作返回的状态进行建模。PTO-STATE-ARCH-GQM 拥有队列表、条目存储、释放与获取纪元,以及事件观测状态。

该所有者定义初始化、暂停与损坏状态、压入与弹出行为以及事件通知。指令解码仍由调用这些辅助函数的指令所有者定义。

概念与架构状态

队列状态与结果字

每个有效模型槽记录地址、容量、计数、队头、暂停标志、损坏标志和条目数组。每个条目包含一个 Word 值和一个释放纪元。

GQMResult 把主值放入位 12:0,把两位状态放入位 63:62;其他结果位从零开始。状态 00 表示成功路径。压入操作在队列暂停或已满时使用 01,弹出操作则在队列为空时使用 01。状态 10 用于队列不存在或已经损坏。

规则与交互

压入、弹出与通知

PushGQMQueueEntry 拒绝不存在或损坏的队列;对于暂停或已满的队列,它返回剩余容量;否则根据 at_head 在队头或队尾插入。非宽松压入会递增 _GQMReleaseEpoch 并把该纪元存入条目;宽松压入存入纪元 0。

PopGQMQueueEntry 对不存在或损坏的队列返回零数据和状态 10,对空队列返回状态 01,否则移除队头条目。非宽松弹出会把条目中非零的释放纪元复制到 _LastGQMAcquireEpoch。

当成功压入或弹出的 notify_event 为真时,BroadcastGQMEvent 递增 _GQMEventEpoch,并在 _LastGQMEventAddress 中记录队列地址。

边界与未定义范围

容量与模型边界

单个队列的容量范围为 0 到 1023。PTO_MODEL_GQM_QUEUE_SLOTS 可配置为 1 到 16,默认值为 4;但所有者明确把它当作可执行验证的后备容量,而不是已初始化队列数量的架构限制。

初始化会复用相同地址的现有槽,或者选择第一个空闲槽。可执行配置档必须为其工作负载提供足够的模型槽;槽耗尽会触发断言,而不是定义一个可移植的队列数量失败结果。

使用示例

示例性队列流程示例

对于容量为二的队列,一次成功的队尾压入会把计数从零改为一,并报告剩余一个条目。随后进行非宽松弹出会返回所存值,把计数恢复为零、把队头复位为零,并观测条目的非零释放纪元。

这个流程仅用于说明;嵌入的 ASL 仍是状态字段和状态更新顺序的确切来源。

相关所有者

  • 执行上下文提供 GQM 所依赖的架构上下文。
  • 内存排序拥有架构排序关系;GQM 的纪元字段不会取代该所有者。
  • 陷阱上下文拥有执行上下文的可移植保存与恢复行为。

NDF 条款

正文来自 owning ASL。拖拽或按钮只临时改变当前页面显示顺序。

No NDF clause is attached to this unit.

Evidence index

8 matching entries

Executable evidence3
  • profile reset clears all executable GQM backing and synchronization state
    1. surfaceARCH
    2. ownerPTO-ARCH-GQM
    3. categorySTATE-TRANSITION
    4. case001
    Show exact test source
    Sources and references
    Complete stable ID
    PTO-AVS-ARCH-GQM-RESET-001
    Path
    tests/asl/arch/programming-model/general-queue-management/arch-state-gqm-reset-001.asl
    Kind / role
    state-transition
    Requirements
    PTO-ARCH-STATE-CLOSURE-001
    Pass condition
    no queue remains initialized and all release, acquire, and event epochs return to zero
    SHA-256
    f980461e16798a8dea175e7d5b8d133f112cb094f4bb17505900c3f8a70701b9
    Open exact source ↗ for PTO-AVS-ARCH-GQM-RESET-001
  • PTO-ARCH-GQM compiles as an independent normative unit
    1. surfaceARCH
    2. ownerPTO-ARCH-GQM
    3. categorySTATIC-INVARIANT
    4. case001
    Show exact test source
    Sources and references
    Complete stable ID
    PTO-AVS-ARCH-GQM-STATIC-001
    Path
    tests/asl/arch/programming-model/general-queue-management/arch-static-general-queue-management-contract-001.asl
    Kind / role
    static-invariant
    Pass condition
    the complete model and this unit's static invariant compile
    SHA-256
    1d97025dc12002cade094c6203613364afdce86c9fcef3177c4e9cdbaf1c06c7
    Open exact source ↗ for PTO-AVS-ARCH-GQM-STATIC-001
  • GQM push and pop report operation-specific success, retry, and error status
    1. surfaceARCH
    2. ownerPTO-ARCH-GQM
    3. categorySTATE-TRANSITION
    4. case002
    Show exact test source
    Sources and references
    Complete stable ID
    PTO-AVS-ARCH-GQM-STATUS-002
    Path
    tests/asl/arch/programming-model/general-queue-management/arch-state-gqm-status-002.asl
    Kind / role
    state-transition
    Pass condition
    full and suspended pushes report retry, empty pop reports retry, suspended non-empty pop succeeds, and missing or corrupt queues report error
    SHA-256
    0ee5f8f97ff9c45cf90fb1f5e54042cad7595b14d73289610e24d285aaa9f47c
    Open exact source ↗ for PTO-AVS-ARCH-GQM-STATUS-002
Commit-scoped evidence5
  • spec/evidence/release-traceability-readiness.json · closedPTO-EVIDENCE-RELEASE-TRACEABILITY
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-RELEASE-TRACEABILITY
    Path
    spec/evidence/release-traceability-readiness.json
    Kind / role
    ASL/NDF/documentation/AVS traceability
    SHA-256
    c7327021d39dc67ac5564bc55073b3870a397d79ac8d9648284d56e33bc14a3e
    Open exact source ↗ for PTO-EVIDENCE-RELEASE-TRACEABILITY
  • spec/evidence/instruction-contract-closure.json · closedPTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSURE
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSURE
    Path
    spec/evidence/instruction-contract-closure.json
    Kind / role
    mnemonic and encoding contract closure
    SHA-256
    3ef2bb62421c79dff8fa77a1c7983923b523244b8090812883ef81286ca8106a
    Open exact source ↗ for PTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSURE
  • spec/evidence/architecture-readiness.json · openPTO-EVIDENCE-ARCHITECTURE-READINESS
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-ARCHITECTURE-READINESS
    Path
    spec/evidence/architecture-readiness.json
    Kind / role
    architecture maturity and blockers
    SHA-256
    4b0b85199101251bea744e0f3591cc31906909dc80d5ab651c417a936036a004
    Open exact source ↗ for PTO-EVIDENCE-ARCHITECTURE-READINESS
  • spec/evidence/release-gate-readiness.json · ready-for-exact-head-verificationPTO-EVIDENCE-RELEASE-GATE-READINESS
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-RELEASE-GATE-READINESS
    Path
    spec/evidence/release-gate-readiness.json
    Kind / role
    exact-head gate readiness
    SHA-256
    a0f4d2b6920c08981ea55fd8ef820708a40d4feb5402c5150e8e9ab532d84ce0
    Open exact source ↗ for PTO-EVIDENCE-RELEASE-GATE-READINESS
  • spec/release-manifest.json · draftPTO-EVIDENCE-RELEASE-MANIFEST
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-RELEASE-MANIFEST
    Path
    spec/release-manifest.json
    Kind / role
    release content and encoding fingerprints
    SHA-256
    1a64c109ed7a90351c41e2a418b3c0ebaf8ad975838986d2101385186b85c0d8
    Open exact source ↗ for PTO-EVIDENCE-RELEASE-MANIFEST

Unit metadata

Open 4 generated metadata fields
id
PTO-ARCH-GQM
surface
arch
classification
[
  "programming-model",
  "general-queue-management"
]
depends_on
[
  "PTO-ARCH-PROGRAMMING-MODEL-EXECUTION-CONTEXT"
]
Open generated traceability record
{
  "classification": [
    "programming-model",
    "general-queue-management"
  ],
  "documentation": "docs/arch/programming-model/general-queue-management.md",
  "id": "PTO-ARCH-GQM",
  "mnemonic": null,
  "readiness_subjects": [],
  "semantic_tests": [
    "PTO-AVS-ARCH-GQM-RESET-001",
    "PTO-AVS-ARCH-GQM-STATUS-002"
  ],
  "source": "asl/arch/programming-model/general-queue-management.asl",
  "surface": "arch",
  "tests": [
    "PTO-AVS-ARCH-GQM-RESET-001",
    "PTO-AVS-ARCH-GQM-STATIC-001",
    "PTO-AVS-ARCH-GQM-STATUS-002"
  ]
}

来源与发布信息

展开 commit、路径、hash、版本和规范所有者
发布
0.58.5 · 候选发布
Commit
7dc8b7e5b121d2b2499a2273bebff29e2cd86812
ASL SHA-256
fbe8a1fa4b7b67271b461f5c5072891e1977c4a499653ea7fdd2b87a5a655493
文档 SHA-256
e7b299ccb14df70084e8614e427d9c4a7bed1183e8c8924ee05d384cf44f46b8

精确所有者

  • ASL PTO-ARCH-GQM asl/arch/programming-model/general-queue-management.asl