# I-type

## I-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-c76a3b3b5bda42297e0aa6a7b53a9bbe7f54c792%2Fi-type.png?alt=media" alt=""><figcaption></figcaption></figure>

* The `funct7` and `rs2` fields from R-format are replaced by 12-bit signed immediate, `imm[11:0]` (in range \[-2048, 2047]).
* Remaining fields (`rs1`, `funct3`, `rd`, `opcode`) same as R-format.
* Immediate is always sign-extended to 32-bits before use in an arithmetic operation.

### I-immediate

<figure><img src="https://733403343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz6F38NLmIOefVEORubUB%2Fuploads%2Fgit-blob-2c9d9fee946f9d0410b763f2dc9a8e425164602a%2Fi-immediate.jpg?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-4d97a19d0d3ea1a562c03800fa643ce77397c440%2Fimmgen-i.jpg?alt=media" alt=""><figcaption><p>Immediate generator generates I-type immediate</p></figcaption></figure>

## I-Format Arithmetic Instructions

<figure><img src="https://733403343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz6F38NLmIOefVEORubUB%2Fuploads%2Fgit-blob-7b853ec51f07410ca818573ed65d0c38161c531e%2Fi-type-instructions.png?alt=media" alt=""><figcaption><p>I-Format Arithmetic Instructions</p></figcaption></figure>

### Adding I-Format arithmetic instructions to datapath

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

## I-Format Load Instructions

Load instructions are also I-type.

<figure><img src="https://733403343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz6F38NLmIOefVEORubUB%2Fuploads%2Fgit-blob-671c006841c1437c8468023fa22797b1f332fbdb%2Fload-instruction-layout.png?alt=media" alt=""><figcaption><p>Load Instruction Layout</p></figcaption></figure>

* Reg\[rd] <- Mem\[Reg\[rs1] + offset]
  * The 12-bit immediate is added to the base address in `rs1` to form the memory address
  * The value loaded from memory is stored in register `rd`

<figure><img src="https://733403343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz6F38NLmIOefVEORubUB%2Fuploads%2Fgit-blob-ad297c9ed209d40565209e71861b2ae67c4369fa%2Fi-type-load-instructions.png?alt=media" alt=""><figcaption><p>I-Format Load Instructions</p></figcaption></figure>

{% hint style="info" %}
Note that the `funct3` field is to specify the width (i.e., the amount of bytes) and signedness of load data.
{% endhint %}

### Adding load instructions to datapath

<figure><img src="https://733403343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz6F38NLmIOefVEORubUB%2Fuploads%2Fgit-blob-18ddd581f3f9801cd7284e033e27ed42710846d5%2Fdatapath3.jpg?alt=media" alt=""><figcaption></figcaption></figure>
