Generic and constants

M

Maki

Guest
Hello all,

In top level description of my processor I have few generic constants. One
of them define how much timers exist in the model.
Timers have two registers: TMR_CFG and TMR_VAL. I keep addresses of these in
separate package as a constant.
How can initialize constants in the package depending of the value of
generic which is in top level file.
I other words I need to generate constants in the package depending on the
value of generic. These constants should be diferent for every timer that is
generated.
Any simple solution for this?

Best regards and thanks.

Maki.

--
Veselic Mladen
Laboratorija Sigma
 
Maki a écrit:
[...]
I other words I need to generate constants in the package depending on the
value of generic. These constants should be diferent for every timer that is
generated.
Any simple solution for this?
Hello
In my opinion, packages are for constants, not parameters. If you want
your constants to depend on a generic parameter, declare them directly
in your architecture.
Since packages must be compiled/analyzed before being used, you can't
make a constant in the package depend on an entity generic.

--
____ _ __ ___
| _ \_)/ _|/ _ \ Adresse de retour invalide: retirez le -
| | | | | (_| |_| | Invalid return address: remove the -
|_| |_|_|\__|\___/
 
Maki wrote:
Hello all,

In top level description of my processor I have few generic constants. One
of them define how much timers exist in the model.
Timers have two registers: TMR_CFG and TMR_VAL. I keep addresses of these in
separate package as a constant.
How can initialize constants in the package depending of the value of
generic which is in top level file.
You can't. There is no way constants in a package can be set according
to a value of a generic.

I other words I need to generate constants in the package depending on the
value of generic. These constants should be diferent for every timer that is
generated.
Any simple solution for this?
As far as I understand the problem, I would declare multiple constants
for each timer (or even an array of constants, making a table). In the
architecture you then choose which constant (or which index into the
array) to use, depending on the value of your generic(s).

Paul.
 
"Maki" <veselic@eunet.yu> wrote in message news:<co32mq$m8l$2@news.eunet.yu>...
Hello all,

In top level description of my processor I have few generic constants. One
of them define how much timers exist in the model.
Timers have two registers: TMR_CFG and TMR_VAL. I keep addresses of these in
separate package as a constant.
How can initialize constants in the package depending of the value of
generic which is in top level file.
I other words I need to generate constants in the package depending on the
value of generic. These constants should be diferent for every timer that is
generated.
Any simple solution for this?

Best regards and thanks.

Maki.
You have got yourself into a tough situation, maybe you can try if
shared variables can help you out, but I am not sure.

Neo
 
Maki a écrit:

Maybe this could be achived in some other, simpler way.
Any sugestions?
Very easily. Pass your timer number to the timer through a generic
parameter and inside the timer, define a constant base address based on
the generic:

Timers : for i in 0 to n_of_timers - 1 generate
begin
Timer : entity work.FROG1_Timer(rtl)
generic map ( --
tmr_nbr => i) --
port map (
clk => clk,
reg_bus => reg_bus,
reg_adr => reg_adr,
reg_rd => reg_rd,
reg_wr => reg_wr,
A => A(i),
B => B(i),
tmr_int => tmr_int_vec(i)
);
end generate;
 
Dear Paul,

I have pass as generic value and with litlle conversion from natural
everything compiles fine.
Thank You very much for Your help it is appriciated.

Best regards,
M.

--
Veselic Mladen
Laboratorija Sigma
"Paul Uiterlinden" <no@spam.nl> wrote in message
news:co4ji0$ogc$1@voyager.news.surf.net...
Maki wrote:
Paul > As far as I understand the problem, I would declare multiple
constants
Paul > for each timer (or even an array of constants, making a table).
In
the
Paul > architecture you then choose which constant (or which index into
the
Paul > array) to use, depending on the value of your generic(s).

This cross my mind. But do You have an idea how to index the array? I
have
only one generic n_of_timers.
Perhaps I can use counter value (i) in generate statement ?

Timers : for i in 0 to n_of_timers - 1 generate
begin
Timer : entity work.FROG1_Timer(rtl)
port map (
clk => clk,
reg_bus => reg_bus,
reg_adr => reg_adr,
reg_rd => reg_rd,
reg_wr => reg_wr,
A => A(i),
B => B(i),
tmr_int => tmr_int_vec(i)
);
end generate;

Somehow I have to pass it to timer entity? Like a generic maybe?

Exactly! Put the counter value of the generate loop in the generic map
and use the generic in the architecture FROG1_Timer(rtl) to index the
array.

Timers : for i in 0 to n_of_timers - 1 generate
begin
Timer : entity work.FROG1_Timer(rtl)
generic map(
timer_nr => i
)
port map (
...

Paul.
 
Thank You all. That's a solution I was looking for.

Best regards,
Maki

--
Veselic Mladen
Laboratorija Sigma

"Nicolas Matringe" <nicolasmatringe001@numeri-cable.fr> wrote in message
news:41A5BAF5.6050500@numeri-cable.fr...
Maki a écrit:

Maybe this could be achived in some other, simpler way.
Any sugestions?

Very easily. Pass your timer number to the timer through a generic
parameter and inside the timer, define a constant base address based on
the generic:

Timers : for i in 0 to n_of_timers - 1 generate
begin
Timer : entity work.FROG1_Timer(rtl)
generic map ( --
tmr_nbr => i) --
port map (
clk => clk,
reg_bus => reg_bus,
reg_adr => reg_adr,
reg_rd => reg_rd,
reg_wr => reg_wr,
A => A(i),
B => B(i),
tmr_int => tmr_int_vec(i)
);
end generate;
 
Thank You for a quick answer :)
I agree with You on this. But ...
Timer module doesn't "know" if it is being copied with a generate statement.
And how many times. So it can't know address of its registers. Example:

Timers : for i in 0 to n_of_timers - 1 generate
begin
Timer : entity work.FROG1_Timer(rtl)
port map (
clk => clk,
reg_bus => reg_bus,
reg_adr => reg_adr,
reg_rd => reg_rd,
reg_wr => reg_wr,
A => A(i),
B => B(i),
tmr_int => tmr_int_vec(i)
);
end generate;

In the package constants are declared like this:
constant adr_tmr : std_logic_vector(4 downto 0) := "10000";
constant adr_tmr_cfg : std_logic_vector(4 downto 0) := "10001";

So every timer that is copied has the same address for data and cfg
registers.
This is bad. There is no difference between them.
But if I could somehow create array of constants which size depend of
generic parameter, perhaps I could access these constants and make all
timers have diferent address. Which is my goal. By changing one generic
parameter I'm allocating address space for these timers so I can access them
all because their address is diferent.

Maybe this could be achived in some other, simpler way.
Any sugestions?

Thanks,
M.

--
Veselic Mladen
Laboratorija Sigma
"Nicolas Matringe" <matringe.nicolas@numeri-cable.fr> wrote in message
news:41A59352.102@numeri-cable.fr...
Maki a écrit:
[...]
I other words I need to generate constants in the package depending on
the
value of generic. These constants should be diferent for every timer
that is
generated.
Any simple solution for this?

Hello
In my opinion, packages are for constants, not parameters. If you want
your constants to depend on a generic parameter, declare them directly
in your architecture.
Since packages must be compiled/analyzed before being used, you can't
make a constant in the package depend on an entity generic.

--
____ _ __ ___
| _ \_)/ _|/ _ \ Adresse de retour invalide: retirez le -
| | | | | (_| |_| | Invalid return address: remove the -
|_| |_|_|\__|\___/
 
Paul > As far as I understand the problem, I would declare multiple
constants
Paul > for each timer (or even an array of constants, making a table). In
the
Paul > architecture you then choose which constant (or which index into the
Paul > array) to use, depending on the value of your generic(s).

This cross my mind. But do You have an idea how to index the array? I have
only one generic n_of_timers.
Perhaps I can use counter value (i) in generate statement ?

Timers : for i in 0 to n_of_timers - 1 generate
begin
Timer : entity work.FROG1_Timer(rtl)
port map (
clk => clk,
reg_bus => reg_bus,
reg_adr => reg_adr,
reg_rd => reg_rd,
reg_wr => reg_wr,
A => A(i),
B => B(i),
tmr_int => tmr_int_vec(i)
);
end generate;

Somehow I have to pass it to timer entity? Like a generic maybe?
Best regards and thanks,
Maki.


--
Veselic Mladen
Laboratorija Sigma
"Paul Uiterlinden" <no@spam.nl> wrote in message
news:co4a28$85a$1@voyager.news.surf.net...
Maki wrote:
Hello all,

In top level description of my processor I have few generic constants.
One
of them define how much timers exist in the model.
Timers have two registers: TMR_CFG and TMR_VAL. I keep addresses of
these in
separate package as a constant.
How can initialize constants in the package depending of the value of
generic which is in top level file.

You can't. There is no way constants in a package can be set according
to a value of a generic.

I other words I need to generate constants in the package depending on
the
value of generic. These constants should be diferent for every timer
that is
generated.
Any simple solution for this?

As far as I understand the problem, I would declare multiple constants
for each timer (or even an array of constants, making a table). In the
architecture you then choose which constant (or which index into the
array) to use, depending on the value of your generic(s).

Paul.
 
Neo > You have got yourself into a tough situation, maybe you can try if
Neo > shared variables can help you out, but I am not sure.

Thanks Neo,
But this solution if for synthesis and I'm not sure that shared variables
are synthesisable.

Regards,
Maki
--
Veselic Mladen
Laboratorija Sigma

"Neo" <zingafriend@yahoo.com> wrote in message
news:e5de3dea.0411250212.3d60b546@posting.google.com...
"Maki" <veselic@eunet.yu> wrote in message
news:<co32mq$m8l$2@news.eunet.yu>...
Hello all,

In top level description of my processor I have few generic constants.
One
of them define how much timers exist in the model.
Timers have two registers: TMR_CFG and TMR_VAL. I keep addresses of
these in
separate package as a constant.
How can initialize constants in the package depending of the value of
generic which is in top level file.
I other words I need to generate constants in the package depending on
the
value of generic. These constants should be diferent for every timer
that is
generated.
Any simple solution for this?

Best regards and thanks.

Maki.

You have got yourself into a tough situation, maybe you can try if
shared variables can help you out, but I am not sure.

Neo
 
On Thu, 25 Nov 2004 11:26:21 +0100, "Maki" <veselic@eunet.yu> wrote:

Thank You for a quick answer :)
I agree with You on this. But ...
Timer module doesn't "know" if it is being copied with a generate statement.
And how many times. So it can't know address of its registers. Example:

Timers : for i in 0 to n_of_timers - 1 generate
begin
Timer : entity work.FROG1_Timer(rtl)
port map (
clk => clk,
reg_bus => reg_bus,
reg_adr => reg_adr,
reg_rd => reg_rd,
reg_wr => reg_wr,
A => A(i),
B => B(i),
tmr_int => tmr_int_vec(i)
);
end generate;

In the package constants are declared like this:
constant adr_tmr : std_logic_vector(4 downto 0) := "10000";
constant adr_tmr_cfg : std_logic_vector(4 downto 0) := "10001";

So every timer that is copied has the same address for data and cfg
registers.
This is bad. There is no difference between them.
But if I could somehow create array of constants which size depend of
generic parameter, perhaps I could access these constants and make all
timers have diferent address. Which is my goal. By changing one generic
parameter I'm allocating address space for these timers so I can access them
all because their address is diferent.

Maybe this could be achived in some other, simpler way.
Any sugestions?
The way I've done this before is to break the address of each register
up into 'base' and 'offset' parts. The constants in the package
define the offsets of each register and the base is passed in as a
generic. The address of each register in the instantiated
architecture is of course (offset + base) or in one rather successful
implementation I used, it was (offset or base).

Regards,
Allan
 
Maki wrote:
Paul > As far as I understand the problem, I would declare multiple
constants
Paul > for each timer (or even an array of constants, making a table). In
the
Paul > architecture you then choose which constant (or which index into the
Paul > array) to use, depending on the value of your generic(s).

This cross my mind. But do You have an idea how to index the array? I have
only one generic n_of_timers.
Perhaps I can use counter value (i) in generate statement ?

Timers : for i in 0 to n_of_timers - 1 generate
begin
Timer : entity work.FROG1_Timer(rtl)
port map (
clk => clk,
reg_bus => reg_bus,
reg_adr => reg_adr,
reg_rd => reg_rd,
reg_wr => reg_wr,
A => A(i),
B => B(i),
tmr_int => tmr_int_vec(i)
);
end generate;

Somehow I have to pass it to timer entity? Like a generic maybe?
Exactly! Put the counter value of the generate loop in the generic map
and use the generic in the architecture FROG1_Timer(rtl) to index the array.

Timers : for i in 0 to n_of_timers - 1 generate
begin
Timer : entity work.FROG1_Timer(rtl)
generic map(
timer_nr => i
)
port map (
...

Paul.
 

Welcome to EDABoard.com

Sponsor

Back
Top