![]() | ![]() | ![]() |
| | |||||||
| General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion? |
| | Thread Tools | Display Modes |
| | (permalink) |
| Experienced Member | How to start with programmable logic. 1. You'll need a PC with a parallel port (true parallel port, no USB adapters) 2. Download and install the Xilinx ISE Webpack from www.xilinx.com 3. get/buy/build the Xilinx Parallel cable III programming adapter 4. get a Xilinx CPLD, for example XC9572 in PLCC-44 package you can also buy a PLCC-44 to DIP adapter (e.g. Aries, from DigiKey) and use breadboard. When programming a CPLD (or FPGA) you don't create a program but description of the logic that implements the desired functionality, usually using a hardware description language. I will use VHDL in the example. Example #1: Implement a synchronous 4-bit counter with asynchronous reset and synchronous load (a little like a simplified 74161) signals active in '1', clock at rising edge. Create a new project, select directory and top level source HDL, Next> Select device (XC9572) and package (PC44) preferred language VHDL. Then you can use the wizard to create a new source (mycounter.vhd) and implement the logic - copy the VHDL code from below: Code: -- includes (common useful libraries)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- tutorial: 4 bit counter design
entity Mycounter is
Port ( reset : in std_logic; -- asynchronous reset
clk : in std_logic; -- master clock input, active rising edge
load : in std_logic; -- synchronous load enable
data : in std_logic_vector (3 downto 0); -- data to load if load is '1'
output : out std_logic_vector (3 downto 0)); -- output of the counter
end Mycounter;
architecture rtl of Mycounter is
-- VHDL does not allow using output signals as input so I need this helper signal
signal myout: std_logic_vector(3 downto 0);
begin
-- send out helper signal to the output pins
output <= myout;
-- this is the output signal
cntr: process (reset, clk)
begin
if reset = '1' then
myout <= "0000"; -- reset active ...
elsif rising_edge(clk) then -- no reset, so wait for rising edge of the clock
if load = '1' then
myout <= data; -- load was active so copy input data to the output
else
myout <= myout + 1; -- load was not active so count ....
end if;
end if;
end process cntr; --- that's all
end rtl; So let's add another file - User constraints file (.ucf) where we force the implementation to use specific pins for our signals Click on the left side Create new source and select implementation constraints, name it MyCounter.ucf. Here is my selection of pins: Code: NET "clk" LOC = "P5" ; NET "data<0>" LOC = "P1" ; NET "data<1>" LOC = "P2" ; NET "data<2>" LOC = "P3" ; NET "data<3>" LOC = "P4" ; NET "load" LOC = "P44" ; NET "output<0>" LOC = "P12" ; NET "output<1>" LOC = "P11" ; NET "output<2>" LOC = "P9" ; NET "output<3>" LOC = "P8" ; NET "reset" LOC = "P39" ; Now it is time to run implementation again and them to program the CPLD. To program the programming file into the CPLD connect the JTAG pins of the CPLD to the programming adapter, power the CPLD and adapter (5V for XC9500 family and 3.3V for XC9500XL family). Expand the Generate Programming File and select Configure Device (iMPACT). Use the default options. After programing the CPLD you can connect it on a breadboard and check that it performs the designed function - a 4-bit binary counter Enjoy. Petr |
| | |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Question about Inchworm+ | Quan | Micro Controllers | 54 | 28th October 2007 12:20 AM |
| UNIT Committment solution using Dynamic programming | arijit18 | Electronic Projects | 1 | 18th October 2007 08:27 PM |
| Programming languages | sram | General Electronics Chat | 9 | 2nd March 2007 04:14 PM |
| Xilinx CPLD programming | patroclus | General Electronics Chat | 6 | 5th October 2006 12:57 PM |
| static rams,xilinx,rockwell, and other components for sale | spencer | Datasheet/Parts Requests | 6 | 21st August 2003 06:36 AM |