Continue to Site

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.

syntax error..dont know why model sim is showing this while compiling: vhdl

Status
Not open for further replies.

rambleach

Junior Member level 1
Joined
Apr 10, 2012
Messages
17
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,293
Activity points
1,397
this is a program for 2^n to n priority encoder



Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
 
entity encoder is
  generic (n:positive);
  port (a:in std_logic_vector(2**n-1 downto 0);
    z:out std_logic_vector(n-1 downto 0);
    v:out std_logic);
  end entity encoder;
 
  architecture exm1 of encoder is
  begin
    prc:process(a) is
   
    v<='0';
  z<=(others=>'0');
  for k in a'range loop
  if a(k)='1' then
  z<=std_logic_vector(to_unsigned (k,n));
  v<='1';
  exit;
end if;
end loop;
end process prc;
end architecture exm1 ;






Code:
** Error: C:/Modeltech_pe_edu_10.1a/examples/encoder.vhd(16): near "v": syntax error
** Error: C:/Modeltech_pe_edu_10.1a/examples/encoder.vhd(18): near "in": expecting ':'

these are compilation errors i cannot find anything wrong ..plzz help!! i
 
Last edited by a moderator:

remove the "is" after process
and you need a "begin" before the code inside the process
 
And as a general remark: try to use more specific names. Using v, z, a, n ... is not recommended.
 

the "is " seems to be optional , it didn't matter if i removed it or not !


@lucbra what do you mean by specific terms , can you please explain,.
 

You forgot the 'begin' statement after the process declaration


Code VHDL - [expand]
1
2
prc:process(a) is
begin



Kevin Jennings
 

yes "is" is optional. I use it because it matches the rest of VHDL's style (eg, if ... then, for ... loop, component ... is, entity ... is, with ... select, when ... else). But it doesn't actually matter. IIRC some editors have process macros that don't include them.

single letter variables are often expected to be index or temporary values in most coding styles. it isn't a syntax error, but you'll make people unhappy with cryptic names.
 
single letter variables are often expected to be index or temporary values in most coding styles. it isn't a syntax error, but you'll make people unhappy with cryptic names.

Permute answered this question perfectly.

i.e. in stead of
Code:
generic (
   n  : positive)

you could write:
Code:
generic
   Width : positive)

makes you code readable.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top