Nios/memtiling

From ASMBits

You need to create a memory of depth d and width w bits. But all you have are memory chips of depth d2 and width w2 bits. How many memory chips do you need to make the d × w memory?

Write a function that computes the number of rows and columns of memory chips needed. The function has four parameters: d, w, d2, and w2. Return the number of rows (i.e., depth) in r2, and the number of columns (width) in r3.

The four input parameters are 32-bit unsigned integers. d2 and w2 are guaranteed to not be zero.


Expected solution length: Around 10 lines.

Sample Input

262144 × 32 memory, 65536 × 16 chips

Sample Output

r2=4, r3=2

See also: nios/tiling

Write your solution here

Upload a source file...