electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

How to initialize an array structure in verilog?


Post new topic  Reply to topic    EDAboard.com Forum Index -> ASIC Design Methodologies & Tools (Digital) -> How to initialize an array structure in verilog?
Author Message
yuenkit



Joined: 20 Jan 2005
Posts: 110
Helped: 5


Post15 Mar 2006 12:30   

verilog array


for example,

reg [7:0] mem [0:3];



1. I want to initialize the every element in the mem = 0, how to do that?
2. I want to initialize mem such that mem[0] = 2, mem[1] =4 , mem[2] = 1, mem[3] = 5. how to do that?
Back to top
Google
AdSense
Google Adsense




Post15 Mar 2006 12:30   

Ads




Back to top
eda_wiz



Joined: 07 Nov 2001
Posts: 720
Helped: 30


Post15 Mar 2006 13:27   

verilog initialize array


write down all the values in a file and use
$readmemh command
Back to top
arunragavan



Joined: 01 Jul 2004
Posts: 487
Helped: 21
Location: India


Post15 Mar 2006 13:43   

verilog array initialization


$readmemh or $readmemb is not synthesizable.
u can use it for simulation purpose.
how to u realize in synthesis part?
u must design a simple RAM for synthesis.

Aravind
Back to top
jjww110



Joined: 19 Apr 2005
Posts: 262
Helped: 5
Location: china


Post16 Mar 2006 1:38   

array verilog


if you use register not memory,please use for loop
to initialization!!
Back to top
aravind



Joined: 29 Jun 2004
Posts: 622
Helped: 23
Location: india


Post16 Mar 2006 2:09   

array in verilog


I cant Understand JJWW110.
can u give simple example.
thanks
Back to top
yuenkit



Joined: 20 Jan 2005
Posts: 110
Helped: 5


Post16 Mar 2006 10:31   

verilog memory array


i guess what jjww said was

Code:
parameter MEM_SIZE = 1024
reg [7:0] mem [0:MEM_SIZE -1]

initial
begin
for (k = 0; k < MEM_SIZE - 1; k = k + 1)
begin
    mem[k] = 0;
end
end
Back to top
weng



Joined: 13 Jan 2006
Posts: 32


Post17 Mar 2006 1:13   

verilog memory initialization


Is this correct? Looks like you actually treat mem as a single bit signal, not a bus signal.
Back to top
tigerajs



Joined: 08 Feb 2006
Posts: 30


Post17 Mar 2006 2:38   

verilog array initialize


of course it is right, I often do as that
Back to top
weng



Joined: 13 Jan 2006
Posts: 32


Post17 Mar 2006 3:20   

verilog array initial


How about if I only want to initialize one of the bit of mem? For example, I want to initialize the bit 0 of all mem array to 0?
Back to top
jjww110



Joined: 19 Apr 2005
Posts: 262
Helped: 5
Location: china


Post17 Mar 2006 3:58   

verilog initialize register


Code:
parameter MEM_SIZE = 1024
reg [7:0] mem [0:MEM_SIZE -1]

initial
begin
for (k = 0; k < MEM_SIZE ; k = k + 1)
begin
mem[k] = 8'h00;
end
end
Back to top
aravind



Joined: 29 Jun 2004
Posts: 622
Helped: 23
Location: india


Post17 Mar 2006 5:05   

verilog parameter array


whether reg [7:0] mem[ 0:MEM_SIZE -1]

the mem should be a ram file in the name of mem or
verilog itself it take as ram memory?

im having ram library of 512 X 8 (file name RAM512X8.v)
how to write or involve it by using array structure like above ( ram [7:0] ---)
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> ASIC Design Methodologies & Tools (Digital) -> How to initialize an array structure in verilog?
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
How to Initialize 2D array in VHDL? (2)
how to initialize sdcard ? (3)
how do i initialize SMC in MPC860 (2)
How to initialize a memory in Quartus (1)
How to initialize a union in Systemverilog? (2)
How to initialize my PIC based project? (1)
how to initialize lcd using coldfire processor (2)
How can I initialize the build-in EEPROM on Atmel AT89S8252 (4)
2-D array (verilog) synthesizable ? (3)
Array assignements in verilog (4)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS