Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Using a memory initialization file

 
Thread Tools Search this Thread
Old 02-16-2009, 08:22 PM   #1
Default Using a memory initialization file


I apologize in advance for what is probably a really stupid beginners
question.

I am currently busy with an assignment for my one course. We are
required to implement the RiSC-16 sequential CPU in VHDL using Quartus
II. We are however not allowed to use megafunctions or other altera
supplied libraries.

Now, my CPU is pretty much done. I am however struggling to figure out
how to link a MIF file to a specific memory component (Namely to my
instruction memory component).

Does anybody know how to do this, and could you please give a nice
step by step explanation on how to do it.

Thanks in advance.
Walther


Walther
  Reply With Quote
Old 02-16-2009, 09:48 PM   #2
Aiken
 
Posts: n/a
Default Re: Using a memory initialization file
do you do it in your simulation program for example Modelsim.
After you start your simluation at time "0". you can update the memory
content.

Aiken

On Feb 16, 3:22*pm, Walther <waltherl...@gmail.com> wrote:
> I apologize in advance for what is probably a really stupid beginners
> question.
>
> I am currently busy with an assignment for my one course. We are
> required to implement the RiSC-16 sequential CPU in VHDL using Quartus
> II. We are however not allowed to use megafunctions or other altera
> supplied libraries.
>
> Now, my CPU is pretty much done. I am however struggling to figure out
> how to link a MIF file to a specific memory component (Namely to my
> instruction memory component).
>
> Does anybody know how to do this, and could you please give a nice
> step by step explanation on how to do it.
>
> Thanks in advance.
> Walther




Aiken
  Reply With Quote
Old 02-16-2009, 11:30 PM   #3
Mike Treseler
 
Posts: n/a
Default Re: Using a memory initialization file
Walther wrote:

> I am currently busy with an assignment for my one course. We are
> required to implement the RiSC-16 sequential CPU in VHDL using Quartus
> II. We are however not allowed to use megafunctions or other altera
> supplied libraries.


That is a good thing.
You won't learn to write code using megafunctions.

> Now, my CPU is pretty much done. I am however struggling to figure out
> how to link a MIF file to a specific memory component (Namely to my
> instruction memory component).


Maybe you don't need a mif file.
Why not infer a rom from a vhdl constant array?
Something like this
http://mysite.verizon.net/miketreseler/sync_rom.vhd

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 02-17-2009, 06:43 AM   #4
Walther
 
Posts: n/a
Default Re: Using a memory initialization file
On Feb 17, 1:30*am, Mike Treseler <mtrese...@gmail.com> wrote:
> Walther wrote:
> > I am currently busy with an assignment for my one course. We are
> > required to implement the RiSC-16 sequential CPU in VHDL using Quartus
> > II. We are however not allowed to use megafunctions or other altera
> > supplied libraries.

>
> That is a good thing.
> You won't learn to write code using *megafunctions.
>
> > Now, my CPU is pretty much done. I am however struggling to figure out
> > how to link a MIF file to a specific memory component (Namely to my
> > instruction memory component).

>
> Maybe you don't need a mif file.
> Why not infer a rom from a vhdl constant array?
> Something like thishttp://mysite.verizon.net/miketreseler/sync_rom.vhd
>
> * *-- Mike Treseler


Thanks Mike

That is what I'm currently doing to test the CPU. However, I would
like to be able to easily load other test programs without needing to
retype all the instructions and recompiling. If I can't initialise the
memory from an external file, then it's not a train smash, but it
would make verification and simulation much easier.

Walther


Walther
  Reply With Quote
Old 02-17-2009, 09:12 AM   #5
Tricky
 
Posts: n/a
Default Re: Using a memory initialization file
On 17 Feb, 06:43, Walther <waltherl...@gmail.com> wrote:
> On Feb 17, 1:30*am, Mike Treseler <mtrese...@gmail.com> wrote:
>
>
>
> > Walther wrote:
> > > I am currently busy with an assignment for my one course. We are
> > > required to implement the RiSC-16 sequential CPU in VHDL using Quartus
> > > II. We are however not allowed to use megafunctions or other altera
> > > supplied libraries.

>
> > That is a good thing.
> > You won't learn to write code using *megafunctions.

>
> > > Now, my CPU is pretty much done. I am however struggling to figure out
> > > how to link a MIF file to a specific memory component (Namely to my
> > > instruction memory component).

>
> > Maybe you don't need a mif file.
> > Why not infer a rom from a vhdl constant array?
> > Something like thishttp://mysite.verizon.net/miketreseler/sync_rom.vhd

>
> > * *-- Mike Treseler

>
> Thanks Mike
>
> That is what I'm currently doing to test the CPU. However, I would
> like to be able to easily load other test programs without needing to
> retype all the instructions and recompiling. If I can't initialise the
> memory from an external file, then it's not a train smash, but it
> would make verification and simulation much easier.
>
> Walther


Then you will probably have to write a script to write the constant
array for you, to then copy/paste into your code - or for even more
clvereness, actaully re-write the constant declaration for you inside
the VHDL.

Otherwise, you will have to write your own MIF interpreter, which will
probably be just as involved as the above idea.


Tricky
  Reply With Quote
Old 02-17-2009, 05:36 PM   #6
Barry
 
Posts: n/a
Default Re: Using a memory initialization file
On Feb 16, 12:22*pm, Walther <waltherl...@gmail.com> wrote:
> I apologize in advance for what is probably a really stupid beginners
> question.
>
> I am currently busy with an assignment for my one course. We are
> required to implement the RiSC-16 sequential CPU in VHDL using Quartus
> II. We are however not allowed to use megafunctions or other altera
> supplied libraries.
>
> Now, my CPU is pretty much done. I am however struggling to figure out
> how to link a MIF file to a specific memory component (Namely to my
> instruction memory component).
>
> Does anybody know how to do this, and could you please give a nice
> step by step explanation on how to do it.
>
> Thanks in advance.
> Walther


I only used a mif file once, when I used Xilinx CoreGen to create a
ROM. I just dragged the mif file into my testbench directory (which
is the directory I opened in ModelSim to run the simulation), and it
picked up the mif file automatically.

Barry


Barry
  Reply With Quote
Old 02-17-2009, 06:15 PM   #7
PlayDough
 
Posts: n/a
Default Re: Using a memory initialization file
On Feb 17, 1:12*am, Tricky <Trickyh...@gmail.com> wrote:
> Then you will probably have to write a script to write the constant
> array for you, to then copy/paste into your code - or for even more
> clvereness, actaully re-write the constant declaration for you inside
> the VHDL.


Or rather, write a Perl script or C program to convert the MIF into a
format that is easy to import. It is quite easy to write some VHDL to
read in a simple list of vectors from a file to populate your RAM. I
recommend you look at the source code for the Altera primitive RAM
models. I've never used Altera, but both Xilinx and Actel models are
capable of being initialized from a file, and the code is very easy to
understand.

I've never heard of MIF until this thread, but it looks very easy to
parse. (I used the reference at the Altera site:
http://www.altera.com/support/softwa...def_mif..html).
And considering that Altera is the source, their models probably read
MIF files. So you can scab the code from their models.

> Otherwise, you will have to write your own MIF interpreter, which will
> probably be just as involved as the above idea.


Doing this in VHDL/Verilog (though perhaps with the PLI it could be
fairly simple) would be more difficult than a Perl script/C code to
generate the constant table. For a class, I recommend a script based
approach.

Pete


PlayDough
  Reply With Quote
Old 02-18-2009, 03:31 PM   #8
Amal
 
Posts: n/a
Default Re: Using a memory initialization file
On Feb 17, 1:15*pm, PlayDough <pla...@gmail.com> wrote:
> On Feb 17, 1:12*am, Tricky <Trickyh...@gmail.com> wrote:
>
> > Then you will probably have to write a script to write the constant
> > array for you, to then copy/paste into your code - or for even more
> > clvereness, actaully re-write the constant declaration for you inside
> > the VHDL.

>
> Or rather, write a Perl script or C program to convert the MIF into a
> format that is easy to import. *It is quite easy to write some VHDL to
> read in a simple list of vectors from a file to populate your RAM. *I
> recommend you look at the source code for the Altera primitive RAM
> models. *I've never used Altera, but both Xilinx and Actel models are
> capable of being initialized from a file, and the code is very easy to
> understand.
>
> I've never heard of MIF until this thread, but it looks very easy to
> parse. *(I used the reference at the Altera site:http://www.altera.com/support/softwa...glossary/d...).
> And considering that Altera is the source, their models probably read
> MIF files. *So you can scab the code from their models.
>
> > Otherwise, you will have to write your own MIF interpreter, which will
> > probably be just as involved as the above idea.

>
> Doing this in VHDL/Verilog (though perhaps with the PLI it could be
> fairly simple) would be more difficult than a Perl script/C code to
> generate the constant table. *For a class, I recommend a script based
> approach.
>
> Pete


If you are using Synplicity and do not mind using Verilog for your
ROMs, you can use $readmemb, $readmemh tasks in an initial block to
read the contents of ROM from the file. This way you can have a
portable ROM implementation between FPGA and ASIC versions. For FPGA
version, $readmemb, and $redmemh use the same memory data file as your
ASIC foundry's ROM data file.

Check and see if Quartus supports $readmemb or $readmemh for
synthesis.

-- Amal


Amal
  Reply With Quote
Old 02-19-2009, 05:47 PM   #9
Walther
 
Posts: n/a
Default Re: Using a memory initialization file
On Feb 18, 5:31*pm, Amal <akhailt...@gmail.com> wrote:
> On Feb 17, 1:15*pm, PlayDough <pla...@gmail.com> wrote:
>
>
>
> > On Feb 17, 1:12*am, Tricky <Trickyh...@gmail.com> wrote:

>
> > > Then you will probably have to write a script to write the constant
> > > array for you, to then copy/paste into your code - or for even more
> > > clvereness, actaully re-write the constant declaration for you inside
> > > the VHDL.

>
> > Or rather, write a Perl script or C program to convert the MIF into a
> > format that is easy to import. *It is quite easy to write some VHDL to
> > read in a simple list of vectors from a file to populate your RAM. *I
> > recommend you look at the source code for the Altera primitive RAM
> > models. *I've never used Altera, but both Xilinx and Actel models are
> > capable of being initialized from a file, and the code is very easy to
> > understand.

>
> > I've never heard of MIF until this thread, but it looks very easy to
> > parse. *(I used the reference at the Altera site:http://www.altera.com/support/softwa...glossary/d...).
> > And considering that Altera is the source, their models probably read
> > MIF files. *So you can scab the code from their models.

>
> > > Otherwise, you will have to write your own MIF interpreter, which will
> > > probably be just as involved as the above idea.

>
> > Doing this in VHDL/Verilog (though perhaps with the PLI it could be
> > fairly simple) would be more difficult than a Perl script/C code to
> > generate the constant table. *For a class, I recommend a script based
> > approach.

>
> > Pete

>
> If you are using Synplicity and do not mind using Verilog for your
> ROMs, you can use $readmemb, $readmemh tasks in an initial block to
> read the contents of ROM from the file. *This way you can have a
> portable ROM implementation between FPGA and ASIC versions. *For FPGA
> version, $readmemb, and $redmemh use the same memory data file as your
> ASIC foundry's ROM data file.
>
> Check and see if Quartus supports $readmemb or $readmemh for
> synthesis.
>
> -- Amal


Thanks for all the help. I decided to write a little script that
transforms the output of the assembler into a VHDL array format.

Works quite well.

Amal: We have to use Quartus, and VHDL (No Verilog)

- Walther


Walther
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
OCZ 6GB Triple-Channel 1333 MHz DDR3 Memory Kit Admin Front Page News 0 02-16-2009 01:27 PM
memory upgrade -D- A+ Certification 1 02-03-2007 01:01 AM
Re: What memory to use? me A+ Certification 0 12-14-2004 03:33 AM
Re: Memory stick question Nildram A+ Certification 1 01-14-2004 02:41 PM
Half memory: lost? Joe A+ Certification 4 09-04-2003 08:57 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46