Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Contributor
syalk1120
Posts: 39
Registered: ‎05-04-2009
0
Accepted Solution

how to initialize array registers

Hi,everyone.

I wanna initialize the array registers in verilog code for implementation, such as  [25:0] data[31:0], how should I do? THX.

Xilinx Employee
Xilinx Employee
ywu
Posts: 2,873
Registered: ‎11-28-2007
0

Re: how to initialize array registers

[ Edited ]

Take a look at the thread below:

 

http://forums.xilinx.com/t5/Virtex-Family-FPGAs/How-to-make-ROM-using-block-RAM/m-p/20628#M1954

 


syalk1120 wrote:

Hi,everyone.

I wanna initialize the array registers in verilog code for implementation, such as  [25:0] data[31:0], how should I do? THX.




Cheers,
Jim
Contributor
syalk1120
Posts: 39
Registered: ‎05-04-2009
0

Re: how to initialize array registers

Thanks,Jim.I have added the initialize code,but it comes out such error "Address xx is invalid in call of system task $readmemb."  whatever I changed the address,the error  existed. what 's the matter with my code?  my initialize code is as following:

 

reg[21:0] ram[31:0]

initial
begin
 $readmemb("ram.mif",ram,0,31);
end

 

 

ps: the "ram.mif" is the binary code in 22*31bits.

Xilinx Employee
Xilinx Employee
ywu
Posts: 2,873
Registered: ‎11-28-2007
0

Re: how to initialize array registers

Can you attach ram.mif file?

 


syalk1120 wrote:

Thanks,Jim.I have added the initialize code,but it comes out such error "Address xx is invalid in call of system task $readmemb."  whatever I changed the address,the error  existed. what 's the matter with my code?  my initialize code is as following:

 

reg[21:0] ram[31:0]

initial
begin
 $readmemb("ram.mif",ram,0,31);
end

 

 

ps: the "ram.mif" is the binary code in 22*31bits.




Cheers,
Jim
Contributor
syalk1120
Posts: 39
Registered: ‎05-04-2009
0

Re: how to initialize array registers

Thanks,Jim.

I have attached "ram.mif"file,pls check it.

Xilinx Employee
Xilinx Employee
ywu
Posts: 2,873
Registered: ‎11-28-2007
0

Re: how to initialize array registers

The old parser in XST is very picky. You will need to get rid of unwanted white spaces, especially the "Tab" character, at the very end of the file. Make sure the ram.mif file has exactly 32 lines.

 


syalk1120 wrote:

Thanks,Jim.

I have attached "ram.mif"file,pls check it.




Cheers,
Jim
Contributor
syalk1120
Posts: 39
Registered: ‎05-04-2009
0

Re: how to initialize array registers

Thanks,Jim. It's done now.

Xilinx Employee
Xilinx Employee
ywu
Posts: 2,873
Registered: ‎11-28-2007
0

Re: how to initialize array registers

Great to hear that. Just so you know there are a couple of more restrictions on the memory initialization file format mentioned in the blog blow in case you run into those:

Memory Initialization Methods


syalk1120 wrote:

Thanks,Jim. It's done now.




Cheers,
Jim