6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri May 03, 2024 10:06 pm

All times are UTC




Post new topic Reply to topic  [ 52 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
PostPosted: Wed Jul 29, 2015 7:24 pm 
Offline
User avatar

Joined: Sun Oct 13, 2013 2:58 pm
Posts: 485
Location: Switzerland
For WinCUPL it does not matter. He optimizes things as much as he can. That's the nice thing about the TABLE statement. And if required he would even invert the equations and change the polarity of the output in order to minimize the number of PTs used. I was really surprised when migrating some old GALASM designs to WinCUPL at how clever it reduces PTs.

What can help, and in this case it did, is to move around instructions. You can try by re-arranging the following instructions
Code:
   LDY      #0                  ; Init Index Register
   STY      PTR                  ; Set low byte of pionter
   LDA      #>BOOTLOADER         ; Get High byte of ROM
   STA      PTR+1               ; Set high byte of pointer


if you switch the STY and LDA the design no longer fits.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 29, 2015 8:18 pm 
Offline

Joined: Mon Jul 20, 2015 6:34 pm
Posts: 62
cbscpe wrote:
Hi i_r_on,
It's really a tight fit. But now I start to ask myself what happens after the image has been loaded and executed and an interrupt occurs. If I understand your design correct $E000..$FFFF always is the ROM which is the GAL. Or do you have some other mechanism? I would have added another GAL as an address decoder and a 128kbyte RAM instead of a 32kbyte RAM. I would also add a BOOT output to the arduino that changes the decoder. If the bit is set, reads always enable the GAL and writes enable always the RAM. If the bit is cleared the GAL is disabled and except for the IO range the RAM is enabled, optionally write-protect the upper part. Once you clear the bit another reset would then use the reset vector in the program image loaded into the RAM.

Peter


Actually this is just a test board but it doesn't matter for the bootloader rom to take space as much as 256 bytes or 4K or even 32k in my case. I don't have any rom routines. What I need is a means to transfer data to ram and execute there. c64 sid files doesn't rely much on existing rom code. So I'll have a bus control signal to my address decoder so that I could switch rom off leave the ram behind it accessible. Also original c64 didn't have more than 64k general purpose ram so I don't need anything beyond that. I would get along with less for sure (except for digi tunes) but then the software would get unnecessarily complex.

And the speed is also important for me since I don't have any other peripheral in my 6502 system and everytime I play a sid I use this hack to transfer the sid music to the ram and execute there. They are on average 4K-6K sizes. With a speed optimized version of this transfer routine I can send average size tunes in 1-2 seconds.

Why this bootloading from gal or 32 bytes rom mechanism is a very useful future for me? It's because now I can test second stage stuff without burning them anywhere. I just build 6502 assembly code and copy paste it into my arduino sketch.

I could revisit using a GAL as an address decoder but I was not able to decode a proper signal for swinsid properly previously. Maybe bad luck or insufficient knowledge I don't know. In my current test setup I only have 74LS138 and a 74HC00 (32K RAM, 8K INT0, 8K INT1, 8K IO, 8K ROM) I'll rework it once I layout a single board design. Now the priority is to increasing compatibility with sid tunes and incorporating a VIA or emulating timer/interrupt functionality of it in arduino.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 29, 2015 10:59 pm 
Offline

Joined: Mon Jul 20, 2015 6:34 pm
Posts: 62
It's terrible to find a mistake in software by testing through hardware :(

By looking carefully at below code, could you spot the mistake?
Code:
[1a] => 'b'xxx10111;
[1b] => 'b'11xxxxxx;
[1c] => 'h'xxx01000;
[1d] => 'b'11xxxxxx;
[1e] => 'h'xxx11001;
[1f] => 'b'11xxxxxx;


ps1: I definitely needed a counter to test this instead of giving address lines values one by one by the way...
ps2: Found a hardware bug and fixed that too.. still no joy...


Attachments:
20150730_015341.jpg
20150730_015341.jpg [ 112.15 KiB | Viewed 1166 times ]


Last edited by i_r_on on Thu Jul 30, 2015 9:09 am, edited 1 time in total.
Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 30, 2015 3:21 am 
Offline
User avatar

Joined: Wed Feb 13, 2013 1:38 pm
Posts: 586
Location: Michigan, USA
i_r_on,

Not meaning to detract from your (very interesting) GAL-ROM discussion, have you looked at Nicholas FitzRoy-Dale's Hardware SID Player? He used a PIC microcontroller as a "blind loader" and he even used it to generate the 50/60 Hz timer interrupt for the player software. I can't see why you couldn't do something similar with an Arduino/AVR microcontroller. If you haven't already, please check it out. It's a nice write-up.

May I ask if there is something special about SWINSID timing that was giving you a problem when trying to implement a GAL Address Decoder earlier?

Regards, Mike


Attachments:
hardware SID player.png
hardware SID player.png [ 146.08 KiB | Viewed 1155 times ]
Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 30, 2015 9:08 am 
Offline

Joined: Mon Jul 20, 2015 6:34 pm
Posts: 62
@Michael,

Yes I'm aware of that project. I even exchanged some mails with him throughout the early phase of my project.
It's just a choice actually I didn't want to drive 6502 keeping it in time with the controlling micro with precise timing.

So my controlling micro's sources are much much simpler and not timing sensitive.

GAL decoder for SID / Swinsid fail maybe a mishap I don't know. Swinsid all together was not working initially because I later realized that SID uses PHI2 clock but we don't input PHI2 clock to Swinsid. So an address decoder for Swinsid should take care of PHI2. (That's for standard logic)

Quote:
But the test design (which I'm trying to use Swinsid SE) gets berzerk after playing a few seconds. (Which I use GAL16v8d for address decoding logic) CS is kept low for 500ns. I guess the problem is GAL being too fast and decodes the sid cs line too quickly with regards to 1mhz clock I'm using. There is almost no propagation delay after rising 1mhz clock edge.

edit: Well added 100ns propagation delay, still no good. My problem might be something else


I don't remember precise timing details, I could re-test this issue changing address decoding to GAL again.

Btw, What should we connect to GAL's clock line? PHI2 clock?


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 30, 2015 6:48 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8172
Location: Midwestern USA
i_r_on wrote:
Btw, What should we connect to GAL's clock line? PHI2 clock?

That's usually the case, assuming you want clocked events in the GAL to be synchronize with events occurring in other parts of the circuit.

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


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 04, 2015 11:09 pm 
Offline

Joined: Mon Jul 20, 2015 6:34 pm
Posts: 62
@Michael :
Btw, just to note.. Today I tested GAL usage in my address decoding. It worked this time. Previously I always processed PHI2 outside GAL with individual logic. I incorporated it into a simple 32k memory memory map and it worked. I don't know if it will work for an actual sid since that chip already has phi2 input. BC is bus control, I use that to remove rom when not needed. BC = 1 : Rom in place, BC = 0: Ram takes rom's place. Having R/W input and laying RAM under ROM didn't fit GAL20V8B.

Not so elegant but here is the PLD file,

Code:
Name     address decoder for sid player;
PartNo   00 ;
Date     05.08.2015 ;
Revision 01 ;
Designer i_r_on ;
Company  none;
Assembly None ;
Location  ;
Device   G20V8AS;

/* *************** INPUT PINS *********************/
PIN   2  =  S5                      ;
PIN   3  =  S4                     ;
PIN   4  =  S3                     ;
PIN   5  =  S2                     ;
PIN   6  =  S1                     ;
PIN   7  =  S0                     ;
PIN  13  = !OE                     ;

/* *************** OUTPUT PINS *********************/
PIN   15  =  CS0                     ;
PIN   16  =  CS1                     ;
PIN   17  =  CS2                     ;

FIELD SIGNALS = [S5..0];  /* [BC, PHI2, A15, A14, A13, A12]; */

FIELD SEL = [CS2..0]; /*SIDCS, RAMCS, ROMCS*/

TABLE SIGNALS => SEL {
/* BC = 0, PHI2 = 0 */
['b'000000] => 'b'111;
['b'000001] => 'b'111;
['b'000010] => 'b'111;
['b'000011] => 'b'111;
['b'000100] => 'b'111;
['b'000101] => 'b'111;
['b'000110] => 'b'111;
['b'000111] => 'b'111;
['b'001000] => 'b'111;
['b'001001] => 'b'111;
['b'001010] => 'b'111;
['b'001011] => 'b'111;
['b'001100] => 'b'111;
['b'001101] => 'b'111;
['b'001110] => 'b'111;
['b'001111] => 'b'111;

/* BC = 0, PHI2 = 1 */
['b'010000] => 'b'101;
['b'010001] => 'b'101;
['b'010010] => 'b'101;
['b'010011] => 'b'101;
['b'010100] => 'b'101;
['b'010101] => 'b'101;
['b'010110] => 'b'101;
['b'010111] => 'b'101;
['b'011000] => 'b'111;
['b'011001] => 'b'111;
['b'011010] => 'b'111;
['b'011011] => 'b'111;
['b'011100] => 'b'111;
['b'011101] => 'b'011;
['b'011110] => 'b'111;
['b'011111] => 'b'111;


/* BC = 1,  PHI2 = 0 */
['b'100000] => 'b'111;
['b'100001] => 'b'111;
['b'100010] => 'b'111;
['b'100011] => 'b'111;
['b'100100] => 'b'111;
['b'100101] => 'b'111;
['b'100110] => 'b'111;
['b'100111] => 'b'111;
['b'101000] => 'b'111;
['b'101001] => 'b'111;
['b'101010] => 'b'111;
['b'101011] => 'b'111;
['b'101100] => 'b'111;
['b'101101] => 'b'111;
['b'101110] => 'b'111;
['b'101111] => 'b'110;

/* BC = 1, PHI2 = 1 */
['b'110000] => 'b'101;
['b'110001] => 'b'101;
['b'110010] => 'b'101;
['b'110011] => 'b'101;
['b'110100] => 'b'101;
['b'110101] => 'b'101;
['b'110110] => 'b'101;
['b'110111] => 'b'101;
['b'111000] => 'b'111;
['b'111001] => 'b'111;
['b'111010] => 'b'111;
['b'111011] => 'b'111;
['b'111100] => 'b'111;
['b'111101] => 'b'011;
['b'111110] => 'b'111;
['b'111111] => 'b'110;
}


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

All times are UTC


Who is online

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