Continuing the circuit area reduction work on my own CPU. The store buffer takes up quite a lot of area, so I'll look into reducing it. I can't pinpoint what directly makes the store buffer so large, but the fields that handle atomic instructions at least use a considerable amount of area, so I'll think about cutting those down.
I'll limit the entry that handles atomic instructions to the first entry only; the other entries will not support atomics.
generate for (genvar e_idx = 0; e_idx < ST_BUF_ENTRY_SIZE; e_idx++) begin : entry_loop logic w_ready_to_merge; logic w_load; assign w_entry_valids[e_idx] = w_entries[e_idx].valid; assign w_load = st_buffer_if.valid & (st_buffer_if.is_rmw ? e_idx == 0 : w_in_ptr_oh[e_idx]) & w_st_buffer_allocated; if (e_idx == 0) begin scariv_st_buffer_amo_entry u_entry /* ... omitted ... */ ); end else begin // if (e_idx == 0) scariv_st_buffer_entry u_entry ( .i_clk (i_clk ), .i_reset_n(i_reset_n), /* ... omitted ... */
Either way, when an atomic instruction is processed, the cache is updated only after confirming that the store buffer is empty, so this should be fine.
At least in terms of area, it is a substantial reduction. So the atomic instruction handling really was using up a lot of area.
- Before the reduction

- After the reduction

This is an English translation of the original Japanese post: 自作CPUの回路面積削減検討 (ストアバッファの面積削減検討)