Thursday, June 25, 2020

Atmel ATF1504AS(L) CPLD Development Board - Part 4 - Write an example program and Program the CPLD

For a basic demonstration we will write a small piece of code to demonstrate the CPLD Dev board is working.  This code will use a single switch to turn on and off some LEDs.


Create a Quartus project

Start up Quartus 13.1 on your computer and we will create a new project from scratch.

  • File => New Project Wizard

  • Enter the project details and Next>
 Working Directory
 C:\altera\projects\swtichled_cpld
 Project Name
 switchLed
 Top-level Entity
 switchLed



  • Click Yes


  • Click Next>

  • Enter the following Details and Click Finish
 Family     7000s
 Package PLCC
 Pin count
 44
 Available Devices
 EPM7064SLC44-5


  • Open the pin planner

  • Setup the following pins with "node name" and "location"


  • Create the top level Design file, Click OK, Click OK and then close the pin planner




  • Double click to open the switchLed Entity


  • Replace the file contents with this! and save it

 `timescale 1ns/1ps

module switchLed
(
    output led1, led2,
    input switch1
);

assign led1 = switch1;
assign led2 = !switch1;

endmodule


  • Compile the code by double clicking on Assembler

  • You should end up with two warnings, but it will be successful.

  • You should now have a .pof file in the output directory.
       


Create the Jed file using POF2JED

  • Startup POF2JED and enter these details and click "Run"
Input File
 C:\altera\projects\swtichled_cpld\output_files\switchLed.pof
 Device 1504AS
Output File
 C:\altera\projects\swtichled_cpld\output_files\switchLed.jed


Program the CPLD using ATMISP v7.3

  • Attach the ATDH1150USK-K programmer to the Dev board and your computer



  • Startup ATMISP v7.3 and Click on Edit => Add New Device and Click OK


  • Enter the following details and Click OK
 Device Name
 ATF1504AS
 JTAG Instruction
 Program/Verify
 JEDEC File
 C:\altera\projects\swtichled_cpld\output_files\switchLed.jed




  • Now click Run


  • It should finish with success, time to move on to the next step



Wednesday, June 24, 2020

Atmel ATF1504AS(L) CPLD Development Board - Part 3 - Development Software and Tools

One of the most annoying things about the Atmel CPLD's is that their ProChip Designer software is basically not available unless you pay hundreds of dollars.  However for all of you makers out there the only real money you'll have to spend will need to be on the programmer.  So lets have a look and see how this all works.

Just some things to note
  • Microchip bought Atmel, I will refer to them as Atmel (not much rebranding has been done).
  • Intel bought Altera, I will refer to them as Intel.

Getting Started

These are all of the resources that I will be using to get / setup / write and upload the software.
You can skip them for now. If you used the same parts I did, you will be able to just follow along.
It's important to note that where possible I will use alternate and freely available or cheap parts where possible.

PDF Resources

Software Resources :
Hardware Resources

Pin compatible parts and converters

For this project we will be using Verilog/VHDL the best thing about this is we can use alternate vendors software for the development environment and then convert it over to a compatible programming file.

Intel Compatibility

I specifically bought this part ATF1504AS-10JU44-ND.
The conversion according to the Atmel : ATF15xx Product Family Conversion is the following:

 Intel AtmelPOF2JED Version
 7064SLC44 1504AS-J44  3.30

This means I can use software normally used to program the 7064 Intel CPLD.


Get and Install  : Intel Development Environment

The Intel 7064 is a 7000 series Max CPLD so lets go to the Intel download site Intel Quartus Legacy Software and grab the latest version of Quartus that supports the 7000 Max series of CPLD.

Get Quartus 13.0 SP1 Web Edition. You do not need to get a license for the Web Edition. Download the ISO file so you can get it in one easy to install package. It is the same package for Windows and Linux.

I installed the 13.0 SP 1 Windows version on Windows 10.


Get and Install : Atmel POF2JED

Quartus produces a POF programming file, however to use Atmels programmer you need a JED file so get this software to do the conversion.

Go here Atmel : POF2JED and download and install POF2JED.

Get and Install : Atmel ATMISP v7.3

Atmels programmer "ATDH1150USB" needs ATMISP v7.3 to program the CPLD.

Go here Atmel : ATMISP v7.3 (for Windows 7, 8 and 10) and download and installed ATMISP v7.3

Get some test programs

https://radzaeem.gitbooks.io/altera-max-ii-cpld-tutorial/led-blink.html

https://learn.digilentinc.com/Documents/242

USB Programmer

I am using the rather expensive ATDH1150USB programmer.

However recently I saw this blog entry on Hackup.net where he built his own programmer and used OpenOCD to program the chip.  I will have a go at building and programming the Dev board with this as well in a later blog entry.














Atmel ATF1504AS(L) CPLD Development Board - Part 2 - Building the Dev Board

Let's build the CPLD development board so we can have some fun.

Order the board

You can get the board from PCBWay: ATF1504AS(L) CPLD Development Board.

If buy from PCBWay via the above link you'll be supporting me cover my prototyping mishaps.

If not you can just download the Gerbers and choose your own manufacturer of choice.

Order the parts

You will need the following parts ( or similar ).

 TagPart
 No
 - ATF1504AS-10JU44-ND CPLD
 1
 U1 PLCC Socket 44 pin
 1
 J1 JTAG Header
 1
 J2 Power Barrel Jack
 1
 C1 Capacitor SMD 0805 10uF
 1
 C2,3,4,5 Capacitor SMD 0805 0.1uF 4
R 1, 2, 3 Resistor SMD 0805 4.7K
 3
R 4 Resistor SMD 0805 10K
 1
J4,5
 Header Female 16 pin           
 2
 J3 Header Female 6 pin     1
 J6 Header Male 2 pin
 1

Build the board

Solder on all of the surface mount parts first
Solder on the PLCC socket
Solder on the remaining parts in any order
Insert the CPLD

Surface Mount Soldering

Don't be afraid of Surface Mount Device soldering (SMD), once you know the tricks you will find that it is actually much easier and cleaner than Through Hole soldering (TH).

I use the same chisel tip on my soldering iron for SMD as I do for TH.  It is important with SMD not to use too fine a tip, especially if you have a large pad or surrounding copper as the heat will quickly vanish.
  • Add solder to one pad of each pair first.
  • With some tweezers move the SMD part into the soldered pad with one hand while re-heating the solder with the other hand.  Then ensure the part is flat on the board by pushing down lightly and re-heating.
  • Lastly solder the other pad to the part.
Tip: When removing the soldering iron, do so quickly. This stops little legs forming. 
Tip: Hold the part in place for one second after removing the heat or it will move.

 

 
 
 
 

 




Tuesday, June 23, 2020

Atmel ATF1504AS(L) CPLD Development Board - Part 1- Research


I've been playing about with FPGA's for a while now and my single most read blog post ever is this one entitled "FPGAs".

I really like the idea however of trying to get some 5V CPLD's into my C64 to do some more complex chip replacement.  The only problem is that the ONLY manufacturer that is currently still manufacturing 5V CPLD's is Atmel (Yes yes I know Xilinx have a heap of stock left but they have actually ceased making them). So I wanted a chip that was good for new designs.

The big problem is that there is only one Dev board available, it's produced by Atmel in tiny quantities and it is really expensive compared to the cheap Chinese CPLD dev boards available for other manufacturers chips.  This is where my search of the Internet found this little beauty (or ugly) on Instructables, the "Ghetto Programmable Logic (CPLD) Development System"

Version 0.1 - Getting it wrong

So initially I replicated the Ghetto board exactly and I used a footprint that I'd downloaded for the socket that I'd selected.  On paper it looked fine.  In reality I completely stuffed up the pin assignment for the the PLCC 44 pin socket.  When importing the part into DipTrace, Library Loader did tell me to check the pin assignments, but assumed it would be fine . . . WRONG! 

So here is the bad version 0.1 board and the correct PLCC 44 pin socket pin out.


Version 0.2 - Getting it right

I took the opportunity to do some proper research this time and along with the correct pin out for the socket I also reviewed the capacitor and resistors required against the schematic from Atmel's development board.

Here is the list of changes:
  • Corrected PLCC44 pin socket pin out
  • Added additional resistors to the JTAG header
  • Added power header pins
  • Re-routed the pins to be sequentially numbered
  • Improved the silkscreen
  • Correct Headers to 0.1"

















Friday, June 12, 2020

FPGA's

This article has been relocated from my old blog "Perils of Wizdom"
--
For some reason I find these things fascinating, so I've started some more projects that I'll probably never ever finish.

There are a lot of really good projects out there for learning FPGA's and some really good stuff rebuilding retro computers.

Two I've taken an interest to are the MIST and the MEGA65.  Mainly because I am a child of the 70/80's and grew up in an age when you could really understand how your computer really worked.

Now I haven't got a clue about HDL ( VHDL or Verilog ) so I'm really just stuffing about but if you can get yourself the required hardware to run the cores here are my notes on how to build them on the latest ( at the time of writing ) Ubuntu distribution. Which surprisingly wasn't that hard to do.

This was all done in Vmware workstation 12.

Installing Xilinx 14.7 and Compiling the MEGA65 Core

1) Get Ubuntu Desktop 17.04
    https://www.ubuntu.com/download/desktop
    Do a default install.

2) Install everything in ~/Documents
    cd ~/Documents
    mkdir MEGA65
    cd MEGA65

3) Install git, libpng-dev
    sudo apt-get install git
    sudo apt-get install libpng-dev

3) Get git repositories required
    git clone https://github.com/MEGA65/mega65-core.git
    git clone https://github.com/gardners/Ophis.git
    git clone https://github.com/sasq64/cbmconvert.git

4) Compile and install cmbconvert
    cd ~/Documents/MEGA65/cbmconvert
    make -f Makefile.unix
    sudo make install

5) Download Xilinx 14.7 WebPACK
    https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/design-tools.html
    As I wish to use both Windows and Linux I got this file :
         Full DVD Single File Download Image (TAR/GZIP - 7.78 GB)
   
6) Create an account and get a FREE Webpack License
    https://www.xilinx.com/registration/sign-in.html?oamProtectedResource=wh%3Dwww.xilinx.com%20wu%3D%2Fmember%2Fforms%2Flicense-form.html%20wo%3D1%20rh%3Dhttp%3A%2F%2Fwww.xilinx.com%20ru%3D%252Fmember%252Fforms%252Flicense-form.html
    OR
    Wait until after the install

7) Install Xilinx 14.7
    cp Xilinx_ISE_DS_14.7_1015_1.tar ~/Documents/
    cd ~/Documents
    tar xvf Xilinx_ISE_DS_14.7_1015_1.tar
    cd ~/Documents/Xilinx_ISE_DS_14.7_1015_1
    sudo ./xsetup
    Accept multiple license agreements
    Choose ISE WebPACK from Edition List
    Don't install cable drivers . . .
    Install to default /opt/Xilinx

    You can remove Xilinx_ISE_DS_14.7_1015_1.tar and Xilinx_ISE_DS_14.7_1015_1.tar as they are no longer needed.

8) Start ISE for the first time and add your license ( or get one )
    . /opt/Xilinx/14.7/ISE_DS/settings64.sh
    ise

9) Add settings to your .bashrc so it is available every time you log in and/or start a terminal
    cd ~
    vi .bashrc
    Add this line to the end of the file
    . /opt/Xilinx/14.7/ISE_DS/settings64.sh

10) Compile the mega65 core
    cd ~/Documents/MEGA65/mega65-core
    ./compile.sh

11) Wait . . . this took about 53 minutes in the VM.  However the resulting core worked perfectly

Installing VMware Tools


1) Add source code to the list of Source repositories
    Click on the Ubuntu Icon and type Software, then click on "Software & Updates"
    Under the TAB Ubuntu Software, check the "Source Code" checkbox
    While you are there also pick a repository close to you, preferrably one you can get free downloads from
    in the "Download from:" Dropbox.

2) Install the source code
    apt-get source linux-image-$(uname -r)
   

3) Unzip and untar the tools and run the installer picking ALL of the default options
    cp VMwareTools-10.1.6-5214329.tar.gz /tmp
    cd /tmp
    gzip -d VMwareTools-10.1.6-5214329.tar.gz
    tar xvf VMwareTools-10.1.6-5214329.tar
    cd vmware-tools-distrib/
    ./vmware-install.pl

ALTERA Quartus II 13.1 - for the MIST


0) Get Altera Quartus II 13.1
    http://dl.altera.com/13.0sp1/?edition=web

    I got the Linux version, it's 4.5GB in size.

1) You will need to install the 32 bit version of the system libraries
    sudo bash
    dpkg --add-architecture i386
    apt-get update

    apt install apt-file            # We need to find 32 bit packages
    apt-file update                #  so use apt-file to search
    apt-file seach <package>        #  for them

    apt-get install libc6:i386         # Not too sure about the first 3
    apt-get install libstdc++6:i386     #
    apt-get install expat:i386        #
    apt-get install libfreetype6:i386    # But you definitely need these ones
    apt-get install libsm6:i386        #
    apt-get install libxrender1:i386    #
    apt-get install libfontconfig1:i386    #
    apt-get install libxext6:i386        #

2) Get a really old version of libpng12 both 32 and 64 bit.
   Because you can't symlink the new version and have it work as the Qt library it uses looks
   at the version number in the library.

    http://packages.ubuntu.com/xenial/amd64/libpng12-0/download
    http://packages.ubuntu.com/xenial/i386/libpng12-0/download

    dpkg -x libpng12-0_1.2.54-1ubuntu1_i386.deb outfiles
    cd outfiles/lib
    cp * /usr/lib/i386-linux-gnu/

    dpkg -x libpng12-0_1.2.54-1ubuntu1_amd64.deb outfiles54
    cd outfiles/lib/x86_64-linux-gni
    cp * /usr/lib/x86_64-linux-gnu/
   
3) Make a directory and untar the installer
    mkdir Altera
    cd Altera
    tar xvf Quartus-web-13.1.0.162-linux.tar .

4) Edit the setup file and change the first line From
    #!/bin/env bash
   To
    #!/bin/bash

5) Open a new terminal
    xhost +                  # Not sure about this as the graphical installer didn't work anyhow
    sudo bash
    ./setup.sh

6) It will go to the command line installer
    Press Enter lots
    Then hold down Enter for the agreement
    Then choose Y
    Then choose a new directory : /op/altera/13.1
    Then choose the defaults ( basically install the Free stuff )
    Wait . . .
    Do defaults

7) Start Quartus II
   Now both versions run:
    cd /opt/altera/13.1/quartus/bin
    ./quartus        # for 32 bit
    ./quartus --64bit    # for 64 bit

Compile the MIST C64 Core

1) Download and Compile C64 core for mist
    cd ~/Documents
    mkdir C64
    cd C64
    git clone https://github.com/sorgelig/C64_MIST.git

2) Start Quartus II
    Open Project and Compile

    It takes about 3mins 41 secs

    ~/Documents/C64/C64_MIST/output_files/C64_mist.rbf