Variable Length Generics, so close and yet so far

Joined
Jun 25, 2009
Messages
1
Reaction score
0
Greetings. I'll describe what it is I'd like to do.

I'd like to enter in a generic of a varible length into a component. My original attempt was something like:

entity simp_shift_register is
generic(size:integer; value: STD_LOGIC_VECTOR(size-1 downto 0));
port( foo_out: STD_LOGIC
....
etc etc

One of the books I've looked through states that generics are always constants, and from attempts in general, this doesn't seem possible. For further information, this is what I did to work around in one instance:

==========

entity simp_shift_register is
generic(size:integer; value:integer);
Port ( s_out : out STD_LOGIC;
clk : in STD_LOGIC;
set : in STD_LOGIC);
end simp_shift_register;

architecture Behavioral of simp_shift_register is
constant weight : std_logic_vector(size-1 downto 0) := CONV_STD_LOGIC_VECTOR(value, size);
signal reg: STD_LOGIC_VECTOR(size-1 downto 0);
begin
process(clk) begin
if rising_edge(clk) then
if set = '1' then reg <= weight;
else reg <= reg(size-2 downto 0) & reg(size-1);
end if; -- set
end if; -- clk
end process;

s_out <= reg(size-1);

end Behavioral;

==============

That seemed to work out, but now I'm moving up in the hierarchy and trying to create a component that uses several of these shift registers, and therefore can pass through those values to load into them. Here's the byproduct of my efforts thus far, which illustrates some attempts:

------------
entity NicolletteNeuron is
generic(inumber:integer:=4; --number of synapses/inputs
size:integer:=8; --size of weight registers
--values:integer range 0 to 2**(size*inumber)-1:=2#11110000101010101100110001010101#; --weight values
values: bigAr:=(2#11110000#,2#10101010#,2#11001100#,2#01010101#);
--values:STD_LOGIC_VECTOR:='11110000101010101100110001010101';
signs:integer:=2#0010#); --signs of weights
Port ( inpoot : in STD_LOGIC_VECTOR (inumber-1 downto 0);
clk : in STD_LOGIC;
ootpoot : out STD_LOGIC;
set : in STD_LOGIC);
end NicolletteNeuron;
------------------

And TiffanyTypes is:

\\\\\
package TiffanyTypes is


type bigAr is array(0 to 99) of integer:=(0,0,0,0,0, 0,0,0,0,0,
0,0,0,0,0, 0,0,0,0,0,
0,0,0,0,0, 0,0,0,0,0,
0,0,0,0,0, 0,0,0,0,0,
0,0,0,0,0, 0,0,0,0,0,

0,0,0,0,0, 0,0,0,0,0,
0,0,0,0,0, 0,0,0,0,0,
0,0,0,0,0, 0,0,0,0,0,
0,0,0,0,0, 0,0,0,0,0,
0,0,0,0,0, 0,0,0,0,0);

end TiffanyTypes;
/////

As you can see, I'm new to VHDL. However, I'm working in a professor's lab, and he's been working with VHDL for many years and hasn't run across this situation yet, and isn't sure of a solution. (Not that he would condone all my attempts above). So my call is to any experts out there, this may be a tougher problem.

In the end, any way of passing in those values (I don't plan to pass them in at a level above NicolleteNeuron) that doesn't necessarily result in a bunch of excess hardware synthesis would be the 'bee's knees'. For example, my hope with the array attempt was that I'd never need more than a 100 shift registers and that the array elements that were never used wouldn't be synthesized.

If you're curious, I'm designing an artifical neuron to be realized on an FPGA. Eventually I plan to put together a network, and don't want to have to specify each input register to each neuron by hand, but want the sizes of those registers and the values within them to be flexible. I'm also aiming for extreme hardware efficiency and so don't want to include all the input lines to load in the register values in a normal way. (The component names are taken from Deus Ex characters.)

Thanks very much for any help anyone can offer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top