azwaa
Member level 1
- Joined
- May 21, 2014
- Messages
- 32
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Activity points
- 197
Hi guys !
I have a big problem with my code about generic
question : How is that the program will be generic ?!
Can you help me plz
Thank you in advance for your reponse
I have a big problem with my code about generic
question : How is that the program will be generic ?!
Can you help me plz
Code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity correla is
generic (
longueur : natural :=8 );
port (
clk : in std_logic ;
rst : in std_logic ;
data: in std_logic_vector(11 downto 0) ;
--code: in std_logic_vector(15 downto 0 ) ;--for 4 bits
code: in std_logic_vector((4*longueur)-1 downto 0 ) ;---for generic
--Q :out std_logic_vector(17 downto 0) ) ;--for 4 bits
Q :out std_logic_vector((4*longueur)+1 downto 0)) ; ---for generic
end entity ;
architecture arch of correla is
--type RAM is array (0 to 3) of std_logic_vector(3 downto 0) ; --for 4 bits
type RAM is array (0 to 3) of std_logic_vector(longueur-1 downto 0) ;---for generic
--type ram16 is array (0 to 3) of signed(15 downto 0) ;--for 4 bits
type ram16 is array (0 to 3) of signed((4*longueur)-1 downto 0) ;---for generic
--type Rom is array (0 to 3) of signed(11 downto 0) ;--for 4 bits
type Rom is array (0 to 3) of signed((3*longueur)-1 downto 0) ;---for generic
signal voie :Rom ;
signal CD : RAM;
signal temp: ram16;
-- signal sum0 :signed (16 downto 0) ;
signal sum0 :signed (4*longueur downto 0) ;---for generic
--signal sum1 :signed (16 downto 0) ;--for 4 bits
signal sum1 :signed (4*longueur downto 0) ;---for generic
--signal AB :signed (17 downto 0) ;--for 4 bits
signal AB :signed ((4*longueur)+1 downto 0) ;---for generic
begin
--CD(0) <= code(15 downto 12);--for 4 bits
--CD(1) <= code(11 downto 8);--for 4 bits
---CD(2) <= code(7 downto 4);--for 4 bits
--CD(3) <= code(3 downto 0); --for 4 bits
AY:for j in 0 to 3 generate
CD(j)<=(code((longueur*j+(longueur-1)) downto (longueur*j)));---for generic
end generate AY ;
etalement:process(clk,rst)
begin
if(rst='1') then
Q <=(others=>'0');
F:for k in 0 to longueur-1 loop ---for generic
temp(k)<=x"0000";
end loop ;
--temp(0)<=x"0000";--for 4 bits
--temp(1)<=x"0000";--for 4 bits
--temp(2)<=x"0000";--for 4 bits
--temp(3)<=x"0000";--for 4 bits
else
if(clk'event and clk ='1') then
voie(0)<=signed(data) ;
B:for L in 1 to 3 loop
voie(L)<=voie(l-1);---for generic
end loop ;
--voie(1)<=voie(0);--for 4 bits
--voie(2)<=voie(1);--for 4 bits
--voie(3)<=voie(2); --for 4 bits
for i in 0 to 3 loop
--for i in 0 to longueur-1 loop
temp(i) <= voie(i)*signed(CD(i));
end loop ;
--sum0<= resize(temp(0),17)+temp(1) ;--for 4 bits
sum0<= resize(temp(0),(4*longueur)+1)+temp(1) ;---for generic
--sum1<= resize(temp(2),17)+temp(3) ;--for 4 bits
sum1<= resize(temp(2),(4*longueur)+1)+temp(3) ;---for generic
-- AB<=resize(sum0,18)+sum1 ;--for 4 bits
AB<=resize(sum0,(4*longueur)+2)+sum1 ;---for generic
Q<=std_logic_vector(AB) ;
end if ;
end if ;
end process ;
end architecture ;
Thank you in advance for your reponse