I have to pass a (6 downto 0) value (it is an output as std_logic_vector) from my top module to one of the sub module(as Generic). Is there any work around for this? (I know that an integer value contained in a signal can't be mapped to a generic variable.
To explain it clearly:
Top module has ------------ sample(6 downto 0);
--Instantiated module ----- count <= to_integer(signed(sample));
----sub_module(pb_debounce shown below) ----------- it has a generic variable named counter which needs the count value to be passed to it since this value comes from configurable memory and it can vary.
entity pb_debounce isgeneric(count :integer)port(----in/out ports));entity pb_debounce;architecture behavioral of pb_debounce issignal SHIFT_PB :std_logic_vector(count-1downto0);beginprocessbeginif rising_edge(clock)then--You're clock
SHIFT_PB(count-2Downto0)<= SHIFT_PB(count-1Downto1);--Shifting each cycle
SHIFT_PB(count-1)<=NOT PB;--PB is the pre-bounced signalIf SHIFT_PB(count-1Downto0)="0000"THEN--once the bounce has settled set the debounced value
PB_DEBOUNCED <= '1';ELSE
PB_DEBOUNCED <= '0';Endif;endprocess;end behavioral;
I need the shift register to be dependent on varying value of count which is captured from the top module.
I hope the question is clear.
You cant pass a signal as a generic. A generic is a constant at elaboration time thaat is used to set the module up before runtime. Therefore it makes no sense to try and connect a changing signal to it.
signal SHIFT_PB :std_logic_vector(count-1downto0);
makes absolutely no sense if the value of count can be modified when in operation (as opposed to during elaboration). That implies that the width of this vector can magically add or subtract the number of bits that are implemented in the design. Dynamic sizing of hardware is impossible, either the hardware exists or it doesn't.