6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue May 07, 2024 6:17 pm

All times are UTC




Post new topic Reply to topic  [ 122 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 9  Next
Author Message
 Post subject: Re: Yet another TTL 6502
PostPosted: Sun Jan 06, 2019 12:11 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10799
Location: England
Oh, and thanks too for making schematics which show the signal flow! That's what I call a proper schematic.


Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Sun Jan 06, 2019 7:21 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Here is the ALU nibble completely routed (still needs to be cleaned up a bit). The surrounding white box is 32x24 mm. A full ALU should be twice that, so 32x48 mm, which is about 10% of a Eurocard. The green circles are test points. They just serve as place holders for all external connections (input, output and control signals). Inputs are all on the left, outputs on the right, and controls run vertically. The bottom two signals (partial Carry and Zero flag) should propagate to upper nibble.

I think I'll start working on the PC and AB logic next, to get a better idea of how that's going to look. The PC will also get a ripple carry, but only has 1 gate delay per bit, instead of 2. Of course, it will be twice as long, so total delay should be similar, but slightly less than ALU. The rest of the design won't have any more adders or incrementers. A lot of muxes and registers, and some random logic. I'm trying to fit all the logic in half the Eurocard size, and reserve the other half for the PLA. No idea if that's enough, but we'll see it when we get there.

My plan is to draw schematic and do layout for each subsection, keeping them well separated, and then experiment with different placements on the board. If you keep them apart, it's easy to draw a box around a section, and move it around, without dragging all the connections as well.

Had to rearrange the mux inputs a little bit to make routing easier, so I also updated schematic.


Attachments:
nibble.png
nibble.png [ 75.93 KiB | Viewed 868 times ]
Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Sun Jan 06, 2019 9:21 pm 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
Looks great. Lots to learn here from the approach you’re taking. Looks like traces on three layers?

_________________
C74-6502 Website: https://c74project.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Mon Jan 07, 2019 4:29 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Yes, red is top, blue is bottom, and orange is one of the middle layers (power). There's a 4th layer for ground that I try to keep empty.

There are ground pours on top/bottom, but they've been switched off for clarity. I've added screenshot of the individual layers. On the orange one I've highlighted the VDD signal, so you can see it reaches the vias that it needs for powering the ICs with reasonably fat traces. I'll put a bypass cap near each of the vias.

Also, at the last stage, I add a bunch of ground vias to stitch all the ground pours together. Couple of other things I'm trying to do: keep like signals together and avoid empty parts (still need to improve that here). This improves plating reliability. And try to avoid cutting ground plane in distinct regions.

See for example the top layer bottom right. There are two vias close together, interrupting the flow of the ground plane. I don't like that, so I'll go fix things like that.


Attachments:
power.png
power.png [ 18.1 KiB | Viewed 840 times ]
bottom.png
bottom.png [ 17.04 KiB | Viewed 840 times ]
top.png
top.png [ 32.89 KiB | Viewed 840 times ]
Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Mon Jan 07, 2019 4:45 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Fixed the interrupted ground by moving via a bit


Attachments:
break.png
break.png [ 5.95 KiB | Viewed 839 times ]
fix.png
fix.png [ 6.31 KiB | Viewed 840 times ]
Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Mon Jan 07, 2019 6:55 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
I thought I had a clever resource-saving trick by registering PC on negative clock edge (everything else switches on positive edge), but then I realized that this trick only leaves the PC with half a clock cycle to do the 16-stage ripple carry. I just reworked the code to switch clock on positive edge instead. Thankfully the impact on logic size is minimal. I still need to calculate AB+1, but add an extra path to load AB+1 directly into AB instead of only in PC.


Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Mon Jan 07, 2019 8:22 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10799
Location: England
I'm sure you'll recall that the 6502 uses some lookahead to increment PC - as it's only an incrementer, that's just a wide NOR on the inverted outputs.

I'm supposing you don't have a way to run a static timing analysis?


Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Mon Jan 07, 2019 9:13 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
With current design I have AB register -> incrementer -> mux -> AB/PC register. Using the 74ALVC08 for example, I have max propagation delay of 2.9 ns per gate, which is about max 50 ns for 16 stages. Add a bit for the mux, xor and setup, and it should still be well under 100 ns, which is good enough for me. More importantly, the PC delay is less than ALU delay, which I can't really optimize without special hardware that fall outside the rules.

And of course, a 16 gate chain of AND gates is delightfully simple, both for schematic/layout and understanding.

And realistically, it's only 15 stages, because who lets their code wrap from FFFF to 0000 ? :roll:


Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Mon Jan 07, 2019 10:48 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10799
Location: England
Yes, it might well be fine, and is certainly simpler, not to carry lookahead.

As I recall, the best guess we have for the critical path in the 6502 is in the control of PC increment: there's work to be done before deciding to increment, and it all has to happen in one cycle.

Possibly this is a non-event with your first revision, where you plan to use an FPGA for the control?


Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Mon Jan 07, 2019 11:38 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
In my case, decision to increment only depends on current {state, IR} combo, both of which are fully registered. In fact, that is true for nearly all control signals in the design. Delay should be equal to one pass through PLA. For instance, I see that the 6502 uses information about branches in the PC increment decision. I have a special state for taking branches. When not taking a branch, state machine goes from DECODE->FETCH->DECODE. When taking a branch it goes from DECODE->BRA0->[BRA1/BRA2]->FETCH. The AB/PC logic only needs to look at the state. In the FETCH state, it takes the AB+1 value, and in the BRA0 state it takes the address from the ALU. Both are calculated in parallel.

Challenge remains to make the PLA both compact and fast. I have some vague ideas, but no concrete plans yet. I'll probably have to do some experimenting first.


Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Mon Jan 07, 2019 2:00 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10799
Location: England
(BTW, my original jokey estimate of board size didn't take into account the use of FPGA, so it was an estimate for a fully TTL implementation. Maybe one day we'll know whether I was close or not!)


Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Mon Jan 07, 2019 2:09 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Here's my new incrementer decision. Mostly depends on state alone, with one exception for 1 byte push/pulls. In those cases, we've already fetched next opcode, but still need to finish current instruction, so opcode can't be loaded in IR yet. My solution is to finish operation, and simply go back to FETCH state and get next opcode again.
Code:
/*
 * address incrementer
 *
 * if 'inc_ab' is set, calculate AB + 1
 */
always @* begin
    inc_ab = 0;
    case( state )
        DECODE:
            casez( IR )
                8'b0??0_1000:           inc_ab = 0;                 // PHA/PLA/PHP/PLP
                default:                inc_ab = 1;
            endcase
        BCD0:                           inc_ab = 1;
        RTS0:                           inc_ab = 1;
        IND0:                           inc_ab = 1;
        FETCH:                          inc_ab = 1;
        ABS0:                           inc_ab = 1;
    endcase
end


Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Mon Jan 07, 2019 2:47 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
ABI is output of incrementer (ripply carry chain, fed by inc_ab).
Code:
wire [15:0] ABI = AB + inc_ab;

And then there's another enable signal that determines whether PC should be updated with ABI or not.
Code:
always @(posedge clk)
    case( state )
        DECODE:                         PC <= ABI;
        BCD0:                           PC <= ABI;
        RTS0:                           PC <= ABI;
        IND0:                           PC <= ABI;
        FETCH: if( !bcd )               PC <= ABI;
        ABS0: if( IR[3] )               PC <= ABI;                  // only for true ABS (not ABS0 as part of ZP,Y)
    endcase


ABI can also go directly into AB register. That code is a bit more elaborate, but at the heart it's just a mux.

The implementation of the mux will most likely be done by an internal bus running across the board, with a bunch of 3-state drivers. I thought about using a real mux, but I think the wiring will get too messy.


Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Mon Jan 07, 2019 5:45 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
Hello, I've been following along and find myself intrigued, especially when the Verilog code is posted. Would it be alot of work to post an RTL schematic of the code? If it's too much trouble, maybe just once in awhile. Or am I just being lazy? :oops:

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Yet another TTL 6502
PostPosted: Mon Jan 07, 2019 6:35 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
I'll try to post more schematics soon. The code should crystallize pretty soon, and then I'll start converting more parts to schematic. For now, it's so much quicker to express thoughts in verilog than in schematic. You could try loading the code in ISE and see what it makes of it, but I'm afraid it's going to be an unreadable maze of wires.

Here's a very quick block diagram of the datapath so far.

A, X, Y, S, M, ABH, ABL, PCH, PCL (and IR, not indicated) are all 8 bit registers.


Attachments:
block.png
block.png [ 7.3 KiB | Viewed 730 times ]
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 122 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 9  Next

All times are UTC


Who is online

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