maciej
Newbie level 2
- Joined
- Nov 13, 2013
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 38
Since this is my first post here I say hello.
Now to the point. I have a 2-dimensional array 256x60 (256-bits of data from each sensor, maximum of 60 sensors are read in parallel). I would like to save it to FPGA's internal RAM as 16-bit words. It seemed easiest to split data stream from each sensor into 16 bits x 16 words. Now the question is how to do it?
First I have tried the following way:
This method fails because for loop requires constants as range parameters. And annoyingly synthesis doesn't give warnings (Quartus II), it just assumes startBit is always 0.
So the result here is:
While I would like to get the following result:
Any ideas how to approach the problem (short of copy-pasting the for loop 16 times with fixed numerical ranges)?
Just a few comments:
- A second index of SED_BUF is 0 at the moment to simplify the problem (I will assign a signal to it later). And synthesis is much shorter this way.
- I know that I could use the bit shift instead of multiplying by 16, but it is not the point here
Now to the point. I have a 2-dimensional array 256x60 (256-bits of data from each sensor, maximum of 60 sensors are read in parallel). I would like to save it to FPGA's internal RAM as 16-bit words. It seemed easiest to split data stream from each sensor into 16 bits x 16 words. Now the question is how to do it?
First I have tried the following way:
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 --type and signal definitions type SED_BUF_ARRAY_TYPE is array(255 downto 0, 59 downto 0) of std_logic; signal SED_BUF : SED_BUF_ARRAY_TYPE; signal WordNumber : natural range 0 to 31; --[...] process(clk) variable startBit : natural range 255 downto 0; begin if(clk'event and clk = '1') then if wordNumber < 16 then wordNumber <= wordNumber + 1; startBit := wordNumber*16; for bitInChainCnt in startBit to (startBit+15) loop meb_dti(bitInChainCnt - startBit) <= SED_BUF(bitInChainCnt, 0); end loop; else wordNumber <= 0; end if; end if; end process;
This method fails because for loop requires constants as range parameters. And annoyingly synthesis doesn't give warnings (Quartus II), it just assumes startBit is always 0.
So the result here is:
Code:
After 1'st rising edge of clk: meb_dti(15 downto 0) is equal to SED_BUF(15 downto 0, 0)
After 2'nd rising edge of clk: meb_dti(15 downto 0) is equal to SED_BUF(15 downto 0, 0)
...
After 16'th rising edge of clk: meb_dti(15 downto 0) is equal to SED_BUF(15 downto 0, 0)
While I would like to get the following result:
Code:
After 1'st rising edge of clk: meb_dti(15 downto 0) is equal to SED_BUF(15 downto 0, 0)
After 2'nd rising edge of clk: meb_dti(15 downto 0) is equal to SED_BUF(31 downto 16, 0)
...
After 16'th rising edge of clk: meb_dti(15 downto 0) is equal to SED_BUF(255 downto 240, 0)
Any ideas how to approach the problem (short of copy-pasting the for loop 16 times with fixed numerical ranges)?
Just a few comments:
- A second index of SED_BUF is 0 at the moment to simplify the problem (I will assign a signal to it later). And synthesis is much shorter this way.
- I know that I could use the bit shift instead of multiplying by 16, but it is not the point here