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.

what's error in this vhdl code?

Status
Not open for further replies.

lzh08

Member level 2
Joined
May 28, 2004
Messages
45
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
565
--fdiv_even.vhd
LIBRARY ieee;
USE ieee.std_logic_1164.all;

package fdiv_even IS
function div_even(ClkIn : in std_logic)
return std_logic;
end;

package body fdiv_even IS
SIGNAL Clk:std_logic;
function div_even(ClkIn : in std_logic)
return std_logic is
BEGIN
PROCESS(ClkIn)
BEGIN
IF ClkIn'event AND ClkIn='1' THEN
Clk<=NOT Clk;
END IF;
END PROCESS;
ClkOut<=Clk;

END;

--fdiv_even.vhd
LIBRARY ieee;
USE ieee.std_logic_1164.all;
use work.fdiv_even.all;

entity div_top is
port
(
ClkIn : in std_logic;
ClkOut : out std_logic
);
end;

architecture action of div_top is

process(ClkIn)
begin
ClkOut <= div_even(ClkIn);
end process;
end;
 

Is this for synthesis or simulation?

I would not be surprised if a synthesis tool refused to synthesize this code.
 

package body fdiv_even IS
SIGNAL Clk:std_logic; -- SIGNAL declaration can't be here
function div_even(ClkIn : in std_logic)
return std_logic is

-- VARIABLE declaration HERE
-- and RETURN variable, for example, ClkOut !

BEGIN

PROCESS(ClkIn) -- ONLY Sequential Statements... :-((
BEGIN
IF ClkIn'event AND ClkIn='1' THEN
Clk<=NOT Clk;
END IF;
END PROCESS;

ClkOut<=Clk;
-- Return function result HERE
-- for example, return ClkOut
END;
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top