Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Array 1D in VHDL Please

Status
Not open for further replies.

azwaa

Member level 1
Member level 1
Joined
May 21, 2014
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
197
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 :

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 reponse

- - - Updated - - -

Hi !

In fact; I shall want to make BPSK Modulation

- - - Updated - - -

Hi !

In fact; I shall want to make BPSK Modulation
 

You can't xor std_logic with a std_locgic_vector. Please consider which logical operation is exactly intended.

I noticed that you posted the same erroneous code at Altera Forum. Forum members suggested corrections that have been said to work correctly. Why don't you proceed from this point?
 

Thank you My friends !

In fact ; I have another problem :
"Error (10500): VHDL syntax error at cdma_testbipo.vhd(12) near text "type"; expecting an identifier ("type" is a reserved keyword), or "constant", or "file", or "signal", or "variable" ""

can you help me plz :


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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
 
Last edited by a moderator:

you can't declare a type or a signal in the middle of the entity port declaration.

move the lines:

Code:
type Re is array(0 to 3)of integer range 0 to 15;
signal CD: Re ;

to below the architecture statement.


Regards
 

Yeah ;

it's done !

but problem always return !!

""""

Error (10381): VHDL Type Mismatch error at cdma_testbipo.vhd(27): indexed name returns a value whose type does not match "integer", the type of the target expression"""""""

so we should to convert CD in array !!

Thank you

- - - Updated - - -

Code:
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  ;
        isis :out  integer range 0 to 3  ;
         S   :out integer range -8 to 7	);
end entity ;

architecture beh of cdma_testbipo is 
    
     type Re is array(0 to 3)of integer range 0 to 15;
           signal CD: Re ;
    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 ;
 

At first sight, changing the data to integer and integer arrays has brought up more confusion rather than fixing the original problem. Still not clear what you want to achieve.

code(0)<=CD(15 downto 12);
Please notice that the compiler just stops at the first error, detecting that LHS is an integer but RHS an integer array, so it can't be assigned. Next would be to detect that the array range doesn't exist and has wrong direction, CD has a range 0 to 3. Finally the integer ranges don't fit.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top