Monday, 24 April 2017

FPGA's

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