1
\$\begingroup\$

I'm getting a syntax error near data0_sim in the following code - New to vhdl and confused as I think this should work:

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library unisim;
use unisim.vcomponents.all;
signal data0_sim : std_logic_vector(8-1 downto 0);
data0_sim <= "00001111";
Gustavo Litovsky
7,7393 gold badges27 silver badges44 bronze badges
asked Sep 18, 2013 at 21:47
\$\endgroup\$
1
  • \$\begingroup\$ I'd suspect revealing just a bit more might be helpful. Constructing a simple testcase with an architecture declarative item for data0_sim and a concurrent signal assignment statement as shown yields no obvious errors, meaning more context appears needed. The actual error message might help, noting there can be errors that don't point to the character or line position where the actual syntax problem is found. \$\endgroup\$ Commented Sep 19, 2013 at 0:17

2 Answers 2

2
\$\begingroup\$

We can only guess since you haven't told us the syntax error, but from the code posted it MIGHT be:

signal data0_sim : std_logic_vector(8-1 downto 0);
data0_sim <= "00001111";

Now there are two things you might be trying to do here:

1) declare a signal and give it an initial value. The correct syntax for that is:

signal data0_sim : std_logic_vector(8-1 downto 0) := "00001111";

Note that the initialiser uses the variable assignment syntax,to indicate that signal assignment semantics (postponed assignment, event generation) don't apply.

2) declare a signal and later, assign it a value.

The correct syntax for that requires more context : declarations and statements occupy two different spaces in a VHDL unit. This follows programming languages such as Ada, but it is rather different from C.

In VHDL, the context may be an entity/architecture such as:

entity demo is
end demo;
architecture test of demo is
 -- declaration region : your signals, constants, types etc here
 signal data0_sim : std_logic_vector(8-1 downto 0);
begin
 -- statement region : your code here
 data0_sim <= "00001111";
end test;
answered Sep 19, 2013 at 8:32
\$\endgroup\$
2
  • \$\begingroup\$ Note you can't always tell an object declaration from an interface declaration - "If no mode is explicitly given in an interface declaration other than an interface file declaration, mode in is assumed." The syntax error could be as simple as trying to assign something to a port formal with a missing mode out. Further, a last formal declaration in the port clause with a missing closing parenthesis on say a std_logic_vector range with a following entity declarative item (e.g. data0_sim) could cause interesting complaints. There's as yet not enough context to address a syntax error. \$\endgroup\$ Commented Sep 19, 2013 at 10:45
  • \$\begingroup\$ Good points : my answer only covers some causes most likely to trip a beginner, not an exhaustive list. \$\endgroup\$ Commented Sep 19, 2013 at 10:52
1
\$\begingroup\$

Why don't you define a component, i.e.

entity example_ent is
 port (data0_sim : out std_logic_vector(7 downto 0));
end example_ent
architecture example_arch of example_ent is
begin
 data0_sim <= "00001111";
end example_arch
answered Sep 19, 2013 at 8:36
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.