COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### How to use a package ?

• Email
• Follow

So, lets start learning and programming vhdl with the Xilinx ISE.
I want to simulate a sinus generator. At the moment there is no FPGA
board available.
I must first learn VHDL.
I have generated a package with a table lookup.
Here is the package body.

library ieee;
use ieee.std_logic_1164.all;

package sine_package is

constant max_table_value: integer :=3D 255;
subtype table_value_type is integer range 0 to max_table_value;

constant max_table_index: integer :=3D 255;
subtype table_index_type is integer range 0 to max_table_index;

subtype sine_vector_type is std_logic_vector( 8 downto 0 );

function get_table_value (table_index: table_index_type) return
table_value_type;

end;

Now I want to use the table lookup.
The package has been compiled.

-- SineWaveLoop

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- use sine_package.ALL;

entity sine_wave_loop is
port (do_sine_wave : in bit; output : out
sine_package.table_value_type);
end sine_wave_loop;

architecture behaviour of sine_wave_loop is
begin
sine_loop : process(do_sine_wave)
variable counter : sine_package.max_index_type;   <----------- This
is Line 10
begin
counter =3D 0;
while (do_sine_wave =3D '1') loop
counter =3D (counter + 1) mod sine_package.max_table_index;
output =3D  sine_package.get_table_value(counter);
end loop;
end process sine_loop;
end behaviour;

And thats the error (One of them):

Line 10. Symbol sine_package can't be used as a prefix in a selected
name.

So, what is the problem ?
Isn=B4t it the correct syntax like <Package_Name>.<Type> ?
You can use the use statement or use the point operator but not both.

 0

See related articles to this posting

HansWernerMarschke@web.de a �crit:
> So, lets start learning and programming vhdl with the Xilinx ISE.
> I want to simulate a sinus generator. At the moment there is no FPGA
> board available.
> I must first learn VHDL.
> I have generated a package with a table lookup.
> Here is the package body.
>
> library ieee;
> use ieee.std_logic_1164.all;
>
> package sine_package is
>
> constant max_table_value: integer := 255;
> subtype table_value_type is integer range 0 to max_table_value;
>
> constant max_table_index: integer := 255;
> subtype table_index_type is integer range 0 to max_table_index;
>
> subtype sine_vector_type is std_logic_vector( 8 downto 0 );
>
> function get_table_value (table_index: table_index_type) return
> table_value_type;
>
> end;
>
> variable counter : sine_package.max_index_type;

And where is defined max_index_type in the package?

Anyway, this solution "compiles":

library ieee;
use ieee.std_logic_1164.all;

package sine_package is

constant max_table_value : integer := 255;
subtype table_value_type is integer range 0 to max_table_value;

constant max_table_index : integer := 255;
subtype table_index_type is integer range 0 to max_table_index;

subtype sine_vector_type is std_logic_vector(8 downto 0);

function get_table_value (table_index : table_index_type) return
table_value_type;

end;

library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_ARITH.all;
use IEEE.STD_LOGIC_UNSIGNED.all;
library work;
use work.sine_package.ALL;

entity sine_wave_loop is
port (
do_sine_wave : in bit;
output : out table_value_type);
end sine_wave_loop;

architecture behaviour of sine_wave_loop is
begin
sine_loop : process(do_sine_wave)
variable counter : table_index_type; // Change to table_index_type
begin
counter := 0;
while (do_sine_wave = '1') loop
counter := (counter + 1) mod max_table_index;
output <= get_table_value(counter);
end loop;
end process sine_loop;
end behaviour;

--
Vince

 0


Thanks a lot

 0

2 Replies
117 Views

Similar Articles

12/11/2013 8:59:42 AM
[PageSpeed]

Similar Artilces:

using underscore in package
Hi I am trying to understand in some code I am required to maintain the following declaration: use base qw(BOB::_::Entity); Can someone please explain what the underscore means? Thanks in advance <soup_or_power@yahoo.com> wrote in message news:1129669990.056929.44570@o13g2000cwo.googlegroups.com... > Hi > I am trying to understand in some code I am required to maintain > the following declaration: > > use base qw(BOB::_::Entity); > > Can someone please explain what the underscore means? > It doesn't mean anything more than you're inheriting from th...

How to use the glossary package ?
This is a multi-part message in MIME format. --------------080700030307050307030609 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Hi, I'm trying to generate a list of acronyms at the beginning of my documents, something like my list of figures for example. For that I just discovered the glossary package but I can't figure out how to use it. What do I have to modify in my tex file to create my acronyms list ? Do I have to gather all the term entries in a file like I do for bibliography entries ? Is there a special command to execute (...

floatflt package use #2
Hi, (sorry if this posts twice) I'm trying to use floatflt but without much success (I've tried wrapfig as well): [lots of text] \begin{floatingfigure}[l]{0.5\textwidth} \centering \includegraphics[width=0.5\textwidth]{TIMING/log1.eps} \caption{A caption.} \label{tim:log1} \end{floatingfigure} [lots of text] The .dvi file that is produced does not contain this figure and doesn't recognise the label. The figure is counted, in the sense that all subsequent (non-floatingfigure) figures are numbered as if this one existed. No errors appear on screen or in the .log file, other t...

strange problem using modules from my own package.
hello all, I found a very strange kind of behaviour in python with my own package. I created a package in which there were 4 modules and one __init__.py file I created the entire project in eclipse (pydev). it works fine there with the ide. but now when I try running the code without eclipse, that is when I run the individual .py file from a command promt it gives me error. for example I have mainwindow.py, customer.py, stock.py and of course __init__p.py in my package the app is in wxpython which is not important in the context of this problem. never the less I go in the directory called pbc...

using functions with package name prefixed.
hi; is there a way to use a function from a package without loading the whole package, but by simply prefixing the package name to the function name? For an example, suppose we have a function foo[] in a packge called Boo.m Now, one must load the Boo package by typing something like Needs["`Boo"] then one can write foo[] But notice that when calling foo[], the package name is not prefixed to it, hence one does not know in which package foo[] is in by looking at the function call. In Java for instance, I can write Boo.foo(), which makes it more clear whe...

Using listings package to highlight numbers in code
Dear all, I am using the listings package for a very simple code listing. I would like every number (we are talking integers here so no decimal point to worry about) to be highlighted red. I have tried the following settings: \documentclass[10pt,a4paper]{article} \usepackage{listings} \usepackage{color} \begin{document} \begin{lstlisting}[emph={0,1,2,3,4,5,6,7,8,9}, emphstyle=\color{red}] This is a test 123 + 456 = 789 \end{lstlisting} \end{document} but no success. Can anyone offer any suggestions? Many thanks in advance, Paul -- Department of Computing, Imperial College London ht...

Help using the %do_over macro from the Macro Array Package
I am trying to use the %do_over macro from the Macro Array Package (http://www.sascommunity.org/wiki/Macro_Array_Package). It works fine unless I add 2 or more statements in the "phrase" section, where one of those statements is dependent on the other. For example, the program below doesn't work, because vbar is dependent on proc gchart, and SAS doesn't seem to recognise that the two different statements are connected to each other once they are inside the "phrase" section. For example, in the program below the first chart is created because it is cerated ...

enlightenment for use with Solaris 9 Sun Gnome packages?
Anyone built this successfully? Have a binary package, or at least some info as to any tough points in building it? -- mailto:rlhamil@smart.net http://www.smart.net/~rlhamil ...

errors with sending email using mime/smtp package
I get the following error from a client site as follows: Tcl: 8.4.5 Error: 400: error flushing "sock568": invalid argument Stack Trace: error flushing "sock568": invalid argument while executing "flush $channel" (procedure "mime::copymessageaux" line 175) invoked from within "mime::copymessageaux$token $channel " invoked from within "mime::copymessage$part $channel" ("foreach" body line 3) invoked from within "foreach part$state(parts) { puts $channel "\n--$bo...

Corrupted Reducer file in Routing Package
Hello, I was experimenting with the routing package and PDM integration when routing came crashing down apon my ears. SW was able to recover the files (at least it said so) upon reboot. Next time I went to drag and drop the standard pipe reducer - it goes in backwards. Went to recover my backup - but it has the same problem. Guess recovery wasn't so wonderful after all. Could someone please send me a copy of the reducer.sldprt file (2005). I've got a SW2006 version but I want to keep playing in the 2005 version. Is it me or does routing have a tendency to crash a fair amount? An...

How to make Jar file using ANT on Java classes that belong to a package?
I'm not sure this is the right newsgroup for this, since I will be asking about ant. I am however trying to make a jar file - so I think it fits the groups purpose. I'm trying to make a jar file with ant, which I can do: but none of the contained files have the package path suffux on them. So for example the following ANT code makes a ReversiGui.jar <?xml version="1.0" ?> <project default="main" basedir="."> <target name="main" depends="compile, compress"> <echo> building the jar file </echo> ...

Why use '->' (instead of '::') on static package functions?
Dear Perl community, I have had a question for a while that I still don't know the answer to, so I thought of posting it here in hopes that someone might shed some light on the subject for me. When I consult the perldocs of "perldoc File::Spec", I see the following lines of usage: use File::Spec; \$x=File::Spec->catfile('a', 'b', 'c'); The second line of code tells me that if I want to cat directory entries together I can call catfile() like this: File::Spec->catfile(@directoryEntries) My question is: why is this call...

Just When I Was Getting Used To Using Using
I have a class Packet that contains a nested class Payload and an enumeration: struct Packet { struct Payload { } ; } ; I had gotten into the habit of writing: using Packet::Payload; so I could write: Payload::..blah.. instead of Packet::Payload::..blah I have done this... (gulp) in many, many .cpp files. I tried out the new Visual C++ Express compiler from you-know-who on my source code and got 1000's of error messages: ...\Packet\Packet.cpp(13) : error C2885: 'Packet::Payload': not a valid using-declaration at non-class scope What does the standard say? Is th...

ActGen to use or not to use?
Hello, I was doing a project with Actel FPGA ex128 with Libero Platinum Eval version software. in my project I had to use some counters,Multiplexers etc. which I wrote myself. Now as I was a beginner I didnt use the ActGen. Is it worth the effort to write the code partly by using ActGen macros for counter and muxes and etc. Thanks Naimesh Naimesh wrote: > I was doing a project with Actel FPGA ex128 with Libero Platinum Eval > version software. > > in my project I had to use some counters,Multiplexers etc. which I > wrote myself. Good work. Writing your own code makes y...

file in use, could not use
Hi. I have two databases that are both linked to the same backend table. I can't use them both at the same time, yet other users can have both functioning simultaneously on their machines. Opening them is not the problem. ..but the error message appears when I run any queries linked to the table. It works in one database, but not the other. All users are running XP sp2 with Access 2003. The error message is the same regardless if anyone is using the backend or not. I believe it is machine specific...MY machine. I haven't a clue. Any ideas? -- Message posted via http://www.accessmon...

To use or not to use neural networks?
Hi, my name is Conrad and I'm guessing that I sould use neural networks for my project. BTW, I'm interested in building a system that mimics an actual human (i.e. myself). Thus, it needs the ability to be able to learn as an actual human. Thus, I'm wondering, is neural networks the way to go for this particular project? If so, are there any books and/resources that can assist me in creating this project. Also, I have purchased the 'Neural Smithing..." book but I would be interested in other appropriate recommendations. Thanks in advance, -Conrad Con wrote: > Hi...

Using use in programs vs modules
Greetings, I have little module, MyUtil.pm for example, that has utility functions I use in most of my perl programs. I would like to use one function from this module in another module - while at the same time referring to the same module subroutine in the "calling" perl program. For example The module (pseudo-code): package MyNewModule use strict; use warnings; use Carp; use lib '/home/modules'; use MyUtill qw(mytool); sub test_it { mytool(); } The perl program (psuedo again): #!/usr/bin/perl use strict; use warnings; use Carp; use lib '/home/modules'; use My...

How to use office phones for home use?
I have always wondered whether networked office phones can be converted to regular phones for use at home. Please advise. Thanks. It depends on the make and model of phone. If they're proprietary "digital" phones they will only work with the KSU or PBX they were intended for so you would need that too. Even if a particular office phone could be connected directly to your home phone line it may not have any feature operations without the benefit of the KSU or PBX central equipment. Do you have a specific phone in mind? From:domenic__@hotmail.com domenic__@hotmail.com &g...

best way to use the USE statement
Let's say I have 3 modules - moda, modb, modc Say modc has 3 subroutines modc_suba, modc_subb, modc_subc modc_suba needs moda modc_subb needs modb modc_subc needs both moda, modb Is it better to do **************** Design 1 ***************** module modc use moda use modb contains subroutine modc_suba ... end subroutine modc_suba subroutine modc_subb ... end subroutine modc_subb subroutine modc_subc ... end subroutine modc_subc end module modc or is it better to do **************** Design 2 ***************** module modc contains subroutine modc_suba use moda end s...

Resource (FMAPs) use when using block RAMs
Hello, I am trying to get acquainted with the amount of logic it takes to implement common structures to an FPGA. I built a simple VHDL 2x16bit memory like follows and targeted it to a xc4013 device (which includes block RAMs) ---- entity mem is port( Dr: in std_logic_vector(15 downto 0); wr: in std_logic; clock: in std_logic; clear: in std_logic; Rr: out std_logic_vector(15 downto 0); Ad: in std_logic_vector(1 downto 0) ); end mem; ------------------------------------------------------------------ architecture behv of mem is type ram_type is array (0 to 3) of std_logic_vector...