# Power ISA (PowerPC)

## 🧠 Conceito Fundamental

**Power ISA**, frequentemente associada ao nome histórico **PowerPC**, é uma arquitetura **RISC**, projetada inicialmente pela **IBM, Motorola e Apple** (consórcio AIM, anos 1990).\
Foi altamente utilizada em:

* Servidores corporativos (IBM POWER/Power Systems)
* Consoles de videogame (PS3, Xbox 360, Nintendo GameCube/Wii/Wii U)
* Sistemas embarcados automotivos e aeroespaciais

Hoje, a Power ISA é dominante principalmente em **data centers de alta performance e mainframes IBM**.

## 🧩 Características-Chave

| Característica       | Descrição                                           |
| -------------------- | --------------------------------------------------- |
| Paradigma            | **RISC puro** (instruções simples e previsíveis)    |
| Tamanho da Instrução | **32 bits fixos** (facilita decodificação)          |
| Modelo de Execução   | Load/Store (somente LOAD/STORE acessam memória)     |
| Registradores        | Muitos registradores de propósito geral e vetoriais |
| Pipeline             | Profundo, otimizado para **alto throughput**        |
| Finalidade           | Eficiência por watt + escalabilidade em HPC         |

## 🧱 Modelo de Registradores (Power ISA 64 bits)

### Registradores Inteiros

```
GPR0 – GPR31 (64 bits cada)
```

### Registradores de Ponto Flutuante (FPU)

```
FPR0 – FPR31 (64 bits IEEE754)
```

### Registradores Vetoriais (VMX / AltiVec / VSX)

```
VR0 – VR31 (128 bits SIMD)
```

### Registradores Especiais

| Nome          | Função                                  |
| ------------- | --------------------------------------- |
| **LR**        | Link Register (retorno de chamadas)     |
| **CTR**       | Contador de loop / branch               |
| **CR**        | Condition Register (32 flags agrupadas) |
| **XER**       | Fixed-Point Exception Register          |
| **SRR0/SRR1** | Salvamento de contexto para exceções    |

## 🎛️ Formato de Instruções (Simples e Estruturado)

As instruções seguem formatos rígidos, como:

```
| OPCODE (6 bits) | REGs | IMEDIATOS | FUNÇÕES |
```

Exemplo:

```asm
addi r3, r4, 16   ; r3 = r4 + 16
lwz  r5, 0(r6)    ; r5 = MEM[r6 + 0]
bne  label         ; branch se flags ≠ zero
```

## ⚡ Pipeline e Execução Interna (Ex.: IBM POWER9)

```mermaid
graph LR
    A[Fetch] --> B[Decode] --> C[Issue Queue]
    C --> D[Exec Units (ALU/FP/VMX/VSX/Branch)]
    D --> E[Reorder Buffer]
    E --> F[Commit]
```

### Recursos Modernos:

* **Out-of-Order Execution**
* **Simultaneous Multi-Threading (SMT2 / SMT4 / SMT8)** dependendo do modelo
* Execução vetorial **VSX** altamente eficiente (HPC / AI)

## 🏗️ Arquitetura de Memória (POWER)

```mermaid
graph TD
    A[L1 Instr] & B[L1 Data] --> C[L2 Privado]
    C --> D[L3 Compartilhado por Chip]
    D --> E[NVLink / OpenCAPI / PCIe]
    E --> F[RAM / GPU / Interconexões HPC]
```

* **L3** geralmente é *on-die e grande* (ex: 32–128 MB)
* Otimizado para **workloads massivamente paralelos**

## 🧬 VMX, AltiVec e VSX (Unidades Vetoriais)

| Extensão          | Largura                  | Usos                      |
| ----------------- | ------------------------ | ------------------------- |
| **VMX / AltiVec** | 128 bits SIMD            | Multimídia, codecs, DSP   |
| **VSX**           | 128 bits com FP avançado | HPC, IA, Machine Learning |

Exemplo:

```asm
vaddfp v2, v3, v4   ; soma vetorial ponto flutuante
```

## 🔥 Exemplo de Loop PowerPC

```asm
loop:
    lwz   r5, 0(r3)     ; carrega palavra
    add   r4, r4, r5    ; acumula
    addi  r3, r3, 4     ; avança ponteiro
    cmp   r3, r6        ; compara limite
    bne   loop
```

* Instruções diretas
* Operações **claras e previsíveis**
* Pipeline fácil de otimizar

## 🥊 Comparação Power ISA vs ARM vs x86 vs RISC-V

| Aspecto              | Power ISA        | ARM                | x86                   | RISC-V                            |
| -------------------- | ---------------- | ------------------ | --------------------- | --------------------------------- |
| Paradigma            | **RISC**         | RISC               | **CISC**              | RISC                              |
| Foco                 | HPC / Servidores | Mobile → HPC       | Desktops / Servidores | Flexibilidade / Abertura          |
| Tamanho da Instrução | Fixo (32b)       | 16/32b             | Variável              | Fixo (32b, compressões opcionais) |
| Vetorial             | VSX (forte)      | NEON / SVE         | SSE / AVX             | V (modular, escalável)            |
| Mercado Atual        | Servidores IBM   | Mobile + ARMv9 HPC | PC / Servidores       | IoT → HPC emergente               |

## 🚀 Onde Power ISA É Usado Hoje

* **IBM POWER9 / POWER10 Servers**
* Supercomputadores (Top500 já incluiu vários)
* Networking carrier-grade (roteadores, firewalls)
* Consoles legados:
  * GameCube / Wii → Broadway, Gekko
  * PS3 → CELL (PPE PowerPC central)
  * Xbox 360 → Xenon

## 🔧 Ferramentas para Desenvolvimento Power ISA

**Compilar:**

```bash
powerpc64le-linux-gnu-gcc -o programa programa.c
```

**Desmontar:**

```bash
powerpc64le-linux-gnu-objdump -D programa
```

**Emular:**

```bash
qemu-ppc64 ./programa
```

**Debug:**

```bash
gdb-multiarch ./programa
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://0xmorte.gitbook.io/bibliadopentestbr/conceitos/arquitetura-de-hardware/arquiteturas-de-processadores/power-isa-powerpc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
