Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Verilog code to transfer content of one memory to another of different sizes in one clock cycle.

Status
Not open for further replies.

tipra

Newbie
Joined
Dec 8, 2020
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
29
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.


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:

Depends on the physical nature of mem. No problem if it's a huge array of registers, but impossible with a SRAM block accessed through an address bus. As you are asking in the ASIC section, I'd expect the former.
 
How do I achieve the given condition, provided 'mem' needs to be inferred as a memory block and not just a array of registers
 

Hi,

.. a rather general question without details...

a memory block should have an interface. You need to read about it.
Usally Address lines, Data lines and control lines. And for communication you need to drive/keep the signals within their timing specifications.

I assume nobody of us can tell you, be cause we don´t have any information about the used device and the used memory section.
In either case anyone needs to read the datasheet. The fastest way is if you do this ...

Klaus
 

How do I achieve the given condition, provided 'mem' needs to be inferred as a memory block and not just a array of registers
you have to go back to the drawing board. that is not how a memory works, it has an address and a data port. you can't write to all addresses at the same time, not with conventional compiled SRAM.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top