tipra
Newbie
I want to transfer the contents of memory 'buff' to memory 'mem'.
Memory 'buff' is of size 9 X 1 byte.
Memory 'mem' is of size 255 X 27 bytes.
I want to transfer the contents such that the content of addresses 0,3,6 of 'buff' to go in 1st, 4th ,7th, ...,25th byte from MSB of 'mem'.
Content of addresses 1,4,7 of 'buff' to go in 2nd, 5th , 8th, .. , 26th byte from MSB of 'mem'
and
Content of address 2,5,7 of 'buff' to go in 3rd, 6th ,9th,.. ,27th byte from MSB of 'mem'.
And this data should be simultaneously transferred/written to first three addresses of memory 'mem' in only one clock pulse.
I want all these data to be written in one clock cycle, i.e. I want to run the design for 1 clk cycle only.
I tried the following code. Will this work? Assume value of 'addR' is 0.
Memory 'buff' is of size 9 X 1 byte.
Memory 'mem' is of size 255 X 27 bytes.
I want to transfer the contents such that the content of addresses 0,3,6 of 'buff' to go in 1st, 4th ,7th, ...,25th byte from MSB of 'mem'.
Content of addresses 1,4,7 of 'buff' to go in 2nd, 5th , 8th, .. , 26th byte from MSB of 'mem'
and
Content of address 2,5,7 of 'buff' to go in 3rd, 6th ,9th,.. ,27th byte from MSB of 'mem'.
And this data should be simultaneously transferred/written to first three addresses of memory 'mem' in only one clock pulse.
I want all these data to be written in one clock cycle, i.e. I want to run the design for 1 clk cycle only.
I tried the following code. Will this work? Assume value of 'addR' is 0.
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 module(input clk, input rst); reg [7:0] buff [0:8]; reg [215:0] mem [0:254]; // Assuming I have a memory 'mem' with the dimensions as stated above // and assuming the value of reg addR at the current posedge of clk is //0. always@(posedge clk) begin for(n=0;n<9;n=n+1) begin mem[(addR+0)][215-(24*n):208-(24*n)] <= buff[n][7:0]; mem[(addR+1)][215-(24*n):208-(24*n)] <= buff[n][7:0]; mem[(addR+2)][215-(24*n):208-(24*n)] <= buff[n][7:0]; end end
Last edited by a moderator: