EmbDev.net

Forum: FPGA, VHDL & Verilog Wrong syntax near


von Cergey C. (cossack5)


Rate this post
useful
not useful
Hi,
Can someone help as to what's wrong with the following line of code:
  signal delay_needed : std_logic_vector(31 downto 0):= 
"0000000000000000000000000010100";

Full Code:
1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
4
5
use ieee.numeric_std.all;
6
use IEEE.std_logic_unsigned.all;
7
use IEEE.numeric_std.all;
8
use IEEE.std_logic_arith.all;
9
10
11
entity delay is
12
  port (clk : in std_logic; 
13
--delay to be generated.
14
        a : in std_logic_vector(31 downto 0);   
15
--this is a pulse to notify that time interval equal to delay is over.
16
        flag : out std_logic 
17
    );
18
end delay;
19
20
architecture Behavioral of delay is
21
    signal count :integer:=0;
22
    begin
23
    process(clk)
24
        begin
25
        if(clk'event and clk='1') then
26
        count <= count +1;   --increment counter.
27
        end if;
28
        --see whether counter value is reached,if yes set the flag.
29
        if(count = conv_integer(a)) then 
30
        count <= 0;
31
        flag <='1';
32
        else
33
        flag <='0';
34
        end if;
35
    end process;
36
37
end Behavioral;
38
39
library IEEE;
40
use IEEE.STD_LOGIC_1164.ALL;
41
42
43
use ieee.numeric_std.all;
44
use IEEE.std_logic_unsigned.all;
45
use IEEE.numeric_std.all;
46
use IEEE.std_logic_arith.all;
47
48
entity device is
49
    Port ( 
50
        CLK : IN STD_LOGIC;
51
         SATN : in INTEGER;
52
         VALUE : OUT INTEGER
53
           
54
           );
55
end device;
56
57
architecture Behavioral of device is
58
    signal flag : std_logic :='0';
59
    signal delay_needed : std_logic_vector(31 downto 0):= "0000000000000000000000000010100"; 
60
   inst_delay : test port map(clk,delay_needed,flag);
61
    
62
    type initvec is array (0 to 1022) of integer;
63
    signal g1 : initvec:=(others=>0);
64
    signal g2 : initvec:=(others=>0);
65
    signal ca : initvec:=(others=>0);
66
        signal tmp_shift : initvec:=(others=>0);
67
        
68
        type neg is array (0 to 9) of integer;
69
        signal reg : neg:=(others=>-1);
70
    
71
    
72
    type prns is array (31 downto 0) of integer;
73
    signal Prn   : prns:=(5,6,7,8,17,18,139,140,141,251,252,254,255,256,257,258,
74
  469,470,471,472,473,474,509,512,513,514,515,516,859,860,
75
    861,862);
76
begin
77
process(clk)
78
variable saveBit :integer;
79
variable count : integer;
80
begin
81
if(clk'event and clk='1') then
82
83
      for I in 0 to 1022 loop
84
      g1(I) <= reg(9);
85
      saveBit := reg(2)*reg(9);
86
      reg(1 to 9) <= reg(0 to 8);
87
      reg(1) <= saveBit;
88
    end loop;
89
    reg <=(others=>-1);
90
    for J in 0 to 1022 loop
91
      g2(J) <= reg(9);
92
      saveBit := reg(1)*reg(2)*reg(5)*reg(7)*reg(8)*reg(9);
93
      reg(1 to 9) <= reg(0 to 8);
94
      reg(1) <= saveBit;
95
    end loop;
96
    tmp_shift (0 to SATN) <= g2(1022-SATN to 1022); 
97
    g2(SATN+1 to 1022) <= g2(0 to 1022-SATN);
98
    g2(0 to SATN) <= tmp_shift (0 to SATN);
99
    
100
    if (flag'event and flag='1')
101
       then
102
         if (count < 1023) then
103
              VALUE <= -1*(g1(count)*g2(count));
104
           end if;      
105
        end if;
106
      end if;
107
end process;
108
109
end Behavioral;

: Edited by Moderator
von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
With your code I get this:
1
Size mismatch.  String literal "0000000000000000000000000010100"
2
is of size 31 but is expected to be of size 32.

After correction i get:
1
parse error, unexpected IDENTIFIER
This is for:
inst_delay : test port map(clk,delay_needed,flag);
But I cannot find any component named test. Should it be delay?

Additionaly the architecture header is not for instantiation, you must 
declare the component there. Instantiation is done later in the 
architectures body:
1
:
2
:
3
architecture Behavioral of device is
4
    signal flag : std_logic :='0';
5
    signal delay_needed : std_logic_vector(31 downto 0):= "00000000000000000000000000010100"; 
6
    
7
    type initvec is array (0 to 1022) of integer;
8
    signal g1 : initvec:=(others=>0);
9
    signal g2 : initvec:=(others=>0);
10
    signal ca : initvec:=(others=>0);
11
        signal tmp_shift : initvec:=(others=>0);
12
        
13
        type neg is array (0 to 9) of integer;
14
        signal reg : neg:=(others=>-1);
15
16
component delay is
17
  port (clk : in std_logic; 
18
        a : in std_logic_vector(31 downto 0);   
19
        flag : out std_logic 
20
    );
21
end component;    
22
23
    
24
    type prns is array (31 downto 0) of integer;
25
    signal Prn   : prns:=(5,6,7,8,17,18,139,140,141,251,252,254,255,256,257,258,
26
  469,470,471,472,473,474,509,512,513,514,515,516,859,860,
27
    861,862);
28
begin
29
   inst_delay : delay port map(clk,delay_needed,flag);
30
:
31
:

After fixing that you will get some errors further on you have to dig 
out...

And then this here:
1
use ieee.numeric_std.all;
2
use IEEE.std_logic_unsigned.all;
3
use IEEE.numeric_std.all;           -- second time: much is more?
4
use IEEE.std_logic_arith.all;
Never ever use the numeric_std and the std_logic_unsigned together. You 
may encounter some strange error messages due to double definitions of 
data types.

All in all: VHDL is not a programming language. Instead it is a 
description language. So you should have a picture of the hardware you 
want to describe (at least in mind). As far as I see you are 
programming. This is very obviuos here:
type initvec is array (0 to 1022) of integer;
That becomes a huge distributed RAM, eating up lots of FPGA ressources.

BTW: pleas use the [vhdl] tags around VHDL code.

: Edited by Moderator
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.