Writing is the reverse: one incoming data value must land in exactly one register. We use a ==k-to-2k decoder== whose outputs are ANDed with a global WriteEnable. Only the decoded line's register captures data on the clock edge.
Why this step? Writing is "route one wire to one of many" → that's a decoder + enable.
Each independent read port needs its own MUX so two registers can be read at once. Two read ports ⇒ two 2k-to-1 MUXes reading the same flip-flop outputs.
How many address bits for 64 registers? → log264=6.
Why 2 read ports + 1 write port? → matches a 2-operand ALU op rd = rs1 op rs2.
Read is built from a ___ , write from a ___ ? → MUX ; decoder+enable.
How does area scale with ports? → (R+W)2.
What does R0 hardwired to 0 buy you? → free mov, nop, constant source; saves opcodes.
Recall Feynman: explain to a 12-year-old
Imagine you're doing math homework. The warehouse is your bookshelf across the room (slow to reach) — that's memory. The register file is the few pencils and scraps of paper on your desk. To add two numbers you need to see both at once (two eyes = two read ports) and have one hand to write the answer (one write port). If you wanted to solve two problems at the same time you'd need four eyes and two hands — much more crowded desk! That crowding growing super fast is why we don't give ourselves a hundred hands.
Dekho, register file basically CPU ke andar ki chhoti si high-speed memory hai — jaise aapke desk pe rakhe do-teen pencils. Main memory to door ki warehouse hai (slow), par registers haath mein hote hain, isliye ek hi clock cycle mein data mil jaata hai. Agar N registers hain to unme se ek ko choose karne ke liye log2N bits ki address chahiye — 32 registers matlab 5 bits.
Ab construction samjho: read ka matlab hai "many me se ek ko wire pe laao" — yeh kaam MUX karta hai. Write ka matlab "ek data ko ek specific register me daalo" — yeh decoder + write-enable karta hai. ALU ka typical kaam hota hai add rd, rs1, rs2, isliye ek saath do read (rs1, rs2) aur ek write (rd) chahiye — isliye 2 read port + 1 write port standard hai.
Sabse important trick: ports mehnge hote hain! Area roughly N⋅n⋅(R+W)2 ke hisaab se badhta hai — matlab ports double karo to cost square ho jaati hai, isliye superscalar CPUs bahut costly ho jaate hain. Aur ek chhoti si smart baat: R0 ko hardwire karke 0 rakh dete hain — isse mov, nop, clear jaise operations free me add se ban jaate hain, opcode bachta hai. Yaad rakhna mnemonic: "Do aankhein, ek haath — aur cost lagta hai SQUARE."