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

Reply

VHDL - use work.my_package.all-->what exactly meaning of this

 
Thread Tools Search this Thread
Old 01-11-2006, 06:47 PM   #1
Default use work.my_package.all-->what exactly meaning of this


Hello friends,

I'm not the novice for the VHDL coding but i've not came across adding
the use work.my_package.all in the initial library declaration part.

Now i want help on that what exactly this statement do? Also if i'm
making a function in the package body where i should store the file and
with which extension? Here i'm giving you the code on which i'm working
right now.

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

entity multiplier1 is
generic (size: integer := 4);
Port ( a,b : in unsigned(size-1 downto 0);
--b : in std_logic;
y : out unsigned(2*size-1 downto 0));
end multiplier1;

architecture Behavioral of multiplier1 is

begin
y <= mult(a,b);

end Behavioral;


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

package pack is
function mult(a,b:unsigned) return unsigned;
end pack;

package body pack is
function mult(a,b:unsigned)return unsigned is
constant max:integer := a'length + b'length -1;
variable aa:unsigned(max downto 0) := (max downto a'length => '0') &
a(a'length-1 downto 0);
variable prod:unsigned(max downto 0) := (others => '0');
begin
for i in 0 to a'length-1 loop
if (b(i)='1') then prod:=prod+aa;
end if;
aa := aa(max-1 downto 0) & '0';
end loop;
return prod;
end mult;
end pack;

Regards..

Parthav



Parthav
  Reply With Quote
Old 01-12-2006, 08:37 AM   #2
john Doef
 
Posts: n/a
Default Re: use work.my_package.all-->what exactly meaning of this

Parthav a écrit :

> Hello friends,
>
> I'm not the novice for the VHDL coding but i've not came across adding
> the use work.my_package.all in the initial library declaration part.
>
> Now i want help on that what exactly this statement do?

It makes all declarations of the package potentially visible.
(BTW, this is not a statement but a context clause).
This clause is almost *never* necessary: each place you use a
declaration from
your package, you can replace the name with its expanded form:
work.my_package.my_func (x , y) instead of my_func (x, y).

> Also if i'm
> making a function in the package body where i should store the file and
> with which extension? Here i'm giving you the code on which i'm working
> right now.

VHDL almost ignore the problem of files: ie you can almost do what you
want.
However, the package must be analyzed before the design unit which uses
it.

JD.



john Doef
  Reply With Quote
Old 01-12-2006, 07:18 PM   #3
Jim Lewis
 
Posts: n/a
Default Re: use work.my_package.all-->what exactly meaning of this
Parthav,
Right off, I see 2 problems:
1) The statement "use work.my_package.all" references
a package named "my_package". You named your package
"pack".
2)
If these are in the same file, put your packge before your entity.
VHDL requires a referenced design unit to be compiled.

Cheers,
Jim

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Jim Lewis
Director of Training private.php?do=newpm&u=
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
> Hello friends,
>
> I'm not the novice for the VHDL coding but i've not came across adding
> the use work.my_package.all in the initial library declaration part.
>
> Now i want help on that what exactly this statement do? Also if i'm
> making a function in the package body where i should store the file and
> with which extension? Here i'm giving you the code on which i'm working
> right now.
>
> library IEEE;
> use IEEE.STD_LOGIC_1164.ALL;
> use IEEE.STD_LOGIC_ARITH.ALL;
> use IEEE.STD_LOGIC_UNSIGNED.ALL;
> library work;
> use work.my_package.all;
>
> entity multiplier1 is
> generic (size: integer := 4);
> Port ( a,b : in unsigned(size-1 downto 0);
> --b : in std_logic;
> y : out unsigned(2*size-1 downto 0));
> end multiplier1;
>
> architecture Behavioral of multiplier1 is
>
> begin
> y <= mult(a,b);
>
> end Behavioral;
>
>
> library IEEE;
> use IEEE.STD_LOGIC_1164.ALL;
> use IEEE.STD_LOGIC_ARITH.ALL;
> use IEEE.STD_LOGIC_UNSIGNED.ALL;
>
> package pack is
> function mult(a,b:unsigned) return unsigned;
> end pack;
>
> package body pack is
> function mult(a,b:unsigned)return unsigned is
> constant max:integer := a'length + b'length -1;
> variable aa:unsigned(max downto 0) := (max downto a'length => '0') &
> a(a'length-1 downto 0);
> variable prod:unsigned(max downto 0) := (others => '0');
> begin
> for i in 0 to a'length-1 loop
> if (b(i)='1') then prod:=prod+aa;
> end if;
> aa := aa(max-1 downto 0) & '0';
> end loop;
> return prod;
> end mult;
> end pack;
>
> Regards..
>
> Parthav



Jim Lewis
  Reply With Quote
Old 01-13-2006, 01:53 PM   #4
Parthav
 
Posts: n/a
Default Re: use work.my_package.all-->what exactly meaning of this
Thanks Jim and John,thanks a lot.

but main thing is that i'm not able to synthesize it as the compiler
shows me the error "Unknown predefined function 'mult' of package
'std_logic_arith' ".

I've tried a lot but unable to traceout the error and the ofcourse
possible cause of it.

I wish you can help me this time also.

Once again thanks for your help Jim.

Regards..

Parthav



Parthav
  Reply With Quote
Old 01-13-2006, 07:50 PM   #5
Mike Treseler
 
Posts: n/a
Default Re: use work.my_package.all-->what exactly meaning of this
Parthav wrote:

> but main thing is that i'm not able to synthesize it as the compiler
> shows me the error "Unknown predefined function 'mult' of package
> 'std_logic_arith' ".
> I've tried a lot but unable to traceout the error and the ofcourse
> possible cause of it.


You would need a vhdl simulator to debug this.

You have to compile the package before
you use it, or else get rid of it (see z below)

-- Mike Treseler
_________________________________________________
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
package pack is
constant len_c : natural := 4;
function mult(a, b : unsigned) return unsigned;
end pack;
package body pack is
function mult(a, b : unsigned)return unsigned is
constant max : integer := a'length + b'length -1;
variable aa : unsigned(max downto 0) :=
(max downto a'length => '0') &
a(a'length-1 downto 0);
variable prod : unsigned(max downto 0) := (others => '0');
begin
for i in 0 to a'length-1 loop
if (b(i) = '1') then prod := prod+aa;
end if;
aa := aa(max-1 downto 0) & '0';
end loop;
return prod;
end mult;
end pack;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.pack.all;
entity multiplier1 is
generic (size : integer := 4);
port (a, b : in unsigned(size-1 downto 0);
y,z : out unsigned(2*size-1 downto 0));
end multiplier1;
architecture Behavioral of multiplier1 is
begin
y <= mult(a, b); -- hard way: infers muxes and adders
z <= a*b; -- easy way: infers a multipler
end Behavioral;



Mike Treseler
  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
Monty Python Meaning of Life DVD hotline problems Robert Kaiser DVD Video 3 05-11-2004 06:38 AM
Meaning of Life: Disk Replacement Contact? Rutgar DVD Video 8 11-15-2003 09:11 PM
Meaning of Life recall? stankley DVD Video 1 10-01-2003 06:02 PM
Universal Python Meaning Of Life reply Peter Williams DVD Video 31 09-27-2003 09:13 PM
"The Meaning of Life" Problems with the transfer? The Magically Delicious Mr. H*** DVD Video 39 09-26-2003 03:55 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