UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Reply

Syntax error. HDLCompiler:806

Newbie
Posts: 3
Registered: ‎08-12-2010

Syntax error. HDLCompiler:806

hey there!

 

I am very new to FPGA's so bear with any silly mistakes but I made this VHDL file for the NEXSYS2, spartan 3e FPGA with this UCF file:

 

VHDL File:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
------------------------------------------------------------------

------------------------
-- Vergelijkers 8 bit --
------------------------
-- LET OP COMP8 is nu nog een COMP4 omdat er maar 8 schakelaars op het bord zijn.
entity Comp8 is
port(CA8, CB8 : in std_logic_vector(3 downto 0);
IsEqualCP8 : out std_logic;
IsGrterCP8 : out std_logic;
IsSmllrCP8 : out std_logic;
SwapBtn : in std_logic);
end Comp8;
architecture AComp8 of Comp8 is
begin
if(SwapBtn = '0') then
IsEqualCP8 <= '1' when (CA8=CB8) else '0';
IsGrterCP8 <= '1' when (CA8>CB8) else '0';
IsSmllrCP8 <= '1' when (CA8<CB8) else '0';
elsif(SwapBtn = '1') then
IsGrterCP8 <= '1' when (CB8>CA8) else '0';
IsSmllrCP8 <= '1' when (CB8<CA8) else '0';
end if;
end AComp8;

 

and this UCF file:


NET "IsEqualCP8" LOC="J14"; --this is a led
NET "IsGrterCP8" LOC="J15"; 
--this is a led
NET "IsSmllrCP8" LOC="K15"; --this is a led
NET "CA8<0>" LOC="G18"; -- this is a switch
NET "CA8<1>" LOC="H18";
-- this is a switch
NET "CA8<2>" LOC="K18"; -- this is a switch
NET "CA8<3>" LOC="K17"; -- this is a switch
NET "CB8<0>" LOC="L14"; -- this is a switch
NET "CB8<1>" LOC="L13"; -- this is a switch
NET "CB8<2>" LOC="N17"; -- this is a switch
NET "CB8<3>" LOC="R17"; -- this is a switch
NET "SwapBtn" LOC="H13"; --this is a push button

 

Now the problem is that on syntax checking It throws these errors (three of them) : HDLCompiler:806. The errors refer to the blue marked lines in the VDHL file above.

 

"D:/Matthias Map/EINDWERKSTUK/FPGA/Projecten/testprojecten/Test0/Test0.vhd" Line 22: Syntax error near "if".

"D:/Matthias Map/EINDWERKSTUK/FPGA/Projecten/testprojecten/Test0/Test0.vhd" Line 26: Syntax error near "elsif".
"D:/Matthias Map/EINDWERKSTUK/FPGA/Projecten/testprojecten/Test0/Test0.vhd" Line 29: Syntax error near "if".

 

can anyone help me with this? The intend of the file is that you can compare two 4 bit numbers to be equal, greater then or smaller then one another. When NOT holding the push button it compares:

 

A=B

A<B

A>B

 

when holding the push button it should compare:


B=A -- I did not include that to avoid duplicate code

B<A

B>A

 

Could anybody help me out? many thanks in advance!

Teacher
Posts: 8,573
Registered: ‎08-14-2007

Re: Syntax error. HDLCompiler:806

Your "if" statements need to be inside a process.

-- Gabor
Newbie
Posts: 3
Registered: ‎08-12-2010

Re: Syntax error. HDLCompiler:806

Thanks. But how would I make this a process? Could you show me how I must code this in order for it  to work?

Teacher
Posts: 8,573
Registered: ‎08-14-2007

Re: Syntax error. HDLCompiler:806

Well I was hoping you would open your VHDL reference book, but...

 

Try:

 

architecture AComp8 of Comp8 is
begin

MY_PROCESS : process (CA8, CB8, SwapBtn) is
begin
  if(SwapBtn = '0') then
    IsEqualCP8 <= '1' when (CA8=CB8) else '0';
    IsGrterCP8 <= '1' when (CA8>CB8) else '0';
    IsSmllrCP8 <= '1' when (CA8<CB8) else '0';
  elsif(SwapBtn = '1') then
    IsGrterCP8 <= '1' when (CB8>CA8) else '0';
    IsSmllrCP8 <= '1' when (CB8<CA8) else '0';
  end if;
end process MY_PROCESS;

end AComp8;

-- Gabor
Newbie
Posts: 3
Registered: ‎08-12-2010

Re: Syntax error. HDLCompiler:806

I would open up a textbook if I had any :P

 

It didn't work btw, gave errors near "when'

 

I'll work on it tommorow.

Teacher
Posts: 8,573
Registered: ‎08-14-2007

Re: Syntax error. HDLCompiler:806

Yeah, that's true.  That syntax is only useful for an assignment outside a process.  I

have to say that VHDL is not my strong suit, but I dabble in it whenever I need to use

someone else's code.  There may be a more elegant way to write this, but you might

want to change your "when" syntax to "if" syntax like:

 

    if CA8 = CB8 then IsEqualCP8 <= '1';
    else IsEqualCP8 <= '0';

    end if;

 

Otherwise you could try to dump the process idea and merge your original "if"

statements into the "when" assignments like:

 

IsGrterCP8 <= '1' when (SwapBtn = '0') and (CA8>CB8) or (SwapBtn = '1') and (CB8>CA8) else '0';

But that isn't very readable.

 

By the way you don't have an assignment for IsEqualCP8 when SwapBtn = '1'

This will create a latch.

 

Finally I don't particularly like the syntax

if (SwapBtn = '0') then

 . . .

elsif (SwapBtn = '1') then

 . . .

end if;

 

When you really mean:

 

if (SwapBtn = '0') then

 . . .

else

 . . .

end if;

 

The latter makes it more clear that you have covered all cases and won't generate a latch.

 

Regards,

Gabor

-- Gabor
Teacher
Posts: 6,500
Registered: ‎02-25-2008

Re: Syntax error. HDLCompiler:806

 


mattigasz wrote:

I would open up a textbook if I had any :P

 


 

So, stop right now, hit your favorite online or real-world book store, and buy a copy of Peter Ashenden's "The Designer's Guide To VHDL."

 

As in, like right now.


----------------------------------------------------------------
Yes, I do this for a living.
Newbie
Posts: 2
Registered: ‎10-16-2012

Re: Syntax error. HDLCompiler:806

I'm having a similar problem with a Verilog testbench. I have this file below that gives me a syntax error near "end." But I have another file from the homework I'm doing that compiles fine and is literally the same code.

 

`timescale 1ns / 1ps

module ee101_hw5_q4_tb();

// Inputs
   reg [4:0] X;

// Output
   wire [5:0] Y;

// Bidirs

// Instantiate the UUT
   ee101_hw5_q4 UUT (
        .X(X),
        .Y(Y)
   );
// Initialize Inputs
        integer i;
       initial begin
            for (i = 0; i < 32; i = i + 1)
            begin
                X = i;
                #100;
            end
        end
endmodule

Newbie
Posts: 2
Registered: ‎10-16-2012

Re: Syntax error. HDLCompiler:806

I know it's very simple, but please help!
Newbie
Posts: 3
Registered: ‎04-04-2013

Re: Syntax error. HDLCompiler:806

Sorry, 

but I have 4 home works and 2 projects if any one can help me.