6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri May 10, 2024 3:16 am

All times are UTC




Post new topic Reply to topic  [ 76 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Re: 6502 Sandbox
PostPosted: Sat Mar 09, 2013 3:08 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
I've added the UART interface (with IRQ handler), and wrote a simple monitor program that I can use to dump memory, fill memory, load programs (binary and Intel hex), and jump to them. The UART interface is configurable between the CPU and the FPGA trace logic. If you now type ^C, the UART is disconnected from the CPU, UART interrupts are disabled, single stepping is enabled, and the UART shows the memory trace instead. Typing ^D switches it back to CPU control, and lets the CPU run full speed again.

Using the intel hex loader, I loaded Klaus' test suite in external SRAM, and ran it. I had to set ROM_vectors to 0, otherwise the hex loader would overwrite the IRQ vector, and that would mess up my UART interrupts, and I had to move the zeropage data a little bit to avoid collision with my own data, but apart from that, I ran it unmodified. Every few seconds I would use the trace logic to see where it was, and after a few times, it was stuck in the 'success' loop.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Sun Mar 10, 2013 12:16 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Cool... I moved my monitor code from F000-FFFF to E000-EFFF, so it wouldn't interfere with other software that might want to load in the Fxxx space. However, because I still want to use IRQ in my monitor, I have added a feature based on the "Vector Pull" signal. During a fetch of any of the vectors, the address is quietly rerouted to my internal monitor code. Works great... and much easier to do this on an FPGA instead of discrete logic.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Mon Mar 11, 2013 3:08 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
I modified the Atom OS ROM to perform read/write character I/O through the UART instead of the keyboard/screen, and loaded it into the sandbox board. The software designers did a pretty good job of keeping the BASIC separated from the operating system. The only violation of the abstraction I found in the basic ROM where it directly polls the ESC key by looking at a PIA register.

Demo program from the manual, running on the board: (note how the code only works for 20th century)
Code:
>LIST
   10 DIM AA(6)
   20 FOR N=0 TO 6; DIM B(10); AA(N)=B; NEXT N
   30 $AA(0)="SUNDAY"; $AA(1)="MONDAY"
   40 $AA(2)="TUESDAY";$AA(3)="WEDNESDAY"
   50 $AA(4)="THURSDAY";$AA(5)="FRIDAY"
   60 $AA(6)="SATURDAY"
   70 INPUT"DAY OF WEEK"''"YEAR "Y,"MONTH "M,"DATE IN MONTH "D
   80 Y=Y-1900
   90 IF Y<0 OR Y>99 PRINT"ONLY 20TH CENTURY !"';GOTO 70
  100 IF M>2 THEN M=M-2; GOTO 120
  110 Y=Y-1; M=M+10
  120 E=(26*M-2)/10+D+Y+Y/4+19/4-2*19
  130 PRINT"IT IS " $AA(ABS(E%7)) ''
  140 END
>RUN
DAY OF WEEK

YEAR ?1999
MONTH ?12
DATE IN MONTH ?31
IT IS FRIDAY


Of course, without video, the number of things you can do is rather limited :)


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Mon Mar 11, 2013 9:16 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Working on SPI flash interface for CPU now. I'm making a very simple CPU interface with a memory mapped data register. Writing to the data register causes a byte to be shifted out over the SPI interface, and another byte to be shifted in at the same time. Later, I'll also add a read-only register that will cause $FF to be shifted out, and another byte to be shifted in, just by reading the register.

I'm using a 24 MHz SPI clock (main clock divided by 4), and because the CPU clock is 8 MHz, it takes less than 3 CPU cycles to shift a byte in or out. So, basically, the CPU can read serial flash data just as fast as it can access SRAM. Of course, you still need to set up the starting address, but as long as you read, say, 256 bytes at a time, that's not going to cost much.
Attachment:
spi.png
spi.png [ 15.4 KiB | Viewed 1019 times ]

Here's a picture from the scope (top=data, bottom= clock), as a result of this code:
Code:
ldx   #$55
ldy   #$aa
stx   $b110
sty   $b110

A write to $b110 causes the SPI byte to be written, and it's no problem to do back to back writes. I could even map the register in zero page.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Tue Mar 12, 2013 2:11 am 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
Arlet wrote:
...I'm using a 24 MHz SPI clock (main clock divided by 4), and because the CPU clock is 8 MHz, it takes less than 3 CPU cycles to shift a byte in or out. So, basically, the CPU can read serial flash data just as fast as it can access SRAM. Of course, you still need to set up the starting address, but as long as you read, say, 256 bytes at a time, that's not going to cost much...

Why did you choose this speed for the FLASH device? I've not looked at the Numonyx datasheet for the IC you're using, but surely it goes up to 80MHz like it's competitors.

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Tue Mar 12, 2013 5:33 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
You are right, I have a copy of an older version of the datasheet that only mentions 25 MHz operation. The newer ones go to 75 MHz. I'll modify the code to use a 48 MHz SPI clock instead.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Tue Mar 12, 2013 7:41 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Here's the same thing, but now running with 48 MHz SPI clock. I've added the PHI2 signal for reference. Of course, when the 65C02 is driving the SPI interface, the higher speed is pointless, but it could become useful when the FPGA is driving the flash directly.
Attachment:
spi_fast.png
spi_fast.png [ 13.84 KiB | Viewed 974 times ]

Flash is responding to read ID command:
Attachment:
rdid.png
rdid.png [ 13.06 KiB | Viewed 968 times ]

Top trace is clock, middle is MOSI, bottom is MISO. Flash responds with $20, $20, $14, as stated in datasheet. I don't have a CPU interface for read data yet, so this is just hand decoded from the scope screen :)


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Tue Mar 12, 2013 8:05 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
Arlet wrote:
...Of course, when the 65C02 is driving the SPI interface, the higher speed is pointless, but it could become useful when the FPGA is driving the flash directly.

Like when a faster core is used, Or...
Would it be difficult to create a state machine for the SPI interface? Maybe then the WDC65C02 could take advantage of this "hardware" instead of performing the function by software?

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Tue Mar 12, 2013 8:42 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
ElEctric_EyE wrote:
Would it be difficult to create a state machine for the SPI interface? Maybe then the WDC65C02 could take advantage of this "hardware" instead of performing the function by software?

The state machine itself would be fairly straightforward. A block read from flash memory is just a matter of writing 8 command bits, followed by 24 address bits, and 8 dummy bits, and then you can read bytes until you're done. But since there's not really a fast I/O peripheral (like video) on board, the current solution is good enough for now.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Wed Mar 20, 2013 7:36 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
ElEctric_EyE wrote:
With that CS4954 video IC, it still needs 2 bytes per pixel I believe. Why not just use a good grade 16-bit RGB videoDAC and make the 8-16bit interface and have a possibility for decent resolution?

The ADV7391 may be an interesting alternative. It provides signals for composite, s-video and component video, just like the CS4954, but offers higher resolutions and non-interlaced (progressive) outputs. At the same time, it still uses an 8 bit digital interface which is attractive to minimize the FPGA pin requirements.

Disadvantage is the tricky package.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Thu Mar 21, 2013 10:28 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
For a quick hack, I've added a simple video output to my existing board. I'm using 3 resistors attached to 3 GPIO pins, and combined the signals into a single output. This signal can be fed into the composite input (or the Y input of the component input), resulting in simple grayscale video. In theory, this could also be used for crude color, but I'll just keep it grayscale.

Of course, it's no substitute for a real video output, but it's good enough to test some designs, including an SRAM video interface. It is also good enough to support some retro graphics/text modes.

Here's a test with grayscale bars.
Attachment:
bars.jpg
bars.jpg [ 52.39 KiB | Viewed 715 times ]


And the signal on the scope:
Attachment:
pal.png
pal.png [ 8.87 KiB | Viewed 713 times ]

As you can see, the steps aren't spaced evenly. I just used a 330 Ohm, 680 Ohm and 1.2k resistor (all 5%), and tried different combinations of '0', '1' and 'Z' outputs to get a few usable levels between 0.3V (black) and 1.0V (white), as well as 0V for sync.


Last edited by Arlet on Thu Mar 21, 2013 3:06 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Thu Mar 21, 2013 12:07 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
Cool!

That other IC looks like it has much more potential. Regarding the package, is that similar to QFN?

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Thu Mar 21, 2013 12:21 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Yes, but it's got a little 'lip' around the side. The leads are accessible from the side, but are also visible on the bottom of the package. I ordered a sample, and took a picture. Behind the chip you can see a ruler with 1/16" markers.
Attachment:
adv7391.jpg
adv7391.jpg [ 36.09 KiB | Viewed 712 times ]

Since the leads extend to the side, it should be possible to hand solder this thing. The only worry would be the possibility of solder bridging two leads on the bottom side of the IC.

Edit: there's also a big ground pad on the bottom of the IC, but I could make a big plated hole under the part so it can be soldered through the PCB. Reflow soldering is also an option, but that would require a stencil. No problem for a small batch of boards, but it makes a single prototype a bit expensive.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Thu Mar 21, 2013 5:24 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8178
Location: Midwestern USA
Arlet wrote:
Demo program from the manual, running on the board: (note how the code only works for 20th century)...

You mean it works for most of the 20th century. Centuries start on odd year numbers, e.g., 1901, 2001, etc. :lol:

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 Sandbox
PostPosted: Fri Mar 22, 2013 7:16 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Here's a full screen picture with different checker board patterns.
Attachment:
blocks.jpg
blocks.jpg [ 130.89 KiB | Viewed 670 times ]

Resolution is 640x256 pixels, which results in about 2:1 aspect ratio for individual pixels. This is equivalent to the old Amiga high res, non interlaced mode. On an old TV, the bottom band with 1x1 pattern is solid gray. On my new LCD monitor/TV, the individual pixels on the bottom can still be discerned, but you can also see some banding patterns over the screen, probably because the LCD TV is all digital and uses a sampling frequency that's not identical to my pixel clock, resulting in moiré patterns.

For a monochrome bitmap, it would take 20kB for this resolution, which is getting close to what an 8 bit CPU can handle.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 76 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 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: