Unusual question about generic port use (optional ports??)

May 17, 2007 2 Replies

Hi all ... I have been writing VHDL for many years now, but can't seem to figure something out. I'm writing a component called "cell" (no it has nothing to do with the cell processor). Since there are so many different variations on my cell architecture I have chosen to use generics and generate statements to create the necessary cell type based on generic values.



Notice below that I have an input ep_in. Well, on some cells I don't need that input because the number of eprobs is zero. However, if I set num_eprobs to 0, ep_in becomes std_logic_vector(-1 downto 0).



Is there some way to disable the ep_in port when num_eprobs is 0? If not, does anyone have any clever ideas on how to get around this?



Thanks, James



entity cell is generic (cell_type : cell_types; num_children : integer range 1 to 6; num_eprobs : integer range 0 to 16; precision : integer); port ( clk : in std_logic; reset_l : in std_logic; -- c_in : in std_logic_vector(num_children*precision-1 downto 0); tp_in : in std_logic_vector(num_children*precision-1 downto 0); ep_in : in std_logic_vector(num_eprobs*precision-1 downto 0); -- val : out std_logic_vector(precision-1 downto 0)); -- output end cell;



Really you should try comp.lang.vhdl, since this isn't really anything specific to FPGA technology. :)

Get around what? A std_logic_vector(-1 downto 0) is perfectly OK, it just has no elements. It's a "null range", and it's very useful in exactly this situation.

If you dislike it, or one of your tools doesn't support it, you could write yourself a max function and do

ep_in : in std_logic_vector(max(num_eprobs*precision-1, 0) downto 0);

But you shouldn't need to.

Cheers,

-Ben-

a very simple solution is to create special cell without this signal and at each time you can call this component instead of the other using generate,

A.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required