Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

Array en VHDL

Hi everybody !

I want to add(xor) data with CD in shape array and the result would be S

Can you help me correcting this code :

library ieee;use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity cdm is 
port (
         clk : in std_logic ;
         rst : in std_logic  ;
         data: in std_logic  ;
        odata: out std_logic  ;
         CD  : in  std_logic_vector(15 downto 0) ;
        isis :out  integer range 0 to 3  ;
         S   :out std_logic_vector(3 downto 0 ));
end entity ;
architecture beh of cdm is 
    type tab is array(3 downto 0)of std_logic_vector(15 downto 0);
        
        signal i      :integer range 0 to 3 ;
        signal idata  :std_logic  ;
        signal itab :tab ;
        begin 
         code :process(clk,rst)
               begin 
                    if(rst='1')then 
                     itab(i)<="0000" ;
                    else 
                        if(clk'event and clk='1')then 
                          
                           itab(i)<= not(CD(15 downto 12)xor (data));
                           S(i)<=itab(i);
                           i<= i+1 ;
                           
                           itab(i)<=not(CD (11 downto 8) xor(data));
                            S(i)<=itab(i);
                            i<=i+1 ;
                            
                           itab(i)<=not( CD(7 downto 4) xor (data));
                            S(i)<=itab(i);
                            i<=i+1;
                            
                           itab(i)<=not( CD(3 downto 0) xor (data));
                            S(i)<=itab(i);
                            i<=i+1 ;
                           
                           
                           
                                   
                           if i=3 then 
                                 idata<=data ;
                            end if ;
                          end if ;
                       end if ;
                  end process ;
                  isis<=i;
                 
                 odata<=idata ;
   end architecture ;          
   

Thank you in advance for your answer

13 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    is that error in this file or another? also as a sidenote, putting your code in code tags improves readability.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    hi guys !!

    i solved my problem but i have another is near of ""Type Re is array ""

    can you help me please !!

    """"

    library ieee;

    use ieee.std_logic_1164.all;

    use ieee.numeric_std.all;

    entity cdma_testbipo is

    port (

    clk : in std_logic ;

    rst : in std_logic ;

    data: in std_logic ;

    odata: out std_logic ;

    type Re is array(0 to 3)of integer range 0 to 15;

    signal CD: Re ;

    isis :out integer range 0 to 3 ;

    S :out integer range -8 to 7 );

    end entity ;

    architecture beh of cdma_testbipo is

    type RAM is array (0 to 3) of integer range -8 to 7;

    signal i :integer range 0 to 3 ;

    signal code : RAM;

    signal idata :std_logic ;

    begin

    code(0)<=CD(15 downto 12);

    code(1)<=CD(11 downto 8) ;

    code(2)<=CD(7 downto 4) ;

    code(3)<=CD(3 downto 0) ;

    bpsk :process(clk,rst)

    begin

    if(rst='1')then

    i<= 0;

    else

    if(clk'event and clk='1')then

    i<=i+1 ;

    if(idata='0') then

    s<=-code(i);

    else

    s<=code(i);

    end if;

    if(i=3) then

    idata<=data;

    end if;

    end if ;

    end if ;

    end process ;

    isis<=i;

    odata<=idata ;

    end architecture ;

    """""

    Thank you
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    you cannot declare an array type inside a port declaration. It will need to be in a package