6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 11:13 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: 65C02 softcore computer
PostPosted: Sun May 10, 2015 6:58 pm 
Offline

Joined: Fri Sep 19, 2008 8:06 pm
Posts: 17
Location: Bordeaux, France
Hi everybody,

I haven't posted in a while, but I did decide to implement a 65C02 softcore (Jens Gutschmidt's cpu6502_tc) in an FPGA, along with VGA output in order to, in the longterm, have some fun with IDE hard drives.

For the moment, I have got the CPU and monochrome VGA output working, and will be working on getting the firmware (ROM) to be upgradeable via UART (as resynthesizing the whole project does take a bit of time...), and have PS/2 input in order to run a monitoring ROM of sorts. I do plan on having color VGA eventually, but my FPGA board's standard VGA output is limited to 8 colors (although more can be made with certain techniques). The VGA module is fixed at 640x480, and is of my own work (for a school project about 2 years ago). The VHDL code hooking all the modules together is dirty though, especially for address decoding :(. There are latches I need to get rid of. The character ROM comes from M. Rictor :D, I took it from here, and subsequently adapted it for use with my VGA controller module.

The board I am using is the Xilinx Spartan 3E Microblaze Development board (no longer in production unfortunately... link).

The current system is running at 25 MHz, although the RAM/VRAM and ROM are synchronous, so I'm running them at 50 MHz in order to get data out before the 65C02's inputs latch.

The system memory MAP is as follows for the moment:

00 - 24 KiB : Main RAM
24 - 32 KiB : Video RAM (Write Only)
32 - 64 KiB : ROM (with IRQ/NMI/RST vectors hard coded into ROM at the moment, even though NMI and IRQ are tied high...)

I am using the Kowalski Assembler/Simulator to produce code at the moment, which I integrate into Xilinx's ISE in a ROM file.

The code I have made to test the VGA at the moment is this:

Code:
 .ORG $8000

 LDX #$00             ; Load 0 into X (init)

.begin:
 LDA helloWorld,X     ; absolute indexed.
 CMP #$00             ; was the value 0?
 BEQ .done            ; done string copying
 STA $6000,X          ; store in video buffer...
 INX                  ; next value
 BRA .begin           ; else loop

.done:
 BRA .done            ; let's just branch on ourself.

helloWorld:
 .DB "Hello World. This is a very long line of text designed to test the VGA Output. I am a 65C02 running happily inside an FPGA. I am eating some electrons.",$00

 .ORG $FFFA ; Vectors, LSB then MSB
.nmiVec:
 .DB $00,$80
.rstVec:
 .DB $00,$80
.irqVec:
 .DB $00,$80


Nothing spectacular (there are tons of ways even just to improve that code, even if jut by adding labels for the vectors...), just a quick way to test the hardware. I plan on implementing some more complete tests/software later on.

Here is a report from the ISE on resource usage:

Image

The actual output on a monitor is as such:
Sorry for the terrible quality, I'm using my phone at the moment, since I can't find my camera charger...

Image

On a side note, I'd like to thank the members of this forum for the many discussions I have read and that inspired me to make this... I've been following this forum a long time, but have been more of a silent type here because my schedule is often filled, and when I wanted to start making microprocessor systems, I was motivated but lacked the knowledge... after some 5 years of university level education, things tend to make more sense... So many thanks! :D

EDIT: Added ISE Report and board used.


Last edited by MrLinuxGuy on Sun May 10, 2015 7:07 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
PostPosted: Sun May 10, 2015 7:02 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Looking good! You should be able to avoid resynthesis if all you did was change the content of initialised memory - see this thread:
viewtopic.php?f=10&t=2575


Top
 Profile  
Reply with quote  
PostPosted: Fri May 15, 2015 12:21 am 
Offline

Joined: Fri Sep 19, 2008 8:06 pm
Posts: 17
Location: Bordeaux, France
Hello again,

I've made some progress - I've gotten PS/2 Keyboard input, Color (3-bit color so 8 colors), and a way to upload the ROM via the UART on my development board. I tried implementing 16 colors à la "VGA Mode 0" by turning off the RGB lines every screen frame, but at 30 Hz it was too flickery, so for now I just ignore the intensity bit. So for now, the VRAM is as such: every even byte is the ASCII character to be displayed on the screen , and every odd byte is the style (background/foreground color and blinking foreground). The "style" byte is as so: BGGGIFFF, where B is for blinking, GGG is the RGB color triplet for the background, I is the intensity, and FFF the foreground RGB color triplet.

The PS/2 input is done using VHDL code from here, although I did modify the code so that it would work properly with the 65C02's interrupt line. The only problem is that I only have an AZERTY keyboard available, so I do tend to type in the wrong characters :D... It's qutie useful as it convert PS/2 scancodes straight into ASCII characters, even for things like Ctrl^C or Ctrl^H.

I've also used the following core in order to upload code straight to the ROM space on the board, and it works relatively well (under 5s for an upload with the binary mode included in the core).

I usually do try and develop everything on my own (usually to avoid any licensing/IP issues, and because I do think that learning in detail about the things you use helps you to understand them), but I'm trying to save some time and also learn how to trust and adapt to other people's code, because inevitably that will probably happen when I'm done with my studies and have to start working.

The system memory map is now as follows:

Code:
;;;; System Memory Map

;; 0000 - 0100   System ZP Variables
;; 0100 - 01FF   System Stack
;; 0400 - 0500   System RAM
;; 0500 - 5FFF   User RAM
;; 6000 - 7F3F  Video RAM (Currently 80x50 Mode-0 VGA = 8000 bytes of RAM, a 8192 RAM is used, but VHDL doesn't dispaly last 10 rows)
;; 7F40 - 7FFF  I/O Space
;;   7F40 - 7FFE : Reserved.
;;   7FFF - 7FFF : Keyboard Register
;; 8000 - FFF9  System ROM
;; FFFA - FFFF   System Vectors


And I'm writing a monitor ROM at the moment.

Here is a photo of the video output:

Image

It's all green because the VRAM loads by default with 0x20 (space in ASCII, green in background color for style), as I was debugging several issues with the style part of the display and testing the 80x50, as opposed to 80x60 characters 640x480 VGA can support.
The complete top left character is blinking, normally it's an "H" as well :D
There are still remains from when I tried to do the 16 colors, as normally the rightmost Hs are supposed to be less intense.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: