EmbDev.net

Forum: FPGA, VHDL & Verilog Wrong syntax near


Author: Cergey Chaulin (cossack5)
Posted on:

Rate this post
0 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:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;


use ieee.numeric_std.all;
use IEEE.std_logic_unsigned.all;
use IEEE.numeric_std.all;
use IEEE.std_logic_arith.all;


entity delay is
  port (clk : in std_logic; 
--delay to be generated.
        a : in std_logic_vector(31 downto 0);   
--this is a pulse to notify that time interval equal to delay is over.
        flag : out std_logic 
    );
end delay;

architecture Behavioral of delay is
    signal count :integer:=0;
    begin
    process(clk)
        begin
        if(clk'event and clk='1') then
        count <= count +1;   --increment counter.
        end if;
        --see whether counter value is reached,if yes set the flag.
        if(count = conv_integer(a)) then 
        count <= 0;
        flag <='1';
        else
        flag <='0';
        end if;
    end process;

end Behavioral;

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;


use ieee.numeric_std.all;
use IEEE.std_logic_unsigned.all;
use IEEE.numeric_std.all;
use IEEE.std_logic_arith.all;

entity device is
    Port ( 
        CLK : IN STD_LOGIC;
         SATN : in INTEGER;
         VALUE : OUT INTEGER
           
           );
end device;

architecture Behavioral of device is
    signal flag : std_logic :='0';
    signal delay_needed : std_logic_vector(31 downto 0):= "0000000000000000000000000010100"; 
   inst_delay : test port map(clk,delay_needed,flag);
    
    type initvec is array (0 to 1022) of integer;
    signal g1 : initvec:=(others=>0);
    signal g2 : initvec:=(others=>0);
    signal ca : initvec:=(others=>0);
        signal tmp_shift : initvec:=(others=>0);
        
        type neg is array (0 to 9) of integer;
        signal reg : neg:=(others=>-1);
    
    
    type prns is array (31 downto 0) of integer;
    signal Prn   : prns:=(5,6,7,8,17,18,139,140,141,251,252,254,255,256,257,258,
  469,470,471,472,473,474,509,512,513,514,515,516,859,860,
    861,862);
begin
process(clk)
variable saveBit :integer;
variable count : integer;
begin
if(clk'event and clk='1') then

      for I in 0 to 1022 loop
      g1(I) <= reg(9);
      saveBit := reg(2)*reg(9);
      reg(1 to 9) <= reg(0 to 8);
      reg(1) <= saveBit;
    end loop;
    reg <=(others=>-1);
    for J in 0 to 1022 loop
      g2(J) <= reg(9);
      saveBit := reg(1)*reg(2)*reg(5)*reg(7)*reg(8)*reg(9);
      reg(1 to 9) <= reg(0 to 8);
      reg(1) <= saveBit;
    end loop;
    tmp_shift (0 to SATN) <= g2(1022-SATN to 1022); 
    g2(SATN+1 to 1022) <= g2(0 to 1022-SATN);
    g2(0 to SATN) <= tmp_shift (0 to SATN);
    
    if (flag'event and flag='1')
       then
         if (count < 1023) then
              VALUE <= -1*(g1(count)*g2(count));
           end if;      
        end if;
      end if;
end process;

end Behavioral;

: Edited by Moderator
Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

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

After correction i get:
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:
:
:
architecture Behavioral of device is
    signal flag : std_logic :='0';
    signal delay_needed : std_logic_vector(31 downto 0):= "00000000000000000000000000010100"; 
    
    type initvec is array (0 to 1022) of integer;
    signal g1 : initvec:=(others=>0);
    signal g2 : initvec:=(others=>0);
    signal ca : initvec:=(others=>0);
        signal tmp_shift : initvec:=(others=>0);
        
        type neg is array (0 to 9) of integer;
        signal reg : neg:=(others=>-1);

component delay is
  port (clk : in std_logic; 
        a : in std_logic_vector(31 downto 0);   
        flag : out std_logic 
    );
end component;    

    
    type prns is array (31 downto 0) of integer;
    signal Prn   : prns:=(5,6,7,8,17,18,139,140,141,251,252,254,255,256,257,258,
  469,470,471,472,473,474,509,512,513,514,515,516,859,860,
    861,862);
begin
   inst_delay : delay port map(clk,delay_needed,flag);
:
:

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

And then this here:
use ieee.numeric_std.all;
use IEEE.std_logic_unsigned.all;
use IEEE.numeric_std.all;           -- second time: much is more?
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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig