Similar Threads:
1.How to specify default value to a variable of unconstrained type
Hi Pankaj,
You have to fix the NUMBERofHEADER here as 2 in a package entity. only
then u will be able to compile the same.
Anupam Garg
2.Default values on undriven ports in configuration?
Hi,
I have a signal which has a default value, but is undriven following a
configuration.
One simulator I am using gives the signal the default value. The
testbench I have relies on this.
A different simulator gives the signal a value of U. This causes my
testbench to fail.
Both are "mainstream" simulators.
I have looked in the LRM, and it is not obvious to me which behaviour
is correct.
I would be very grateful as for any advice on this.
(If replying by email, please get rid of the m after ken otherwise it
will be treated as spam)
Many Thanks,
Ken Morrow
A test case which shows the problem:-
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity PARTIAL_DRIVER is
port (
FRED : out std_logic_vector(7 downto 0));
end PARTIAL_DRIVER;
architecture TEST of PARTIAL_DRIVER is
begin -- TEST
FRED <= "01010101";
end TEST;
entity DEFAULT_VALUE is
end DEFAULT_VALUE;
library IEEE;
use IEEE.STD_LOGIC_1164.all;
architecture TEST1 of DEFAULT_VALUE is
signal FRED : std_logic_vector(7 downto 0);
--DEFAULT_SIGNAL is given a default value:-
signal DEFAULT_SIGNAL : std_logic_vector(7 downto 0) := (others=>'1');
--One simulator retains this default value.
--The other assigns a value of 'U'.
component DRIVER
port (
FRED : out std_logic_vector(7 downto 0);
DEFAULT_SIGNAL : out std_logic_vector(7 downto 0));
end component;
begin -- TEST
UUT : DRIVER
port map (
FRED => FRED,
DEFAULT_SIGNAL => DEFAULT_SIGNAL);
end TEST1;
configuration CFG of WORK.DEFAULT_VALUE is
for TEST1
for UUT : DRIVER
use entity work.PARTIAL_DRIVER
port map (
FRED => FRED); --NOTE DEFAULT_VALUE is
undriven
end for;
end for;
end CFG;
3.Unconstrained arrays in port : elegant but...
Hi,
It makes me nervous to see "shared variables" in RTL code... As a newbie, you
probably shouldn't be aware of these beasts anyway ;-)
Shared vars can be very handy in test benches and behavioral models, but they must be
used with extreme care.
A constant would have done the trick.
Unconstrained arrays in port is IMO a very elegant style, but it doesn't
have only advantages... I'm not sure all the synthesis tool accept this yet either,
you need to check first before using this style ! Don't rely on manuals, they are
sometimes unaware of what the tool can do !!! Use the code below (wrap it in a
sized-ports top level first indeed) to see of it works.
So below is something which I wrote "similar" to your idea (though the function coded
has nothing to do with a square root. I think there is a synthesizable square root in
the Synplify examples, but if it's an assignment, write your own solution first).
You can throw this code in your VHDL simulator and see it work (PWM on Cout).
Hope this helps,
Bert
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
entity pAndG is
port( A, B : in std_logic_vector;
Plink,
Glink : out std_logic_vector );
end pAndG;
architecture dummy of pAndG is
begin
-- just to put something here for the sake of the example
Plink <= A and B;
Glink <= A xor B;
end;
-- we ae going to instanciate this entity.
-- ----------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
entity SquareRoot is
port( A, B : in std_logic_vector;
Cin : in std_logic;
Cout : out std_logic;
Sum : out std_logic_vector );
end SquareRoot;
library IEEE;
use IEEE.numeric_std.all;
architecture Dummy of SquareRoot is -- just for the example !
-- this does nothing interesting, the purpose is only to show how
-- to use unconstrained array and attributes.
constant Width : positive := A'length; -- if you want to use it.
signal Plink, Glink, Slink0, Slink1: std_logic_vector(A'range);
signal Clink0, Clink1: std_logic;
signal Sum1 : std_logic_vector (A'high+1 downto 0);
begin
-- shows the instanciation of another entity with unconstrained vectors in port
pg: entity work.pAndG(Dummy) port map (A, B, Plink, Glink); --
Sum1 <= std_logic_vector (unsigned('0'& A) + unsigned('0'& B));
Sum <= Sum1(Sum'range);
Cout <= Sum1(Sum1'high);
end;
-------simple test bench-----------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
entity TB is end;
architecture test of TB is
signal A,B,Sum : std_logic_vector(5 downto 0);
signal Cout : std_logic;
begin
UUT: entity work.SquareRoot port map (A,B,'0',Cout,Sum);
process begin
A <= (others=>'0'); B <= (others=>'0');
for i in 0 to 2**A'length-1 loop
for j in 0 to 2**A'length-1 loop
A <= std_logic_vector (to_unsigned(i,A'length));
B <= std_logic_vector (to_unsigned(j,B'length));
wait for 10 ns;
end loop;
end loop;
wait;
end process;
end test;
----------------------------------
4.Unconstrained array for output port in generic :/
I'm fairly new to generics, consequently I'm having problems :)
I'm trying to create an entity with 'width' bits in and 'nbits'x'width'
bits out. I'm trying to use an unconstrained array to do this, but I'm
getting compile errors...
# ** Error: C:/Modeltech_6.0c/work/srsipo.vhd(34): near "array":
expecting: STRING IDENTIFIER
Any ideas? Thanks.
-Brandon
<SNIP>
library ieee;
use ieee.std_logic_1164.all;
use work.srsipo_pkg.all;
-------------------------------------------------------------------------------
-- ENTITY
-------------------------------------------------------------------------------
entity srsipo is
generic (
nbits : integer;
width : integer
);
port (
---------------------------------------------------------------------------
-- input
------------------------------------------------------------------
rst_na : in std_logic;
clk : in std_logic;
din : in std_logic_vector(width-1 downto 0);
-- output
-----------------------------------------------------------------
dout : out array (width-1 downto 0)
of std_logic_vector(nbits-1 downto 0)
---------------------------------------------------------------------------
);
end srsipo;
</SNIP>
5.Unconstrained array ports - Good or Bad?
As a newbie to this area I am confused as to the status/views on
unconstrained array ports.
They appear to be legal, in the VHDL language and "The Designers Guide
to VHDL" by Peter Ashenden makes them out to be a great thing for
producing re-usable entities. However, the Xilinx synthesizer does not
allow them and other reports I've read on the topic seem to indicate
either implicitly or explicitly that they are a Very Bad Thing.
Can the experts who visit this newsgroup provide some insight to clarify
the position?
Thanks!
6. type convertion of an unconstrained output in a port map
7. Unconstrained array of unconstrained vector.
8. How to specify default value to a variable of unconstrained type INSIDE a VHDL procedure ?