Parse error unexpected tick

I am trying to write a VHDL module but I have a problem with the if statement. Most probably it is a silly mistake, but since I am very new to VHDL, I could not figure out the problem. Here is my c...

I am trying to write a VHDL module but I have a problem with the if statement. Most probably it is a silly mistake, but since I am very new to VHDL, I could not figure out the problem. Here is my code:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;


entity binary_add is
    port( n1 : in std_logic_vector(3 downto 0);
    n2 : in std_logic_vector(3 downto 0);
    segments : out std_logic_vector(7 downto 0);
    bool : out bit;
    o : out std_logic_vector(3 downto 0);
    DNout : out std_logic_vector(3 downto 0));

end binary_add;

architecture Behavioral of binary_add is
begin

process(n1, n2) 
begin

o <= n1 + n2;

if( o = '1010') then 
bool <= '1';
else
bool <= '0';
end if;

end process;

end Behavioral;

And I get the following answer from the first line of if statement:

ERROR:HDLParsers:## - "C:/Xilinx/12.3/ISE_DS/ISE/.../binary_add.vhd" Line ##. parse error, unexpected TICK

What am I doing wrong?

asked Nov 2, 2010 at 17:07

makyol's user avatar

1

The ‘1010’ should be «1010» (double quotes). A single quote is used for a character literal (a single character).

answered Nov 2, 2010 at 17:15

mark4o's user avatar

mark4omark4o

57.8k17 gold badges85 silver badges101 bronze badges

2

So you have fixed the first error as per Mark’s answer.

The second error is that you can not make use of the value of an output.

if output = "0101";    -- illegal

some_signal <= output; -- illegal

To solve this you need to create an internal signal (say sum). You then use the internal signal, and assign it to the external signal.

architecture Behavioral of binary_add is

signal sum : std_logic_vector(3 downto 0);

begin

process(n1, n2, sum) 
begin

sum <= n1 + n2;

if( sum = '1010') then 
bool <= '1';
else
bool <= '0';
end if;

end process;

o <= sum;

end Behavioral;

answered Nov 3, 2010 at 10:13

George's user avatar

GeorgeGeorge

1,1228 silver badges13 bronze badges

Содержание

  1. Help me solve errors in VHDL code
  2. hahaconma
  3. Marcel Majoor
  4. parsing — PHP parse/syntax errors; and how to solve them
  5. Answer
  6. Solution:
  7. What are the syntax errors?
  8. Most important tips
  9. How to interpret parser errors
  10. Solving syntax errors
  11. White screen of death
  12. Answer
  13. Solution:
  14. Using a syntax-checking IDE means:
  15. Answer
  16. Solution:
  17. Unexpected <-code-11>-code-1>
  18. Unexpected <-code-21>closing square bracket
  19. Answer
  20. Solution:
  21. Unexpected An &quot<-code-13<-code-16>unexpected <-code-1<-code-16>&quot <-code-13<-code-16>means that there’s a literal <-code-2<-code-16>name <-code-8<-code-16>which doesn’t fit into the current expression/statement structure Missing semicolon It most commonly indicates a missing semicolon in the previous line <-code-4<-code-16>Variable assignments following a statement are a good indicator where to look: String concatenation Btw <-code-8<-code-16>you should prefer string interpolation <-code-23>basic variables in double quotes) whenever that helps readability <-code-4<-code-16>Which avoids these syntax issues String interpolation is a scripting language core feature <-code-4<-code-16>No shame in utilizing it <-code-4<-code-16>Ignore any micro-optimization advise about variable <-code-4<-code-16>concatenation being faster <-code-4<-code-16>It’s not Missing expression operators Of course the same issue can arise in other expressions <-code-8<-code-16> <-code-14<-code-16>instance arithmetic operations: PHP can’t guess here <-code-19>the variable should have been added <-code-8<-code-16>subtracted or compared etc Lists Or functions parameter <-code-11<-code-16>s: Class declarations This parser error also occurs in class declarations <-code-4<-code-16>You can only assign static constants <-code-8<-code-16>not expressions <-code-4<-code-16>Thus the parser complains about variables as assigned data: Unmatched <-code-16>closing curly braces can in particular lead here <-code-4<-code-16>If a method is terminated too early <-code-23>use proper indentation!) <-code-8<-code-16>then a stray variable is commonly misplaced into the class declaration body Variables after ident<-code-19>iers Take in mind that using variable variables should be the exception <-code-4<-code-16>Newcomers often try to use them too casually <-code-8<-code-16>even when arrays would be simpler and more appropriate Missing parentheses after language constructs Hasty typing may lead to <-code-14<-code-16>gotten opening or closing parenthesis <-code-14<-code-16> <-code-19>and <-code-14<-code-16>and <-code-14<-code-16>each statements: Solution: add the missing opening <-code-23>between statement and variable The curly < brace does not open the code block<-code-8<-code-16>without closing the <-code-19>expression with the ) closing parenthesis first Else does not expect conditions Solution: Remove the conditions from else or use Need brackets <-code-14<-code-16>closure Solution: Add brackets around $var Invisible whitespace As mentioned in the reference answer on &quot<-code-13<-code-16>Invisible stray Unicode&quot <-code-13<-code-16><-code-23>such as a non-breaking space) <-code-8<-code-16>you might also see this error <-code-14<-code-16>unsuspecting code like: It’s rather prevalent in the start of files and <-code-14<-code-16>copy-and-pasted code <-code-4<-code-16>Check with a hexeditor <-code-8<-code-16> <-code-19>your code does not visually appear to contain a syntax issue See also Answer Solution: Unexpected T_CONSTANT_ENCAPSED_STRING Unexpected T_ENCAPSED_AND_WHITESPACE The unwieldy names T_CONSTANT_ENCAPSED_STRING and T_ENCAPSED_AND_WHITESPACE refer to quoted «string» literals. They’re used in different contexts, but the syntax issue are quite similar. T_ENCAPSED… warnings occur in double quoted string context, while T_CONSTANT… strings are often astray in plain PHP expressions or statements. Incorrect variable interpolation And it comes up most frequently for incorrect PHP variable interpolation: Quoting arrays keys is a must in PHP context. But in double quoted strings (or HEREDOCs) this is a mistake. The parser complains about the contained single quoted ‘string’ , because it usually expects a literal identifier / key there. More precisely it’s valid to use PHP2-style simple syntax within double quotes for array references: Nested arrays or deeper object references however require the complex curly string expression syntax: If unsure, this is commonly safer to use. It’s often even considered more readable. And better IDEs actually use distinct syntax colorization for that. Missing concatenation If a string follows an expression, but lacks a concatenation or other operator, then you’ll see PHP complain about the string literal: While it’s obvious to you and me, PHP just can’t guess that the string was meant to be appended there. Confusing string quote enclosures The same syntax error occurs when confounding string delimiters. A string started by a single ‘ or double » quote also ends with the same. That example started with double quotes. But double quotes were also destined for the HTML attributes. The intended concatenation operator within however became interpreted as part of a second string in single quotes. Tip: Set your editor/IDE to use slightly distinct colorization for single and double quoted strings. (It also helps with application logic to prefer e.g. double quoted strings for textual output, and single quoted strings only for constant-like values.) This is a good example where you shouldn’t break out of double quotes in the first place. Instead just use proper for the HTML attributesВґ quotes: While this can also lead to syntax confusion, all better IDEs/editors again help by colorizing the escaped quotes differently. Missing opening quote Here the ‘, ‘ would become a string literal after a bareword, when obviously login was meant to be a string parameter. Array lists If you miss a , comma in an array creation block, the parser will see two consecutive strings: Note that the last line may always contain an extra comma, but overlooking one in between is unforgivable. Which is hard to discover without syntax highlighting. Function parameter lists Runaway strings A common variation are quite simply forgotten string terminators: Here PHP complains about two string literals directly following each other. But the real cause is the unclosed previous string of course. HEREDOC indentation Prior PHP 7.3, the heredoc string end delimiter can’t be prefixed with spaces: Solution: upgrade PHP or find a better hoster. See also Answer Solution: Unexpected is a bit of a misnomer. It does not refer to a quoted <-code-2>. It means a raw identifier was encountered. This can range from <-code-3>words to leftover <-code-4>or function names, forgotten unquoted strings, or any plain text. Misquoted strings This syntax error is most common for misquoted string values however. Any unescaped and stray <-code-5>or <-code-6>quote will form an invalid expression: Syntax highlighting will make such mistakes super obvious. It<-code-6>s important to remember to use backslashes for escaping <-code-33> <-code-5>double quotes, or <-code-33> <-code-6>single quotes — depending on which was used as string enclosure. For convenience you should prefer outer single quotes when outputting plain HTML with double quotes within. Use double quoted strings if you want to interpolate variables, but then watch out for escaping literal <-code-5>double quotes. For lengthier output, prefer multiple <-code-11>/ <-code-12>lines instead of escaping in and out. Better yet consider a HEREDOC section. Another example is using PHP entry inside HTML code generated with PHP: This happens if <-code-14>is large with many lines and developer does not see the whole PHP variable value and focus on the piece of code forgetting about its source. Example is here Unclosed strings It<-code-6>s not just literal s which the parser may protest then. Another frequent variation is an for unquoted literal HTML. Non-programming string quotes If you copy and paste code from a blog or website, you sometimes end up with invalid code. Typographic quotes aren<-code-6>t what PHP expects: Typographic/smart quotes are Unicode symbols. PHP treats them as part of adjoining alphanumeric text. For example <-code-20>is interpreted as a constant identifier. But any following text literal is then seen as a <-code-3>word/ by the parser. The missing semicolon <-code-29>again If you have an unterminated expression in previous lines, then any following statement or language construct gets seen as raw identifier: PHP just can<-code-6>t know if you meant to run two functions after another, or if you meant to multiply their results, add them, compare them, or only run one <-code-22>or the other. Short open tags and <-code-23>headers in PHP scripts This is rather uncommon. But if short_open_tags are enabled, then you can<-code-6>t begin your PHP scripts with an XML declaration: Share solution ↓ Additional Information: Didn’t find the answer? Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free. Similar questions Find the answer in similar questions on our website. Write quick answer Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger. About the technologies asked in this question PHP (from the English Hypertext Preprocessor — hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites. The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license. https://www.php.net/ Laravel Laravel is a free open source PHP framework that came out in 2011. Since then, it has been able to become the framework of choice for web developers. One of the main reasons for this is that Laravel makes it easier, faster, and safer to develop complex web applications than any other framework. https://laravel.com/ JavaScript JavaScript is a multi-paradigm language that supports event-driven, functional, and mandatory (including object-oriented and prototype-based) programming types. Originally JavaScript was only used on the client side. JavaScript is now still used as a server-side programming language. To summarize, we can say that JavaScript is the language of the Internet. https://www.javascript.com/ MySQL DBMS is a database management system. It is designed to change, search, add and delete information in the database. There are many DBMSs designed for similar purposes with different features. One of the most popular is MySQL. It is a software tool designed to work with relational SQL databases. It is easy to learn even for site owners who are not professional programmers or administrators. MySQL DBMS also allows you to export and import data, which is convenient when moving large amounts of information. https://www.mysql.com/ HTML (English «hyper text markup language» — hypertext markup language) is a special markup language that is used to create sites on the Internet. Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone. https://www.w3.org/html/ Welcome to programmierfrage.com programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration. Get answers to specific questions Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve. Help Others Solve Their Issues Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge. Источник
  22. Missing semicolon
  23. String concatenation
  24. Missing expression operators
  25. Lists
  26. Class declarations
  27. Variables after ident<-code-19>iers
  28. Missing parentheses after language constructs
  29. Else does not expect conditions
  30. Need brackets <-code-14<-code-16>closure
  31. Invisible whitespace
  32. See also
  33. Answer
  34. Solution:
  35. Unexpected T_CONSTANT_ENCAPSED_STRING Unexpected T_ENCAPSED_AND_WHITESPACE
  36. Incorrect variable interpolation
  37. Missing concatenation
  38. Confusing string quote enclosures
  39. Missing opening quote
  40. Array lists
  41. Function parameter lists
  42. Runaway strings
  43. HEREDOC indentation
  44. Answer
  45. Solution:
  46. Unexpected
  47. Misquoted strings
  48. Unclosed strings
  49. Non-programming string quotes
  50. The missing semicolon <-code-29>again
  51. Short open tags and <-code-23>headers in PHP scripts
  52. Share solution ↓
  53. Additional Information:
  54. Didn’t find the answer?
  55. Similar questions
  56. Write quick answer
  57. About the technologies asked in this question
  58. Laravel
  59. JavaScript
  60. MySQL
  61. Welcome to programmierfrage.com
  62. Get answers to specific questions
  63. Help Others Solve Their Issues

Help me solve errors in VHDL code

hahaconma

Newbie level 1

i’m a beginer in VHDL, when i wrote this code, it generated some errors, can somebody help me?
ERROR:HDLParsers:164 — «D:/Chinh/FPGA/lab/traffic/STAT_MAC.vhd» Line 40. parse error, unexpected TICK
ERROR:HDLParsers:164 — «D:/Chinh/FPGA/lab/traffic/STAT_MAC.vhd» Line 45. parse error, unexpected TICK
ERROR:HDLParsers:164 — «D:/Chinh/FPGA/lab/traffic/STAT_MAC.vhd» Line 51. parse error, unexpected TICK
ERROR:HDLParsers:164 — «D:/Chinh/FPGA/lab/traffic/STAT_MAC.vhd» Line 55. parse error, unexpected TICK

LIBRARY ieee;
USE ieee.std_logic_1164.all;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

ENTITY STAT_MAC IS
PORT (CLK,RESET: IN std_logic;
TIMER : in std_logic_vector ( 3 downto 0);
AMB, GRN, RD : out std_logic);

ARCHITECTURE BEHAVIOR OF STAT_MAC IS
— State variables for machine sreg
— SIGNAL AMBER, next_AMBER, GREEN, next_GREEN, RED, next_RED, REDAMB,
— next_REDAMB : std_logic;
SIGNAL next_AMB,next_GRN,next_RD : std_logic;
signal tmr : std_logic_vector (3 downto 0);
BEGIN
p00: PROCESS (CLK,next_AMB,next_GRN, next_RD)
BEGIN
IF CLK=’1′ AND CLK’event THEN
AMB

Marcel Majoor

Full Member level 2

Re: help me VHDL code

Just about the syntax problem:

You use ‘0000’ (with single quotes). This is not correct. This should be double quotes, like «0000».

For a std_logic_vector -> use «» (double quotes)
For a std_logic -> use » (single quotes)

Keep in mind that there is a difference between «0» and ‘0’ -> the first is a std_logic_vector (made of a single bit), and the second a std_logic (also a single bit). Since a std_logic is always a single bit, you will never see more than a single character within single quotes.

Added after 14 minutes:

Just one hint (since you will see that your code will not compile):

TIMER is defined as an input in your entity.
In the second process you want to assign a value to TIMER (based on RESET). This is not possible (TIMER being an input).
If TIMER is a signal, then you could do this, but not when it is an entity input.

This is typically handled like follows:

1. define a signal
signal tm: std_logic_vector(3 downto 0);

2. (outside a process, unless you want a synchronous reset) assign the entity signal to your signal
tmr

Источник

parsing — PHP parse/syntax errors; and how to solve them

Everyone runs into syntax errors. Even experienced programmers make typos. For newcomers, it’s just part of the learning process. However, it’s often easy to interpret error messages such as:

PHP Parse error: syntax error, unexpected ‘<-code-1>‘ in index.php on line 20

The unexpected symbol isn’t always the real culprit. But the line number gives a rough idea of where to start looking.

Always look at the code context. The syntax mistake often hides in the mentioned or in previous code lines. Compare your code against syntax examples from the manual.

While not every case matches the other. Yet there are some general steps to . This references summarized the common pitfalls:

Closely related references:

While Stack Overflow is also welcoming rookie coders, it’s mostly targetted at professional programming questions.

  • Answering everyone’s coding mistakes and narrow typos is considered mostly off-topic.
  • So please take the time to follow the basic steps, before posting syntax fixing requests.
  • If you still have to, please show your own solving initiative, attempted fixes, and your thought process on what looks or might be wrong.

If your browser displays error messages such as «SyntaxError: illegal character», then it’s not actually php-related, but a javascript-syntax error.

Syntax errors raised on vendor code: Finally, consider that if the syntax error was not raised by editing your codebase, but after an external vendor package install or upgrade, it could be due to PHP version incompatibility, so check the vendor’s requirements against your platform setup.

Answer

Solution:

What are the syntax errors?

PHP belongs to the C-style and imperative programming languages. It has rigid grammar rules, which it cannot recover from when encountering misplaced symbols or ident<-code-18>-code-11>iers. It can<-code-18>-code-8>t guess your coding intentions.

Most important tips

There are a few basic precautions you can always take:

Use proper code indentation, or adopt any lofty coding style. Readability prevents irregularities.

Read the language reference and examples in the manual. Twice, to become somewhat proficient.

How to interpret parser errors

A typical syntax error message reads:

Parse error: syntax error, unexpected <-code-18>-code-4<-code-18>-code-5>-code-2<-code-18>-code-5>, expecting <-code-18>-code-8> <-code-18>-code-4<-code-18>-code-5>-code-1<-code-18>-code-5> <-code-18>-code-8> in file.php on line 217

Which lists the possible location of a syntax mistake. See the mentioned file name and line number.

A moniker such as <-code-18>-code-4<-code-18>-code-5>-code-2<-code-18>-code-5> explains which symbol the parser/tokenizer couldn<-code-18>-code-8>t process finally. This isn<-code-18>-code-8>t necessarily the cause of the syntax mistake, however.

It<-code-18>-code-8>s important to look into previous code lines as well. Often syntax errors are just mishaps that happened earlier. The error line number is just where the parser conclusively gave up to process it all.

Solving syntax errors

There are many approaches to narrow down and fix syntax hiccups.

Open the mentioned source file. Look at the mentioned code line.

For runaway strings and misplaced operators, this is usually where you find the culprit.

Read the line left to right and imagine what each symbol does.

More regularly you need to look at preceding lines as well.

In particular, missing <-code-18>-code-4<-code-18>-code-5>-code-1<-code-18>-code-5> semicolons are missing at the previous line ends/statement. (At least from the stylistic viewpoint. )

If <-code-18>-code-4<-code-18>-code-5> code blocks <-code-18>-code-5> are incorrectly closed or nested, you may need to investigate even further up the source code. Use proper code indentation to simpl<-code-18>-code-11>y that.

Look at the syntax colorization!

Strings and variables and constants should all have d<-code-18>-code-11>ferent colors.

Operators <-code-18>-code-6> should be tinted distinct as well. Else they might be in the wrong context.

If you see string colorization extend too far or too short, then you have found an unescaped or missing closing <-code-18>-code-7> or <-code-18>-code-8> string marker.

Having two same-colored punctuation characters next to each other can also mean trouble. Usually, operators are lone <-code-18>-code-11> it<-code-18>-code-8>s not <-code-18>-code-9> , <-code-18>-code-10> , or parentheses following an operator. Two strings/ident<-code-18>-code-11>iers directly following each other are incorrect in most contexts.

Whitespace is your friend. Follow any coding style.

Break up long lines temporarily.

You can freely add newlines between operators or constants and strings. The parser will then concretize the line number for parsing errors. Instead of looking at the very lengthy code, you can isolate the missing or misplaced syntax symbol.

Split up complex <-code-18>-code-11> statements into distinct or nested <-code-18>-code-11> conditions.

Instead of lengthy math formulas or logic chains, use temporary variables to simpl<-code-18>-code-11>y the code. (More readable = fewer errors.)

Add newlines between:

  1. The code you can easily ident<-code-18>-code-11>y as correct,
  2. The parts you<-code-18>-code-8>re unsure about,
  3. And the lines which the parser complains about.

Partitioning up long code blocks really helps to locate the origin of syntax errors.

Comment out offending code.

If you can<-code-18>-code-8>t isolate the problem source, start to comment out (and thus temporarily remove) blocks of code.

As soon as you got rid of the parsing error, you have found the problem source. Look more closely there.

Sometimes you want to temporarily remove complete function/method blocks. (In case of unmatched curly braces and wrongly indented code.)

When you can<-code-18>-code-8>t resolve the syntax issue, try to rewrite the commented out sections from scratch.

As a newcomer, avoid some of the confusing syntax constructs.

The ternary <-code-18>-code-13> condition operator can compact code and is useful indeed. But it doesn<-code-18>-code-8>t aid readability in all cases. Prefer plain <-code-18>-code-11> statements while unversed.

PHP<-code-18>-code-8>s alternative syntax ( <-code-18>-code-11>: / else<-code-18>-code-11>: / end<-code-18>-code-11><-code-18>-code-4<-code-18>-code-5>-code-1<-code-18>-code-5> ) is common for templates, but arguably less easy to follow than normal <-code-18>-code-4<-code-18>-code-5> code <-code-18>-code-5> blocks.

The most prevalent newcomer mistakes are:

Missing semicolons <-code-18>-code-4<-code-18>-code-5>-code-1<-code-18>-code-5> for terminating statements/lines.

Mismatched string quotes for <-code-18>-code-7> or <-code-18>-code-8> and unescaped quotes within.

Forgotten operators, in particular for the string . concatenation.

Unbalanced ( parentheses ) . Count them in the reported line. Are there an equal number of them?

Don<-code-18>-code-8>t forget that solving one syntax problem can uncover the next.

If you make one issue go away, but other crops up in some code below, you<-code-18>-code-8>re mostly on the right path.

If after editing a new syntax error crops up in the same line, then your attempted change was possibly a failure. (Not always though.)

Restore a backup of previously working code, <-code-18>-code-11> you can<-code-18>-code-8>t fix it.

  • Adopt a source code versioning system. You can always view a d<-code-18>-code-11>f of the broken and last working version. Which might be enlightening as to what the syntax problem is.

Invisible stray Unicode characters: In some cases, you need to use a hexeditor or d<-code-18>-code-11>ferent editor/viewer on your source. Some problems cannot be found just from looking at your code.

In particular BOMs, zero-width spaces, or non-breaking spaces, and smart quotes regularly can find their way into the source code.

Take care of which type of linebreaks are saved in files.

PHP just honors n newlines, not r carriage returns.

Which is occasionally an issue for MacOS users (even on OS&nbsp<-code-18>-code-4<-code-18>-code-5>-code-1<-code-18>-code-5> X for misconfigured editors).

It often only surfaces as an issue when single-line // or # comments are used. Multiline /*. */ comments do seldom disturb the parser when linebreaks get ignored.

If your syntax error does not transmit over the web: It happens that you have a syntax error on your machine. But posting the very same file online does not exhibit it anymore. Which can only mean one of two things:

You are looking at the wrong file!

Or your code contained invisible stray Unicode (see above). You can easily find out: Just copy your code back from the web form into your text editor.

Check your PHP version. Not all syntax constructs are available on every server.

php -v for the command line interpreter

&lt<-code-18>-code-4<-code-18>-code-5>-code-1<-code-18>-code-5>?php phpinfo()<-code-18>-code-4<-code-18>-code-5>-code-1<-code-18>-code-5> for the one invoked through the webserver.

Those aren<-code-18>-code-8>t necessarily the same. In particular when working with frameworks, you will them to match up.

Don<-code-18>-code-8>t use PHP<-code-18>-code-8>s reserved keywords as ident<-code-18>-code-11>iers for functions/methods, classes or constants.

Trial-and-error is your last resort.

If all else fails, you can always google your error message. Syntax symbols aren<-code-18>-code-8>t as easy to search for (Stack Overflow itself is indexed by SymbolHound though). Therefore it may take looking through a few more pages before you find something relevant.

White screen of death

If your website is just blank, then typically a syntax error is the cause. Enable their display with:

  • error_reporting = E_ALL
  • display_errors = 1

Enabling it within the broken script is too late because PHP can<-code-18>-code-8>t even interpret/run the first line. A quick workaround is crafting a wrapper script, say test.php :

Then invoke the failing code by accessing this wrapper script.

Answer

Solution:

I think this topic is totally overdiscussed/overcomplicated. Using an IDE is THE way to go to completely avoid any syntax errors. I would even say that working without an IDE is kind of unprofessional. Why? Because modern IDEs check your syntax after every character you type. When you code and your entire line turns red, and a big warning notice shows you the exact type and the exact position of the syntax error, then there’s absolutely no need to search for another solution.

Using a syntax-checking IDE means:

You’ll (effectively) never run into syntax errors again, simply because you see them right as you type. Seriously.

Excellent IDEs with syntax check (all of them are available for Linux, Windows and Mac):

Answer

Solution:

Unexpected <-code-11>-code-1>

These days, the unexpected <-code-11>-code-1> array bracket is commonly seen on outdated PHP versions. The short array syntax is available since PHP >= 5.4. Older installations only support <-code-11>-code-3> .

Array function result dereferencing is likewise not available for older PHP versions:

Though, you’re always better off just upgrading your PHP installation. For shared webhosting plans, first research if e.g. <-code-11>-code-7> can be used to enable a newer runtime.

BTW, there are also preprocessors and PHP 5.4 syntax down-converters if you’re really clingy with older + slower PHP versions.

Other causes for Unexpected <-code-11>-code-1> syntax errors

If it’s not the PHP version mismatch, then it’s oftentimes a plain typo or newcomer syntax mistake:

Confusing <-code-11>-code-1> with opening curly braces <-code-11>or parentheses <-code-12>is a common oversight.

Or trying to dereference <-code-16>ants <-code-12>before PHP 5.6 <-code-23>as arrays:

At least PHP interprets that <-code-16>as a <-code-16>ant name.

If you meant to access an array variable <-code-12>which is the typical cause here<-code-23>, then add the leading <-code-17>sigil — so it becomes a <-code-17>varname .

You are trying to use the <-code-19>keyword on a member of an associative array. This is not valid syntax:

Unexpected <-code-21>closing square bracket

This is somewhat rarer, but there are also syntax accidents with the terminating array <-code-21>bracket.

Again mismatches with <-code-23>parentheses or > curly braces are common:

Or trying to end an array where there isn’t one:

Which often occurs in multi-line and nested array declarations.

If so, use your IDE for bracket matching to find any premature <-code-21>array closure. At the very least use more spacing and newlines to narrow it down.

Answer

Solution:

Unexpected

An &quot<-code-13<-code-16>unexpected <-code-1<-code-16>&quot <-code-13<-code-16>means that there’s a literal <-code-2<-code-16>name <-code-8<-code-16>which doesn’t fit into the current expression/statement structure

Missing semicolon

It most commonly indicates a missing semicolon in the previous line <-code-4<-code-16>Variable assignments following a statement are a good indicator where to look:

String concatenation

Btw <-code-8<-code-16>you should prefer string interpolation <-code-23>basic variables in double quotes) whenever that helps readability <-code-4<-code-16>Which avoids these syntax issues

String interpolation is a scripting language core feature <-code-4<-code-16>No shame in utilizing it <-code-4<-code-16>Ignore any micro-optimization advise about variable <-code-4<-code-16>concatenation being faster <-code-4<-code-16>It’s not

Missing expression operators

Of course the same issue can arise in other expressions <-code-8<-code-16> <-code-14<-code-16>instance arithmetic operations:

PHP can’t guess here <-code-19>the variable should have been added <-code-8<-code-16>subtracted or compared etc

Lists

Or functions parameter <-code-11<-code-16>s:

Class declarations

This parser error also occurs in class declarations <-code-4<-code-16>You can only assign static constants <-code-8<-code-16>not expressions <-code-4<-code-16>Thus the parser complains about variables as assigned data:

Unmatched <-code-16>closing curly braces can in particular lead here <-code-4<-code-16>If a method is terminated too early <-code-23>use proper indentation!) <-code-8<-code-16>then a stray variable is commonly misplaced into the class declaration body

Variables after ident<-code-19>iers

Take in mind that using variable variables should be the exception <-code-4<-code-16>Newcomers often try to use them too casually <-code-8<-code-16>even when arrays would be simpler and more appropriate

Missing parentheses after language constructs

Hasty typing may lead to <-code-14<-code-16>gotten opening or closing parenthesis <-code-14<-code-16> <-code-19>and <-code-14<-code-16>and <-code-14<-code-16>each statements:

Solution: add the missing opening <-code-23>between statement and variable

The curly < brace does not open the code block<-code-8<-code-16>without closing the <-code-19>expression with the ) closing parenthesis first

Else does not expect conditions

Solution: Remove the conditions from else or use

Need brackets <-code-14<-code-16>closure

Solution: Add brackets around $var

Invisible whitespace

As mentioned in the reference answer on &quot<-code-13<-code-16>Invisible stray Unicode&quot <-code-13<-code-16><-code-23>such as a non-breaking space) <-code-8<-code-16>you might also see this error <-code-14<-code-16>unsuspecting code like:

It’s rather prevalent in the start of files and <-code-14<-code-16>copy-and-pasted code <-code-4<-code-16>Check with a hexeditor <-code-8<-code-16> <-code-19>your code does not visually appear to contain a syntax issue

See also

Answer

Solution:

Unexpected T_CONSTANT_ENCAPSED_STRING
Unexpected T_ENCAPSED_AND_WHITESPACE

The unwieldy names T_CONSTANT_ENCAPSED_STRING and T_ENCAPSED_AND_WHITESPACE refer to quoted «string» literals.

They’re used in different contexts, but the syntax issue are quite similar. T_ENCAPSED… warnings occur in double quoted string context, while T_CONSTANT… strings are often astray in plain PHP expressions or statements.

Incorrect variable interpolation

And it comes up most frequently for incorrect PHP variable interpolation:

Quoting arrays keys is a must in PHP context. But in double quoted strings (or HEREDOCs) this is a mistake. The parser complains about the contained single quoted ‘string’ , because it usually expects a literal identifier / key there.

More precisely it’s valid to use PHP2-style simple syntax within double quotes for array references:

Nested arrays or deeper object references however require the complex curly string expression syntax:

If unsure, this is commonly safer to use. It’s often even considered more readable. And better IDEs actually use distinct syntax colorization for that.

Missing concatenation

If a string follows an expression, but lacks a concatenation or other operator, then you’ll see PHP complain about the string literal:

While it’s obvious to you and me, PHP just can’t guess that the string was meant to be appended there.

Confusing string quote enclosures

The same syntax error occurs when confounding string delimiters. A string started by a single ‘ or double » quote also ends with the same.

That example started with double quotes. But double quotes were also destined for the HTML attributes. The intended concatenation operator within however became interpreted as part of a second string in single quotes.

Tip: Set your editor/IDE to use slightly distinct colorization for single and double quoted strings. (It also helps with application logic to prefer e.g. double quoted strings for textual output, and single quoted strings only for constant-like values.)

This is a good example where you shouldn’t break out of double quotes in the first place. Instead just use proper for the HTML attributesВґ quotes:

While this can also lead to syntax confusion, all better IDEs/editors again help by colorizing the escaped quotes differently.

Missing opening quote

Here the ‘, ‘ would become a string literal after a bareword, when obviously login was meant to be a string parameter.

Array lists

If you miss a , comma in an array creation block, the parser will see two consecutive strings:

Note that the last line may always contain an extra comma, but overlooking one in between is unforgivable. Which is hard to discover without syntax highlighting.

Function parameter lists

Runaway strings

A common variation are quite simply forgotten string terminators:

Here PHP complains about two string literals directly following each other. But the real cause is the unclosed previous string of course.

HEREDOC indentation

Prior PHP 7.3, the heredoc string end delimiter can’t be prefixed with spaces:

Solution: upgrade PHP or find a better hoster.

See also

Answer

Solution:

Unexpected

is a bit of a misnomer. It does not refer to a quoted <-code-2>. It means a raw identifier was encountered. This can range from <-code-3>words to leftover <-code-4>or function names, forgotten unquoted strings, or any plain text.

Misquoted strings

This syntax error is most common for misquoted string values however. Any unescaped and stray <-code-5>or <-code-6>quote will form an invalid expression:

Syntax highlighting will make such mistakes super obvious. It<-code-6>s important to remember to use backslashes for escaping <-code-33> <-code-5>double quotes, or <-code-33> <-code-6>single quotes — depending on which was used as string enclosure.

  • For convenience you should prefer outer single quotes when outputting plain HTML with double quotes within.
  • Use double quoted strings if you want to interpolate variables, but then watch out for escaping literal <-code-5>double quotes.
  • For lengthier output, prefer multiple <-code-11>/ <-code-12>lines instead of escaping in and out. Better yet consider a HEREDOC section.

Another example is using PHP entry inside HTML code generated with PHP:

This happens if <-code-14>is large with many lines and developer does not see the whole PHP variable value and focus on the piece of code forgetting about its source. Example is here

Unclosed strings

It<-code-6>s not just literal s which the parser may protest then. Another frequent variation is an for unquoted literal HTML.

Non-programming string quotes

If you copy and paste code from a blog or website, you sometimes end up with invalid code. Typographic quotes aren<-code-6>t what PHP expects:

Typographic/smart quotes are Unicode symbols. PHP treats them as part of adjoining alphanumeric text. For example <-code-20>is interpreted as a constant identifier. But any following text literal is then seen as a <-code-3>word/ by the parser.

The missing semicolon <-code-29>again

If you have an unterminated expression in previous lines, then any following statement or language construct gets seen as raw identifier:

PHP just can<-code-6>t know if you meant to run two functions after another, or if you meant to multiply their results, add them, compare them, or only run one <-code-22>or the other.

Short open tags and <-code-23>headers in PHP scripts

This is rather uncommon. But if short_open_tags are enabled, then you can<-code-6>t begin your PHP scripts with an XML declaration:

Additional Information:

Didn’t find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Similar questions

Find the answer in similar questions on our website.

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

About the technologies asked in this question

PHP (from the English Hypertext Preprocessor — hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites. The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/

Laravel

Laravel is a free open source PHP framework that came out in 2011. Since then, it has been able to become the framework of choice for web developers. One of the main reasons for this is that Laravel makes it easier, faster, and safer to develop complex web applications than any other framework.
https://laravel.com/

JavaScript

JavaScript is a multi-paradigm language that supports event-driven, functional, and mandatory (including object-oriented and prototype-based) programming types. Originally JavaScript was only used on the client side. JavaScript is now still used as a server-side programming language. To summarize, we can say that JavaScript is the language of the Internet.
https://www.javascript.com/

MySQL

DBMS is a database management system. It is designed to change, search, add and delete information in the database. There are many DBMSs designed for similar purposes with different features. One of the most popular is MySQL. It is a software tool designed to work with relational SQL databases. It is easy to learn even for site owners who are not professional programmers or administrators. MySQL DBMS also allows you to export and import data, which is convenient when moving large amounts of information.
https://www.mysql.com/

HTML (English «hyper text markup language» — hypertext markup language) is a special markup language that is used to create sites on the Internet. Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/

Welcome to programmierfrage.com

programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration.

Get answers to specific questions

Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.

Help Others Solve Their Issues

Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.

Источник

Skip to main content

Forum for Electronics

Forum for Electronics

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.

  • Digital Design and Embedded Programming

  • PLD, SPLD, GAL, CPLD, FPGA Design

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Help me solve errors in VHDL code


  • Thread starter

    hahaconma


  • Start date

    Oct 17, 2009

Status
Not open for further replies.

  • #1

Newbie level 1

Joined
Jun 28, 2009
Messages
1
Helped
0
Reputation

0

Reaction score
0
Trophy points
1,281
Activity points

1,299


i’m a beginer in VHDL, when i wrote this code, it generated some errors, can somebody help me?
ERROR:HDLParsers:164 — «D:/Chinh/FPGA/lab/traffic/STAT_MAC.vhd» Line 40. parse error, unexpected TICK
ERROR:HDLParsers:164 — «D:/Chinh/FPGA/lab/traffic/STAT_MAC.vhd» Line 45. parse error, unexpected TICK
ERROR:HDLParsers:164 — «D:/Chinh/FPGA/lab/traffic/STAT_MAC.vhd» Line 51. parse error, unexpected TICK
ERROR:HDLParsers:164 — «D:/Chinh/FPGA/lab/traffic/STAT_MAC.vhd» Line 55. parse error, unexpected TICK

LIBRARY ieee;
USE ieee.std_logic_1164.all;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

ENTITY STAT_MAC IS
PORT (CLK,RESET: IN std_logic;
TIMER : in std_logic_vector ( 3 downto 0);
AMB, GRN, RD : out std_logic);

END STAT_MAC;

ARCHITECTURE BEHAVIOR OF STAT_MAC IS
— State variables for machine sreg
— SIGNAL AMBER, next_AMBER, GREEN, next_GREEN, RED, next_RED, REDAMB,
— next_REDAMB : std_logic;
SIGNAL next_AMB,next_GRN,next_RD : std_logic;
signal tmr : std_logic_vector (3 downto 0);
BEGIN
p00: PROCESS (CLK,next_AMB,next_GRN, next_RD)
BEGIN
IF CLK=’1′ AND CLK’event THEN
AMB <= next_AMB;
GRN <= next_GRN;
RD <= next_RD;
END IF;
END PROCESS;
p01 : process (TIMER)
begin
if ((TIMER = ‘0100’ or TIMER = ‘0101’ or TIMER = ‘0110’ or TIMER = ‘0111’ or
TIMER = ‘1100’ or TIMER = ‘1101’ or TIMER = ‘1110’ or TIMER = ‘1111’) and RESET = ‘0’) then
next_AMB <= ‘1’;
ELSE next_AMB <= ‘0’;
END IF;
if ((TIMER = ‘0000’ or TIMER = ‘0001’ or TIMER = ‘0010’ or TIMER = ‘0011’ or
TIMER = ‘0100’ or TIMER = ‘0101’ or TIMER = ‘0110’ or TIMER = ‘0111’) and RESET = ‘0’ ) then
next_RD <= ‘1’;
else next_RD <= ‘0’;
end if;

IF ((TIMER = ‘1000’ or TIMER = ‘1001’ or TIMER = ‘1010’ or TIMER = ‘1011’ )and RESET = ‘0’) then
next_GRN <=’1′;
ELSE next_GRN <=’0′;
END IF;
if RESET = ‘1’ then TIMER <= ‘0000’; end if;
end process;

END BEHAVIOR;

i wote it in XINLINX ISE 10.1

  • #2

Full Member level 2

Joined
Jan 17, 2004
Messages
148
Helped
69
Reputation

138

Reaction score
39
Trophy points
1,308
Activity points

1,569


Re: help me VHDL code

Just about the syntax problem:

You use ‘0000’ (with single quotes). This is not correct. This should be double quotes, like «0000».

For a std_logic_vector -> use «» (double quotes)
For a std_logic -> use » (single quotes)

Keep in mind that there is a difference between «0» and ‘0’ -> the first is a std_logic_vector (made of a single bit), and the second a std_logic (also a single bit). Since a std_logic is always a single bit, you will never see more than a single character within single quotes.

Added after 14 minutes:

Just one hint (since you will see that your code will not compile):

TIMER is defined as an input in your entity.
In the second process you want to assign a value to TIMER (based on RESET). This is not possible (TIMER being an input).
If TIMER is a signal, then you could do this, but not when it is an entity input.

This is typically handled like follows:

1. define a signal
signal tm: std_logic_vector(3 downto 0);

2. (outside a process, unless you want a synchronous reset) assign the entity signal to your signal
tmr <= TIMER when (RESET = ‘1’)
else
«0000»;

3. Use ‘tmr’ anywhere TIMER is used

From what I can see you where about to do this … (having degined tmr)

Status
Not open for further replies.

Similar threads

  • need help in pulse generator vhdl code

    • Started by Pratyusha Shukla
    • Aug 26, 2022
    • Replies: 2

  • Unwanted values in Result in VHDL

    • Started by Soh_bhat
    • Nov 12, 2022
    • Replies: 5

  • Digital Design and Embedded Programming

  • PLD, SPLD, GAL, CPLD, FPGA Design

  • This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.

Я пытаюсь написать модуль VHDL, но у меня проблема с оператором if. Скорее всего, это глупая ошибка, но, поскольку я очень новичок в VHDL, я не мог понять проблему. Вот мой код:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;


entity binary_add is
    port( n1 : in std_logic_vector(3 downto 0);
    n2 : in std_logic_vector(3 downto 0);
    segments : out std_logic_vector(7 downto 0);
    bool : out bit;
    o : out std_logic_vector(3 downto 0);
    DNout : out std_logic_vector(3 downto 0));

end binary_add;

architecture Behavioral of binary_add is
begin

process(n1, n2) 
begin

o <= n1 + n2;

if( o = '1010') then 
bool <= '1';
else
bool <= '0';
end if;

end process;

end Behavioral;

И я получаю следующий ответ из первой строки оператора if:

ERROR:HDLParsers:## - "C:/Xilinx/12.3/ISE_DS/ISE/.../binary_add.vhd" Line ##. parse error, unexpected TICK

Что я делаю не так?

2 ответа

«1010» должно быть «1010» (двойные кавычки). Одинарная кавычка используется для символьного литерала (один символ).


2

mark4o
2 Ноя 2010 в 20:15

Итак, вы исправили первую ошибку в соответствии с ответом Марка.

Вторая ошибка заключается в том, что вы не можете использовать значение вывода.

if output = "0101";    -- illegal

some_signal <= output; -- illegal

Чтобы решить эту проблему, вам нужно создать внутренний сигнал (скажем, сумму). Затем вы используете внутренний сигнал и назначаете его внешнему сигналу.

architecture Behavioral of binary_add is

signal sum : std_logic_vector(3 downto 0);

begin

process(n1, n2, sum) 
begin

sum <= n1 + n2;

if( sum = '1010') then 
bool <= '1';
else
bool <= '0';
end if;

end process;

o <= sum;

end Behavioral;


2

George
4 Ноя 2010 в 13:00

OpenCores

no use no use 1/1 no use no use

How to send string from RS232 with VHDL ?

by mmc01 on Nov 18, 2011
mmc01

Posts: 1

Joined: Nov 14, 2011

Last seen: Jul 23, 2012

I downloaded RS232 code from http://opencores.org/project,rs232_interface . I try to send string from FPGA to IC MAX232 with this code. In the line 95 I think I have to change data in this line. I want to send «ABC» to RS232. So, I change the code like in my image.

But when I run Check syntax it show many error like this.

ERROR:HDLParsers:164 — «C:/Users/PKRU/Documents/VHDL/test_rs232/test_rs232.vhd» Line 96. parse error, unexpected TICK

ERROR:HDLParsers:164 — «C:/Users/PKRU/Documents/VHDL/test_rs232/test_rs232.vhd» Line 102. parse error, unexpected IF, expecting CASE

ERROR:HDLParsers:164 — «C:/Users/PKRU/Documents/VHDL/test_rs232/test_rs232.vhd» Line 118. parse error, unexpected WHEN, expecting END

ERROR:HDLParsers:164 — «C:/Users/PKRU/Documents/VHDL/test_rs232/test_rs232.vhd» Line 122. parse error, unexpected WHEN, expecting END

ERROR:HDLParsers:164 — «C:/Users/PKRU/Documents/VHDL/test_rs232/test_rs232.vhd» Line 126. parse error, unexpected WHEN, expecting END

ERROR:HDLParsers:164 — «C:/Users/PKRU/Documents/VHDL/test_rs232/test_rs232.vhd» Line 132. parse error, unexpected WHEN, expecting END

please help me, How to send string from RS232 with VHDL ?

RE: How to send string from RS232 with VHDL ?

by vlogaras on Nov 18, 2011
vlogaras

Posts: 46

Joined: Aug 28, 2005

Last seen: Dec 15, 2014

Have you made a correct null modem connection between your board and the PC?

RE: How to send string from RS232 with VHDL ?

by fpga_is_funny on Nov 18, 2011
fpga_is_funny

Posts: 3

Joined: Dec 13, 2006

Last seen: Feb 9, 2023

Hello

It seems that you corrupted the syntax of the VHDL testbench while entering the test string of «ABC».

If you send me all of the needed files I will help you to proceed successfully with your project «RS232 data transmission controlled by FPGA / VHDL».

Best Regards

fpga_is_funny / Jens

no use no use 1/1 no use no use

© copyright 1999-2023
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Parse error syntax error unexpected это
  • Parse error syntax error unexpected что делать
  • Parse error syntax error unexpected use
  • Parse error syntax error unexpected token echo
  • Parse error syntax error unexpected t string expecting t function

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии