|
|
How to use a package ?
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
|
|
|
|
Reply
|
HansWernerMarschke
|
5/3/2008 9:26:58 PM |
|
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
|
|
|
|
Reply
|
Vince
|
5/3/2008 9:51:33 PM
|
|
Thanks a lot
|
|
0
|
|
|
|
Reply
|
HansWernerMarschke
|
5/4/2008 1:01:06 AM
|
|
|
2 Replies
91 Views
(page loaded in 0.07 seconds)
Similiar Articles: IEEE VHDL fixed point package - comp.lang.vhdlHi, I am trying to learn how to use the IEEE VHDL fixed point package (fixed_pkg.vhdl). It's suppose to come with IEEE Std 1076-2008 and I don't w... How to make a java package in matlab - comp.soft-sys.matlab ...I want to make a java package using deployment tool of matlab. I'm using matlab 2007b(7.5) that use : >>ver Matlab Compiler 4.7 sur MCR 7.7 je ... How to read a field value from pdf form in Java - comp.text.pdf ...Do you > happen to know how to achieve the same result using Adobe package in > Java? In other words, how to read the field value on the PDF form > using Adobe package ... Instrumentation package - comp.lang.java.programmerHi all, How to use the java instrumentation package . Of course, Igoogled, but what to do with the profiling?Thanks in advance... Changing page margins in mid-document - comp.text.texI know how to use the geometry package to adjust the margins of the document, but this forces *all* pages to have the nonstandard margin. How can I tell LaTeX to revert ... How to use OSGi bundle services dynamically - comp.lang.java.help ...hi all, i have a little problem here finding out how to use registered services in ... Installing HP print package - comp.unix.solaris... Unix Group- -Computer and Network ... pkg-get remove - comp.unix.solarisFind the real name of the package (hint: it starts with CSW) and use Solaris native pkgrm. Dragan -- Dragan Cvetkovic, To be or not to be is true. G. Boole No ... How to set the default publisher on a repository? - comp.unix ...I'm using Solaris 11 Express, attempting to send an IPS package to a local repository. I first configured the repository with: # svccfg -s ap... How do I cite SPSS now? - comp.soft-sys.stat.spssI have a grant application due tommorow and it suddenly occured to me that I really don't know how to cite the program anymore (AMA style - in text,... how to deploy my java programs as a software package by including ...Hi, i had written a program in java. it is an addressbook.i want to deploy this program as a complete software package to my friends.this must be just... How to Use Stamps to Mail a Package | eHow.comMailing a package through the U.S. Postal Service with stamps can be a quick process. If your package weighs more than 13 ounces, you need to take it into the post ... How to Use an iPhone With No Data Package | eHow.comThe iPhone is a quad-band Global Systems for Mobile Communications-based (GSM) smartphone that also functions as a pocket computer. Many features on the iPhone ... 7/8/2012 4:37:45 PM
|
|
|
|
|
|
|
|
|