Categories
CPU Digital Design RISC-V

RISC-V std review Note 1

RISC-V

This is the notes for reviewing riscv-spec-v2.2.pdf
– no branch delay slots
– optional variable-length instruction encoding

instruction set

  • characterized by width of integer registers
Instruction set integer width (bit)
RV32x 32
RV64x 64
suffix meaning
I basic integer operation
M integer multiplication and division
A atmoic read, modify and write memory
F single-precision floating-point
D double-precision floating-point
G general-purpose scalar intsruction (IMAFD)
  • fixed-length 32-bit instructions must aligned on 32-bit boundaries
  • variable-length instructions align on 16-bit
  • compressed 16-bit instructions allow aligned on 16-bit

Instruction Length Encoding

+---------+---------+------------+------------+
| Length  | offset  |     byte 0 |     byte 1 |
+---------+---------+------------+------------+
|  16 bit |         | 0bxxxxxx00 | 0bxxxxxxxx |
|         |         | 0bxxxxxx01 | 0bxxxxxxxx |
|         |         | 0bxxxxxx10 | 0bxxxxxxxx |
+---------+---------+------------+------------|
|  32 bit |         | 0bxxx00011 | 0bxxxxxxxx |
|         |         | 0bxxx00111 | 0bxxxxxxxx |
|         |         | 0bxxx01011 | 0bxxxxxxxx |
|         |         | 0bxxx01111 | 0bxxxxxxxx |
|         |         | 0bxxx10011 | 0bxxxxxxxx |
|         |         | 0bxxx10111 | 0bxxxxxxxx |
|         |         | 0bxxx11011 | 0bxxxxxxxx |
+---------+---------+------------+------------|
|  48 bit |         | 0bxx011111 | 0bxxxxxxxx |
+---------+---------+------------+------------|
|  64 bit |         | 0bx0111111 | 0bxxxxxxxx |
+---------+---------+------------+------------|
|  80 bit |         | 0bx1111111 | 0bx000xxxx |
+---------+---------+------------+------------|
|  96 bit |         | 0bx1111111 | 0bx001xxxx |
+---------+---------+------------+------------|
| 112 bit |         | 0bx1111111 | 0bx010xxxx |
+---------+---------+------------+------------|
| 128 bit |         | 0bx1111111 | 0bx011xxxx |
+---------+---------+------------+------------|
Categories
Digital Design

Digital Logic 101.1: Numeric System

Base 10 (a.k.a. decimal) is the numeric system which most people using in daily life.

For the digital logic or computer system in nowadays, it would use binary instead. Binary only have two values, 0 and 1. For any number that larger than one, it should be represented by two digital.

$latex 2_{10} = 10_2$
$latex 5_{10} = 101_2$

A number represented as binary has longer length comparing with decimal. Usually, hexadecimal is used for written down in the program.

$latex 1_{10} = 1_{2} = 1_{16}$
$latex 2_{10} = 10_{2} = 2_{16}$
$latex 3_{10} = 11_{2} = 3_{16}$
$latex 4_{10} = 100_{2} = 4_{16}$
$latex 5_{10} = 101_{2} = 5_{16}$
$latex 6_{10} = 110_{2} = 6_{16}$
$latex 7_{10} = 111_{2} = 7_{16}$
$latex 8_{10} = 1000_{2} = 8_{16}$
$latex 9_{10} = 1001_{2} = 9_{16}$
$latex 10_{10} = 1010_{2} = A_{16}$
$latex 11_{10} = 1011_{2} = B_{16}$
$latex 12_{10} = 1100_{2} = C_{16}$
$latex 13_{10} = 1101_{2} = D_{16}$
$latex 14_{10} = 1110_{2} = E_{16}$
$latex 15_{10} = 1111_{2} = F_{16}$
$latex 16_{10} = 10000_{2} = 10_{16}$

Prefixes is add for represent the binary and hexadecimal in the source code. Here is the example in C.
0x0A