> For the complete documentation index, see [llms.txt](https://byrzhm.gitbook.io/build-a-risc-v-chip-from-scratch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://byrzhm.gitbook.io/build-a-risc-v-chip-from-scratch/tutorial/datapath/u-type.md).

# U-type

## U-Format Instruction Layout

<figure><img src="/files/3sIyrITviZb6bOsonVp1" alt=""><figcaption></figcaption></figure>

## U-Format Instructions

<figure><img src="/files/evcUlzhIbAcyeH1vdMRs" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/9mcbEeBMGHKFzik5Xlcf" 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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://byrzhm.gitbook.io/build-a-risc-v-chip-from-scratch/tutorial/datapath/u-type.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
