8×8 Register File
intermediate · sequential · 150 XP
Sign in to write your solution, run it in the simulator and submit it for grading.
Sign in or create a free account →Problem
8×8 Register File
A small register file with **8 registers, each 8 bits wide**. Two independent read ports and one write port, all operating in the same clock cycle.
This is the standard RISC register file architecture: read two operands while writing one result back — all simultaneously.
**Interface**
| Port | Direction | Description |
|-------------|-----------|-----------------------------------|
| `clk` | input | Clock |
| `we` | input | Write enable |
| `waddr[2:0]`| input | Write address (selects register) |
| `wdata[7:0]`| input | Write data |
| `raddr1[2:0]`| input | Read port 1 address |
| `rdata1[7:0]`| output | Read port 1 data (combinational) |
| `raddr2[2:0]`| input | Read port 2 address |
| `rdata2[7:0]`| output | Read port 2 data (combinational) |
**Write:** synchronous — updates on `posedge clk` when `we=1`.
**Read:** asynchronous — combinational, no clock: `rdata = mem[raddr]` always.
**Read-during-write:** If `waddr == raddr` in the same cycle, the read returns the **old** value (reads are combinational from pre-write memory). Document this in comments.
Constraints
- Use `reg [7:0] mem [0:7]` as storage.
- Write is synchronous (posedge clk, we=1).
- Reads are asynchronous/combinational: `assign rdata1 = mem[raddr1];`
- Read-during-write returns old value (not new value).
Examples
Input: we=1, waddr=3, wdata=8'hAB on posedge clk
Output: mem[3]=8'hAB after edge
Synchronous write
Input: raddr1=3 same cycle as write to addr 3
Output: rdata1=old value of mem[3]
Async read sees pre-write value
Input: raddr1=2, raddr2=5 simultaneously
Output: rdata1=mem[2], rdata2=mem[5]
Independent dual read ports
Common questions
- What does the 8×8 Register File problem ask you to build?
- 8×8 Register File A small register file with **8 registers, each 8 bits wide**. Two independent read ports and one write port, all operating in the same clock cycle. This is the standard RISC register file architecture: read two operands while writing one result back — all simultaneously.
- What constraints does 8×8 Register File have?
- Use `reg [7:0] mem [0:7]` as storage.; Write is synchronous (posedge clk, we=1).; Reads are asynchronous/combinational: `assign rdata1 = mem[raddr1];`; Read-during-write returns old value (not new value).
- What is an example input and output for 8×8 Register File?
- Input we=1, waddr=3, wdata=8'hAB on posedge clk gives output mem[3]=8'hAB after edge. Synchronous write
- Which Verilog concepts does 8×8 Register File practise?
- sequential, register-file, interview, RISC, memory.