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.

Vhdl fpga implementation (subroutine call, assign port)

Status
Not open for further replies.

p11

Banned
Joined
Jan 25, 2014
Messages
177
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
0
hi i have started learning vhdl. I am tryimg to display a string in FPGA spartan 3E. Please someone help me , because i cant understand how to call a subroutine in fpga . I mean if in the program some statements need to get executed many times then its quite impractical to write those statements in the program again & again. so i am trying to get something equivalent to GOTO in C , or call subroutine type used in microprocessors.
Besides i also want to know that say if 'A' is assigned as a output port as A:OUT STD _ LOGIC , then in the program can we write A<= 'p' in order to display P in lcd or we need to define another signal in the program. like , Signal c:std_ logic

and then in architecture C <= 'p'. If so then why ?? I mean why cant we write A<='p'.

THANKS.
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,065
Helped
2,077
Reputation
4,171
Reaction score
2,030
Trophy points
1,393
Activity points
39,113
You're approaching the problem all wrong. An FPGA is nothing like a processor - its a big block of hardware. You VHDL descibes a "chip" that gets placed inside the FPGA. each entity is it's own chip and each chip connects to other chips (like on a circuit board). So there is no such thing as a subrouting, because all hardware always exists and always runs in parrallel.

I suggest you take up a good VHDL tutorial, and find a good digital logic text book. Then when you come back to the problem, draw the circuit you intend to create before you write any VHDL. this is a Hardware Description Language. WIthout understand what hardware you want, theres no chance of writing any meaningful code.
 

p11

Banned
Joined
Jan 25, 2014
Messages
177
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
0
ERROR:HDLParsers:164 - "C:/Users/user/Desktop/phd/xilinx/led/led2.vhd" Line 61. parse error, unexpected PROCEDURE
ERROR:HDLParsers:164 - "C:/Users/user/Desktop/phd/xilinx/led/led2.vhd" Line 73. parse error, unexpected PROCEDURE

Code:
----------------------------------------------------------------------------------
-- Company: 
-- Engineer: 
-- 
-- Create Date:    00:44:57 05/11/2015 
-- Design Name: 
-- Module Name:    led2 - Behavioral 
-- Project Name: 
-- Target Devices: 
-- Tool versions: 
-- Description: 
--
-- Dependencies: 
--
-- Revision: 
-- Revision 0.01 - File Created
-- Additional Comments: 
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity d is
    Port ( clk : in  STD_LOGIC;
           d : in STD_LOGIC;
           q : out  STD_LOGIC);
end d;





architecture Behavioral of d is
begin

 process ( clk ,d )
 
 begin  
 if (clk <='1') then 
 
 q<=d;
 
 else 
 
 q<='0';

end if;
procedure add;..............  [B]line 61[/B]

end process; 

 


end Behavioral;


procedure add is ....... [B]line 73[/B]

begin 
variable a,o :integer := 1
o:= a+1;

end procedure;

plz correct me.i have mentioned the lines of errors.
 
Last edited by a moderator:

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,065
Helped
2,077
Reputation
4,171
Reaction score
2,030
Trophy points
1,393
Activity points
39,113
using the procedure keyword is declaring a new procedure, and you cannot declare a procedure inside the run time area of a procedure, it must be declared before the begin. If you intended to call this procedure, then you cannot call a procedure that has not been declared yet.

Procedures must be declared in the declarative region of something. ie. before the "begin"
 

vGoodtimes

Advanced Member level 4
Joined
Feb 16, 2015
Messages
1,089
Helped
307
Reputation
614
Reaction score
302
Trophy points
83
Activity points
8,730
Procedures can be used to avoid repetition within a process. For example, many FSMs have an idle state with a lot of logic. Often, states that transition to the idle state could also skip the idle state and move directly to an active state. Developers often transition to the idle state for 1 cycle just to make the code easier to read and avoid the repetition (and associated maintainence issues). With a procedure, you can avoid the repetition. The implementation is not much larger, but may be slower.

I suggest you avoid them for now as their proper use in synthesis relies on a firm understanding of logic design in VHDL. It does sound like you are still trying to directly target a CPU.

IMO, procedures are eventually worth looking at.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top