kth_hkt
Newbie

I have a memory of depth 4 and 8 bytes wide.
I need to read first two bytes of first address of the memory and calculate its sum and find the average and replace the first two bytes of first address by that average.
Then I need to read the contents of subsequent two bytes of the first address itself and again do sum and find average and then replace third and fourth bytes by that average. This process should continue for all the addresses .
Ex: If the memory is something like this
Then, first two bits of first address must be replaced by (3+1)/2 = 2
and then next two bits of address must be replaced by (2+4)/2=3,
and so on, for all bytes of all the addresses
Finally the memory should look like,
I need to write verilog code for this design and the code should be parameterized such that it can be extended to any width and any depth.
I need to read first two bytes of first address of the memory and calculate its sum and find the average and replace the first two bytes of first address by that average.
Then I need to read the contents of subsequent two bytes of the first address itself and again do sum and find average and then replace third and fourth bytes by that average. This process should continue for all the addresses .
Ex: If the memory is something like this
3 | 1 | 2 | 4 | 3 | 5 | 5 | 3 |
2 | 2 | 1 | 1 | 3 | 1 | 3 | 3 |
4 | 2 | 0 | 2 | 0 | 4 | 6 | 4 |
2 | 8 | 2 | 6 | 8 | 0 | 9 | 7 |
Then, first two bits of first address must be replaced by (3+1)/2 = 2
and then next two bits of address must be replaced by (2+4)/2=3,
and so on, for all bytes of all the addresses
Finally the memory should look like,
2 | 2 | 3 | 3 | 4 | 4 | 4 | 4 |
2 | 2 | 1 | 1 | 2 | 2 | 3 | 3 |
3 | 3 | 1 | 1 | 2 | 2 | 5 | 5 |
5 | 5 | 4 | 4 | 4 | 4 | 8 | 8 |
I need to write verilog code for this design and the code should be parameterized such that it can be extended to any width and any depth.
Last edited: