Probably getting
yosys installed is the hardest part. The quick start guide at
https://github.com/hoglet67/atf15xx_yosys is what I used to get my Verilog -> yosys -> ATF1508 JED file workflow set up, although I took his two scripts
run_yosys and
run_fitter and moved them to be on my executable $PATH.
Update on the CPLD on my 6809 board
The 6809 doesn't have the concept of pages or user mode/kernel mode (i.e. unprivileged and privileged modes). But it does raise the BS line when it loads the vector to deal with interrupts, reset and software interrupts (SWI). When the CPLD sees BS go high, it changes an internal register to mark the CPU entering kernel mode.
Actually, the CPLD keeps a stack of the last four transitions into kernel mode. Just before we RTI (return from interrupt), we access a memory address that tells the CPLD to go back to the previous mode:
sta prevmode
rti
We need this in case a usermode program does an SWI (system call) that goes into kernel mode. While the operating system is dealing with this, an interrupt comes in, keeping us in kernel mode. We use the above two instructions to leave the interrupt handler, going back to the system call code and we stay in kernel mode. And the syscall handler also uses these two instructions to return to the user code, this time transitioning back to user mode.
The CPLD also has eight page table entries for pages that are size 8K. This covers all of the 6809's 64K address space. Each page can be mapped to one of 64 page frames, which allows the system to have 51K of RAM.
In user mode 63.75K of address space is RAM (eight pages) except for the top 256 bytes which is ROM ($FFxx). We need this to hold the vectors for the reset and interrupt handlers. When we move to kernel mode, an I/O area at $FExx gets mapped in as well as nearly 32K of ROM from $8000 - $FDFF. These get mapped out when the CPLD takes us back to kernel mode.
We still need to be able to see all of the user's RAM in kernel mode, e.g. to copy data to/from the program and the filesystem. So there's a CPLD toggle mapped into the I/O area which allows the 32K ROM to be mapped in or out in kernel mode. Luckily the top 256 bytes of ROM stay mapped in :-)
All of this is working at 14.75MHz on my 6809 + ATF1508 board. I can start in kernel mode with the 32K ROM mapped, copy machine code to low RAM and switch to user mode (mapping out the I/O area and 32K ROM). The user code does an SWI to get back into kernel mode, which busy loops waiting for a flag to be raised that indicates keyboard data. The UART interrupt handler, when started, reads the UART, saves the character and raises this flag. Thus, we have a stack of user mode -> SWI handler in kernel mode -> UART interrupt handler in kernel mode.
What I did stuff up in my design is the wiring to the DS12C887 RTC device. I'll fix that on the next hardware revision. For now, I can get the CPLD to send a regular clock tick interrupt to the CPU, the whole purpose of the RTC device.
The fun continues! Cheers, Warren