Home    Bloggers    Messages    Webinars    Resources   
Tw  |  Fb  |  In  |  Rss
Duane Benson

Discovering FPGAs: Using a Software Simulator

Duane Benson
Page 1 / 3   >   >>
intseeker
intseeker
3/3/2013 10:33:31 PM
User Rank
Beginner
Re: Another Humble Request to the FPGA VHDL Experts
@devel@latke.net: "   .... I am still kinda dizzy ...."

Ash I promised, I came back for another simple request from the experts. Happy to learn.(grin)

OK, I made some progress as far as defining a package named SRPackage and compiling it as a library placed at a certainh directory on the hard disk, say D:\ABD\DEF\partsbox

I began creating a test project named ActiveLowJK.vhd module which is expected to use the SRPlackageNow, I need to know how to refer to it along the library declaration and include (use) code lines as follows:

 

library IEEE, partsbox;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use partsbox.SRPackage.all;

Since I got errors referent to "libraby not defined" and such, I located the ieee directory within %PATH\Xilinx\11.1\ISE\vhdl\xst

 

For lack of better knowledge, I placed the 'partsbox' in there. Still didn't work.

At this point, after exploring Google the best I know, it remains to wait for the wisdom coming down from the AllProgrammablePlanet experts and gurus! (grin)

 

50%
50%
Duane Benson
Duane Benson
2/25/2013 11:46:36 AM
User Rank
Blogger
Re: Another Humble Request to the FPGA VHDL Experts
Devel - Thanks for the detailed explanation. I'm nowhere near the point of creating libraries or packages, but this helps me undersdtand what I'm doing when I use something from a library or package.

50%
50%
Duane Benson
Duane Benson
2/25/2013 11:39:53 AM
User Rank
Blogger
Re: Learn best by finding mistakes!
Brian re: "I bet you will never forget that "Simulation" radio button again! "

It's funny how something can be right in front of the face, yet not seen. But once spotted the first time, it's completely obvious from then on.

50%
50%
Brian
Brian
2/25/2013 1:22:06 AM
User Rank
Guru
Learn best by finding mistakes!
 

Hi Duane,

Re: but thus far I haven't learned anything (apart from the fact that I need to be in the "Simulation" view, of course).

But see, you did learn something!  I bet you will never forget that "Simulation" radio button again!  Isn't it funny how learning the hard way is always best...  (After the frustration is over! :-)

Re: Unfortunately, the "haven't learned anything" refrain seems to be far too common a theme for me

Ditto!  :-)

 

50%
50%
thrakkor
thrakkor
2/22/2013 2:59:19 PM
User Rank
Blogger
Re: Another Humble Request to the FPGA VHDL Experts
perhaps i wasn't clear.

compile the uart into whatever library you want (like you are recommending and showing examples for).  I completely agree here.

but, within the uart hierarchy itself, all uart references and declarations can be to work.  however, you are not analyzing into work as we have previously stated.

by using work internally, the tools can resolve those references and declarations into the library the unit is analyzed into.  the tools are smart enough to know that say in uart_fsm.vhd the use work.uart_pkg.all will resolve/map to my_uart_lib.uart_pkg.all

 

at whatever level of hierarchy the uart is instantiated or the pkg is used (outside of the uart hierarchy) is where the unique library name is needed.  anything below can just use work, safely.

50%
50%
devel@latke.net
devel@latke.net
2/22/2013 2:52:53 PM
User Rank
Guru
Re: Another Humble Request to the FPGA VHDL Experts
intseeker:  Please, tell me the name of the book on "digital design with VHDL" book you wrote, and I will purchase a copy. 

Sorry, I haven't written one. I work for a living, and I can't imagine taking the time off to write such a book. I'm too lazybusy to even work up a simple WordPress blog with this stuff on it.

50%
50%
devel@latke.net
devel@latke.net
2/22/2013 2:51:09 PM
User Rank
Guru
Re: Another Humble Request to the FPGA VHDL Experts
Thrakkor: otherwise, reusers down the road are stuck with whatever library name you created and it could conflit with existing library names in their design.

I agree -- somewhat. 

But as someone on another VHDL thread pointed out, a good reason (perhaps really the only reason) to use VHDL libraries is to avoid namespace collision. Everybody wants to call their UART something simple like "uart." 

So rather than trying to analyze the uart entity into the work library and have it collide with another entity called uart (OK, so you're insane and you're using two different uart models for some crazy reason), you put your UART into a library whose name is hopefully "reasonably unique."

You could end up with something like:
library ieee;
use ieee.std_logic_1164.all;
library ExpensiveIP;
use ExpensiveIP.TheirPackages.all;
library MyCompanyLibrary;
use MyCompanyLibrary.OurPackages.all;

and when you instantiate:
theiruart : entity ExpensiveIP.uart port map (...);
myuart : entity MyCompanyLibrary.uart port map (...);

FWIW, this is the reason why Xilinx' EDK uses libraries for all of their IP cores. And note that the library names they use attempt to be unique by adding version numbers and all of that.

50%
50%
thrakkor
thrakkor
2/22/2013 2:11:06 PM
User Rank
Blogger
Re: Another Humble Request to the FPGA VHDL Experts
the only things I would add to what Devel has described are these:

 

1)  within the uart hierarchy you are compliing into myuart library, use the generic work library name for all references and declarations.

why?

because the library creation based on RTFM creates virtual mappings.  and in this way it is truly portable because you can compile the uart hierarchy into any arbitrary library for reference in a larger design.  otherwise, reusers down the road are stuck with whatever library name you created and it could conflit with existing library names in their design.

 

2)  you can skip the component declaration of the topmost entity in the package and when instantiating it do this:

myuart_i : entity myuart.uart  

which directly invokes the library myuart you have compiled the uart hierarchy into.

50%
50%
intseeker
intseeker
2/22/2013 2:10:58 PM
User Rank
Beginner
Re: Another Humble Request to the FPGA VHDL Experts
devel@latke.net

devel@latke.net: ". . . . . . . . . . See? Very simple. "   

I said "humble" not "simple" (grin)


It is complicated and I understand most of the steps. However, I must tell you that this is the best step-by-step guide I ever got! Please, tell me the name of the book on "digital design with VHDL" book you wrote, and I will purchase a copy. THIS IS GOOD STUFF!


I am still kinda dizzy after reading it, but hopeful that I will pull this together :0)

UART, ALARM CLOCK, or a simple FF, all come from a seed: "bit".


THANK YOU!

 

 

 

50%
50%
devel@latke.net
devel@latke.net
2/22/2013 12:47:43 PM
User Rank
Guru
Re: Another Humble Request to the FPGA VHDL Experts
intseeker: @jezimo: In that case int I would suggest that you put your components in a package rather than creating a library.

Thanks Jezimo for staying with me on this(grin)

So my first question is: why do you want to use a library? I mean, I wouldn't put simple stuff (like a D-flip-flop) into a library. If anything, it would be something more substantial, like perhaps the entire description of a UART or something.

And having said that: anything substantial which is likely to be re-used gets put into the source-code control system and the source checked out (using Subversion's externals property) along with the rest of the FPGA design. But I digress.

Here is what is important to understand about VHDL libraries. They aren't what you think they are. Here is why I say that. 

A library is a collection of compiled "stuff." That "stuff" could be anything from entities to type definitions to packages. You are obviously familiar with the ieee library. It contains definitions of some types (std_logic among them) and functions which convert between types.

Note I said "collection of compiled." So right away you need to compile the library for your simulation tool and compile it again for your synthesis tool. (Your vendors provide a pre-compiled ieee library.) 

Furthermore, look at the usual library use invocation:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

Before the first dot is the library name. The second thing (std_logic_1164, numeric_std) is the name of a package which has been compiled into that library. The "all" says that "all parts of the package are available for your use."

What does the second part, "a package which has been compiled into that library" mean? Not quite simple, I'm afraid. It means that if you want to put something into a library and then reuse it, you need to put it into a package which gets analyzed into that library. 

Stay with me here. There are actually two parts of a package.

There is the package declaration and the package body. You can think of (very roughly) the package declaration in the same way as a C header file. It can contain your type definitions and constants. It can contain function and procedure declarations (but not the "guts" of them). It can contain component declarations (but again not the "guts"). It is the last of these which you'd use for entities such as your reusable UART.

Along with the package declaration, you might have a package body. It is in the package body where you will find the code for the functions and procedures referenced in the package declaration. The package body does not, however, contain the description of a component's logic. More on that in a moment.


So now you have a package declaration and possibly a package body. When you compile the package, you can specify the library into which it is compiled. How you do that is entirely tool-dependent, so RTFM. So if you like, you can compile your UART into a library called myuart, and then code which wants to use the UART does:
library myuart;
use myuart.myuart_pkg.all;

and code in the entity which needs to know about your UART can use it.


BUT WAIT, THERE'S MORE. You're still asking, "how do I put my UART entity into the library?" Like so:
  1. Code up your UART entity in the usual way (create an entity port list and an architecture and fill in the guts). Call it myuart.
  2. Create a package declaration, call it myuart_pkg. In that package declaration, create a component declaration that matches exactly the entity declaration for myuart.
  3. Tell your synthesis or simulation tool to create a library called myuart. (Tool-dependent, RTFM).
  4. Tell your synthesis or simulation tool to compile both the UART entity itself and the package into that library myuart. (Otherwise, they get compiled into the default work library.)

Now you're asking, "How do I use my library?
  1. Tell your synthesis or simulation tool about this library myuart so when it's elaborating, it can find the guts of your UART entity. (Again, tool-dependent.)
  2. In the library-declare part of the sources that need to know about your UART, add the library lines noted above.
  3. In the entity which instantiates your UART, instantiate the component called myuart. The package (header) includes the component declaration, so the compiler is satisfied.

See? Very simple. 

50%
50%
Page 1 / 3   >   >>
More Blogs from Duane Benson
Duane has decided that the time is ripe to get his ZedBoard bolted onto his robot with a Linux distribution up and running. That was the ultimate plan anyway, so why wait?
Now it's time to delve deeper into the state machine I'm using to control my I2C interface.
The three states associated with bi-directional "inout" pins can cause confusion for the unwary.
It's time to jump into unexplored territory -- the state machine that will control Duane Benson's I2C interface.
We're now ready for the I2C master to transmit a command set to a remote device.
flash poll
follow us on twitter
follow Xilinx on twitter
like us on facebook
like Xilinx on facebook
All Programmable Planet     About Us     Contact Us     Help     Register     Twitter     Facebook     RSS