Nios/memaddr

From ASMBits

Consider a memory array of depth D and width of B bits. How many address lines are needed for this memory array?

Write a function that returns the number of address bits for a memory of depth D and width B bits. D and B will be at least 1.

unsigned int addrlines(unsigned int D, unsigned int B);

Expected solution length: Around 10 lines.

Sample Input

addrlines(16, 8)

Sample Output

r2=4

Write your solution here

Upload a source file...