WinCupl batch file cupl.bat

Topics relating to PALs, CPLDs, FPGAs, and other PLDs used for the support or creation of 65-family processors, both hardware and HDL.
Post Reply
User avatar
akohlbecker
Posts: 282
Joined: 24 Jul 2021
Contact:

WinCupl batch file cupl.bat

Post by akohlbecker »

Hi everyone,

I've been experimenting with Atmel's programmable logic ICs and felt frustrated by the lack of a nice development workflow for them. Many people here have suggested using WinCupl's command-line tools, but a good example of how to do that was not easy to find.

So, I've created cupl.bat, which automatically compiles and fits a design (if necessary, depending on the "Device" tag in the pld file). The source code is available on my GitHub here https://github.com/adrienkohlbecker/cupl.bat and I'm also attaching it below.

My workflow, for now, is to connect to a Windows VM and edit my PLD with Notepad++. I have mapped this batch file to F6 in the editor, and it seems to work well enough for compilation and fitting. I'm more of a MacOS/Linux guy, so this is my first time writing a batch file and there may be obvious changes to make.

All feedback is welcome!
Attachments
cupl.bat-revB.zip
(3.47 KiB) Downloaded 237 times
User avatar
banedon
Posts: 742
Joined: 08 Sep 2013
Location: A missile silo somewhere under southern England

Re: WinCupl batch file cupl.bat

Post by banedon »

Hi Akohbecker

Thanks for this. I'll give it a test 'n tune when I start working on my next ATF1504 or 8 design.
gfoot
Posts: 871
Joined: 09 Jul 2021

Re: WinCupl batch file cupl.bat

Post by gfoot »

Hi Adrien, it looks useful for Windows use, and you've used some pretty advanced features if it's your first batch file!

Did you try my Wine-based scripts at all? As I find they do everything I need in Linux, to the point that I don't need to run a VM or anything like that.

I also found that I had to work a bit harder on the output to get it to give nice results for various different error conditions, as the way different errors are reported by WinCupl was a bit haphazard. (There's also more to do there for sure, my script sometimes hides errors that would be interesting for the user to see.)
User avatar
akohlbecker
Posts: 282
Joined: 24 Jul 2021
Contact:

Re: WinCupl batch file cupl.bat

Post by akohlbecker »

banedon wrote:
Hi Akohbecker

Thanks for this. I'll give it a test 'n tune when I start working on my next ATF1504 or 8 design.
Let me know how that goes!
gfoot wrote:
Hi Adrien, it looks useful for Windows use, and you've used some pretty advanced features if it's your first batch file!
Thanks, let's call it Stack Overflow-driven programming :mrgreen:
gfoot wrote:
Did you try my Wine-based scripts at all? As I find they do everything I need in Linux, to the point that I don't need to run a VM or anything like that.

I also found that I had to work a bit harder on the output to get it to give nice results for various different error conditions, as the way different errors are reported by WinCupl was a bit haphazard. (There's also more to do there for sure, my script sometimes hides errors that would be interesting for the user to see.)
I did, however I had trouble getting cupl to run properly. I was trying to run it on a Linux VM, but my main machine is an ARM Mac, and between Intel emulation and the hypervisor, it crashed with an illegal instruction error. I did not try on a native Linux box, as by then the effort was similar to connecting to my native Windows machine. I also figured it will be easier to run ATMISP natively, as I'm working with ATF150x parts and I haven't found any reference to running it headless.

I'm going to try and automate ATMISP using AutoHotKey next, so it can generate the svf file on Windows and I can program the device using my Mac.
User avatar
akohlbecker
Posts: 282
Joined: 24 Jul 2021
Contact:

Re: WinCupl batch file cupl.bat

Post by akohlbecker »

Making progress on getting CUPL programming to a bearable state.

I was able to move my CUPL editing and device programming to my main Mac M2 machine. I'm using UTM (QEMU under the hood), to virtualize Windows 11 ARM edition. (Guide to follow here: https://docs.getutm.app/guides/windows/). Inside Windows 11 ARM, both WinCUPL and ATMISP work flawlessly so far through Microsoft's translation layer. Finally, using UTM's USB sharing feature, I'm able to plug my Atmel programmer directly into the VM, and to program a CPLD successfully.

I did have some trouble initially with FTDI drivers, but putting the FTD2XX.DLL file found in this archive (https://ftdichip.com/wp-content/uploads ... utable.zip) inside the ATMISP directory made it work. I did have to use the one from the "x86" folder.

I also switched my editor to Visual Studio Code, with the build actions below. To use ATMISP like this you need to run it once manually to configure your device, and use it to save a .chn file with the same name of your .pld next to it. The following extension has syntax highlighting for CUPL: https://marketplace.visualstudio.com/it ... ighlighter

Next goals are : automate ATMISP to generate the svf file, and move to VSCode Server so I can edit and program natively on Mac without using the VM's GUI.

Code: Select all

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "cupl",
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "command": "C:\\Wincupl\\Projects\\cupl.bat ${fileDirname}\\${fileBasenameNoExtension}.pld"
        },
        {
            "label": "atmisp",
            "type": "shell",
            "group": "build",
            "command": "C:\\ATMISP7\\ATMISP.exe ${fileDirname}\\${fileBasenameNoExtension}.chn"
        }
    ]
}
User avatar
cbscpe
Posts: 491
Joined: 13 Oct 2013
Location: Switzerland
Contact:

Re: WinCupl batch file cupl.bat

Post by cbscpe »

It has been a rather long time I have been on 6502.org, mainly because my current projects are now mostly based on the DCJ11 (a PDP-11 Processor on a single device). I'm using ATF150x's a lot, and I'm in the same boat, that my only computer will be an ARM based Mac. I knew that under the hood WinCUPL just calls some programs, but I never imagined that there is a way to compile a CUPL design file by just using the command line interface.

Thanks a lot for your effort.

I always found the WinCUPL a horrible user interface and as all the editing is of course done on the Mac (using bbedit) as are all the other programs. Now have all error and success messages on the screen without having to acknowledge the success window of WinCUPL an have a look into the fitter output to make sure the design really fits. When you say you moved your device programming to the Mac I assume you use openocd? Did you make any progress on ATMISP? I really want to get rid of Windows as much as possible and the CPLDs are the last reason still having some Windows program, after I successfully managed to extract the avrasm2 from XC to even do assembly for AVR on my Mac.

Regards

Peter
harrowm
Posts: 1
Joined: 02 Feb 2025

Re: WinCupl batch file cupl.bat

Post by harrowm »

To program on a Mac, you could look at this:

https://store.rosco-m68k.com/products/l ... programmer

And the tools it uses here:

https://github.com/roscopeco/atfprog-tools
Post Reply