# U-type

## U-Format Instruction Layout

<figure><img src="https://733403343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz6F38NLmIOefVEORubUB%2Fuploads%2Fgit-blob-5e975ce15a0dadd63d2ddbf0e616ef5d4be2cf1b%2Fu-type.png?alt=media" alt=""><figcaption></figcaption></figure>

## U-Format Instructions

<figure><img src="https://733403343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz6F38NLmIOefVEORubUB%2Fuploads%2Fgit-blob-d3c677191d5e5c555f4e82c48e379dbcd2dcd4b9%2Flui-and-auipc.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://733403343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz6F38NLmIOefVEORubUB%2Fuploads%2Fgit-blob-0d3e054424374dccaa18f7b166c503f57734af21%2Fu-type-instructions.png?alt=media" alt=""><figcaption></figcaption></figure>

* LUI - Load Upper Immediate
  * `Reg[rd] = {imm, 12'b0}`
* AUIPC - Add Upper Immediate to PC
  * `Reg[rd] = PC + {imm, 12'b0}`

> The combination of an AUIPC and the 12-bit immediate in a JALR can transfer control to any 32-bit PC-relative address, while an AUIPC plus the 12-bit immediate offset in regular load or store instructions can access any 32-bit PC-relative data address.
>
> The current PC can be obtained by setting the U-immediate to 0. Although a JAL +4 instruction could also be used to obtain the local PC (of the instruction following the JAL), it might cause pipeline breaks in simpler microarchitectures or pollute BTB structures in more complex microarchitectures.

## Adding U-Format instructions to datapath

{% hint style="info" %}
What should be added to datapath?
{% endhint %}
