Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VHDL - Conditional attribute declaration depending on a generic

Tags:

vhdl

How do I write a code segment which would evaluate a generic and create (or not create) an attribute accordingly?

Example :

if G_MY_GENERIC then
    attribute my_attribute_typ : string;
    attribute my_attribute_typ of signal_having_an_attr : signal is "value";
else
    --nothing is created
end if;
like image 545
Passepartout Avatar asked Jul 09 '26 17:07

Passepartout


2 Answers

Instead you have to use something like the following to conditionally set an attribute (cumbersome, but achieves the result):

  signal asvRam : svRam_at(0 to gc_nFifoDepth-1) := (others => (others => '0'));

  type svStr_at is array(boolean) of string(0 to 10);
  constant c_svRamStyle : svStr_at := (false => "           ", true => "distributed");
  attribute ram_style : string;
  attribute ram_style of asvRam : signal is c_svRamStyle(gc_bDistributedRam);
like image 125
Knut Krogstad Avatar answered Jul 12 '26 08:07

Knut Krogstad


It is perfectly possible to write something similar to that, but the attribute will only be visible in the scope of the generate statement.

g_something: if test_condition generate
   attribute my_attribute_typ : string;
   attribute an_attribute of my_attribute_typ: signal is "value";
begin
    -- attribute is visible in this scope

    p_my_process: process(clk)
    begin
        -- attribute is also visible here
    end process;
end generate;

-- but not here
like image 34
OllieB Avatar answered Jul 12 '26 06:07

OllieB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!