Forum Discussion
Altera_Forum
Honored Contributor
14 years agomapping a port to several signals
Hi all!
I have got an issue, I don't really know if it's a bug from ModelSi or an error from my code. Maybe soeone will be able to tell me... A/° I am using: --- Quote Start --- ModelSim DE 6.6a Revision: 2010.03 Date: Mar 19 2010 --- Quote End --- B/° This code works:library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity test is
end entity test;
architecture behavioural of test is
component foo
port
(
s : out std_logic_vector(31 downto 0)
);
end component foo;
constant K : natural range 1 to 31 := 15;
signal msb : std_logic_vector(31 downto K);
signal lsb : std_logic_vector((K - 1) downto 0);
begin
foo_inst : foo
port map
(
s(31 downto K) => msb,
s((K - 1) downto 0) => lsb
);
end architecture behavioural; --- Quote Start --- ModelSim> vcom -reportprogress 300 -work work /home/reinauld/Bureau/test.vhd # Model Technology ModelSim DE vcom 6.6a Compiler 2010.03 Mar 19 2010 # -- Loading package standard # -- Loading package std_logic_1164 # -- Loading package numeric_std # -- Compiling entity test # -- Compiling architecture behavioural of test ModelSim> --- Quote End --- C/° I tried to replace the constant K with e generic that I can set when starting the simulation, but it does not work library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity test is
generic
(
K : natural range 1 to 31 := 15
);
end entity test;
architecture behavioural of test is
component foo
port
(
s : out std_logic_vector(31 downto 0)
);
end component foo;
signal msb : std_logic_vector(31 downto K);
signal lsb : std_logic_vector((K - 1) downto 0);
begin
foo_inst : foo
port map
(
s(31 downto K) => msb,
s((K - 1) downto 0) => lsb
);
end architecture behavioural; --- Quote Start --- ModelSim> vcom -reportprogress 300 -work work /home/reinauld/Bureau/test.vhd # Model Technology ModelSim DE vcom 6.6a Compiler 2010.03 Mar 19 2010 # -- Loading package standard # -- Loading package std_logic_1164 # -- Loading package numeric_std # -- Compiling entity test # -- Compiling architecture behavioural of test # ** Error: /home/reinauld/Bureau/test.vhd(29): (vcom-1024) Individually associated formal "s" must be identified with a locally static name. # ** Error: /home/reinauld/Bureau/test.vhd(30): (vcom-1024) Individually associated formal "s" must be identified with a locally static name. # ** Error: /home/reinauld/Bureau/test.vhd(30): (vcom-1048) Non-locally static choice (association# 2, choice# 1) is allowed only if it is the only choice of the only association. # ** Error: /home/reinauld/Bureau/test.vhd(33): VHDL Compiler exiting # /opt/modelsim_de/modelsim_dlx/linuxpe/vcom failed. ModelSim> --- Quote End --- Can anyone comment this? Maybe suggest another way to achieve what I try to do? The point is to map output of a signal driver (that reads stimuli from a file) to several stimuli signals. Thanks, Julien16 Replies
- Altera_Forum
Honored Contributor
--- Quote Start --- @kaz: a generic is set at compilation time, so it behaves like a constant. It's not a signal that can vary in time... --- Quote End --- Almost, but not quite. A constant is a known value when you compile the code. A generic may not have a default value when you compile the code, so it is only fixed when you isntantiate the entity, so therefore it is not static, and hence the error when you compile the code. --- Quote Start --- @FvM: yes it does (one proof is that 1st version of code compiles) True :) --- Quote End --- See the above comment --- Quote Start --- @kaz This does not change anything... --- Quote End --- yes it does, because generics are not static. - Altera_Forum
Honored Contributor
Your test entity has only generic and your msb/lsb are undriven internal signals and this is not standard code.
A generic constant should be acceptable by any sensible compiler. - Altera_Forum
Honored Contributor
@kaz:
--- Quote Start --- The compiler needs to settle what to connect to what i.e. k must be a constant per build --- Quote End --- a generic is set at compilation time, so it behaves like a constant. It's not a signal that can vary in time... @FvM: --- Quote Start --- The VHDL standard doesn't provide the option to connect variable bits or slices of port signal individually --- Quote End --- yes it does (one proof is that 1st version of code compiles) --- Quote Start --- But it's easy to connect s as a whole to a wire signal and individual slices of it as intended. --- Quote End --- True :) @kaz --- Quote Start --- use: generic( k : integer := 15 ); --- Quote End --- This does not change anything... - Altera_Forum
Honored Contributor
The VHDL standard doesn't provide the option to connect variable bits or slices of port signal individually. But it's easy to connect s as a whole to a wire signal and individual slices of it as intended.
- Altera_Forum
Honored Contributor
use:
generic( k : integer := 15 ); - Altera_Forum
Honored Contributor
The compiler needs to settle what to connect to what i.e. k must be a constant per build