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.

function syntex error in compilation

Status
Not open for further replies.

maheyadav333

Member level 1
Joined
Oct 22, 2010
Messages
36
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,518
why this function show the syntex error during compilation ?

# ** Error: C:/Users/user/Desktop/function bilbo/bilbo reg func.vhd(1): near "function": syntax error


function bilbo_reg (Si, b1 ,b2: std_logic;
Z: std_logic_vector(7 downto 0);
Q: std_logic_vector(7 downto 0))

return std_logic_vector is

variable FB: std_logic;
variable mode: std_logic_vector(1 downto 0);

begin

FB <= Q(1) xor Q(2) xor Q(3) xor Q(7) ;

mode := B1 & B2;
case mode is
when "00" => -- Shift register mode
Q <= Si & Q(1 to NBITS-1);
when "01" => -- Pseudo Random Pattern Generator mode
Q <= FB & Q(1 to NBITS-1);
when "10" => -- Normal Operating mode
Q <= Z;
when "11" => -- Multiple Input Signature Register mode
Q <= Z(7 downto 0) xor (FB & Q(7 downto 1));
when others =>
end case;

return Q;

end bilbo_reg;
 

I guess, the function appears in a place, where no function is allowed, outside a package or architecture body, or without correctly finishing the preceeding declaration. In other words, the cause is before the text you're posting.
 

You are using variables inside a process. So this line is wrong:
FB <= Q(1) xor Q(2) xor Q(3) xor Q(7) ;

Use ':=' instead of '<=' while assigning to variables.

Change other lines too.

Also I am not sure whether you can return Q or not. I suggest you declare a temp variable and then copy the value of Q to it, in the beginning. And return this temp variable instead of Q.
 

Also, you cannot assign values to Q. It is an input to the function (and is also a constant). The only output is the return value. Therefor you need to make Q an internal variable rather than function input.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top