6.5.11 · D1 · HinglishAdvanced & Emerging Architectures

FoundationsRISC-V custom extensions for accelerators

2,082 words9 min read↑ Read in English

6.5.11 · D1 · Hardware › Advanced & Emerging Architectures › RISC-V custom extensions for accelerators

Custom instructions samajhne se pehle, tumhe ek plain instruction bit by bit padhna aana chahiye. Yeh page har woh word aur symbol build karta hai jis par parent note rely karta hai, "bit kya hota hai" se shuru hokar "kyun 1024 ops ek opcode slot mein fit hote hain" tak. Yahan kuch bhi assumed nahi hai — agar parent ne use kiya, to hum define karte hain.


0. Bilkul base se: bits, bytes, aur ek 32-bit word

Figure dekho: 32 chhote boxes ek row mein, right se numbered. Sabse rightmost box bit hai, sabse leftmost bit hai. Yeh numbering direction matter karti hai kyunki CPU decide karta hai "yeh kaisi instruction hai?" right waale boxes pehle padhkar.


1. Opcode — "kaunsi family" ka tag

Kyunki 7 bits alag-alag patterns le sakti hain, at most possible opcode families ho sakti hain.


2. Registers, rs1, rs2, rd — fast scratchpad

32 registers mein se ek ka naam lene ke liye tumhe se tak ka number chahiye, aur , isliye 5 bits exactly ek register naam karte hain.

Figure register file ko 32 boxes ki stack ke roop mein dikhata hai jisme se do arrows nikalte hain (do read ports, rs1 aur rs2 ko feed karte hue) aur ek arrow andar jaata hai (ek write port, rd se driven). Yahi exact shape — two read, one write — kyun parent note baar baar kehta hai "hardware barely changes": tumhari custom instruction sirf unhi ports mein plug hoti hai jo already exist karti hain.


3. funct3 aur funct7 — "kaunsa flavour" tags

Jab opcode keh deta hai "yeh ek arithmetic-shaped instruction hai", CPU ko phir bhi jaanna hota hai kaunsi wali: add? subtract? multiply? Yeh extra selector bits funct fields hain.


4. R-type layout — ek row jo har field use karti hai

Figure har field ko colour karta hai: do data fields (rs2, rs1, rd) ek hue mein, do operation-selector fields (funct7, funct3) doosre mein, aur opcode teesre mein. Custom instructions is exact skeleton ko borrow karti hain taaki CPU ki existing decode wiring reuse ho sake — dekho R-type instruction format.


5. Operations count karna — kahan se aata hai

Ab parent ki key derivation mein har symbol defined hai, to hum actually count kar sakte hain.


6. Latency, cycles, aur "coupling" — kyun tight ek door device se better hai


7. Speedup aur Amdahl — "kya yeh worth it hai?" number


Prerequisite map

bit

32-bit word

opcode inst 6 to 0

register file

rs1 rs2 rd fields

R-type format

funct3 and funct7

reserved custom opcodes

encoding budget 1024

custom extension

clock cycle and latency

tight vs loose coupling

speedup and Amdahl

Upar se neeche padho: bits ek word banate hain; word ke rightmost 7 bits opcode hain; opcode plus funct fields plus register fields R-type row banate hain; funct bits count karne se 1024 budget milta hai; reserved opcodes plus woh budget ek custom extension dete hain, aur latency/coupling aur speedup ideas batate hain kab build karna worth it hai.


Equipment checklist

Ek RISC-V opcode kitne bits ka hota hai, aur kahan baithta hai?
7 bits, inst[6:0] mein — 32-bit word ke rightmost 7 boxes.
5 bits ek register kyun naam karte hain?
Kyunki 32 registers hain aur .
rs1, rs2, rd kya select karte hain — operation ya data?
Data (kaunse registers inputs/output hold karte hain), kabhi operation nahi.
funct3 aur funct7 kya select karte hain?
Ek opcode family ke andar specific operation (flavour).
Ek R-type instruction mein field by field kitne bits total hote hain?
.
Ek -bit field patterns kyun hold karta hai?
Har added bit possibilities ko double kar deta hai.
Operations per custom slot derive karo.
.
Ek custom instruction small ops ke liye MMIO se faster kyun hai?
Operands few cycles mein registers se aate hain, na ki hundreds-of-cycles bus round-trip mein.
Amdahl's Law accelerators ke baare mein kya warn karta hai?
Un-accelerated part total speedup cap kar deta hai, isliye sirf hot kernel ko harden karo.

Connections