6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun May 12, 2024 4:11 pm

All times are UTC




Post new topic Reply to topic  [ 64 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
PostPosted: Mon Sep 25, 2017 12:06 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8180
Location: Midwestern USA
kakemoms wrote:
Well, you are a purist, which is fine. Ultimately 6502 code does or doesn't run on other versions of the 6502, its all about compability level. Try running commodore 64 code on a 2MHz 6502, and it will probably fail due to some
timing-critical routine.

Whether software written to run on the Commodore 64 will work on a 2MHz 6502 (Which 2 MHz 6502 system?) or not would have nothing to do with the code itself and everything to do with the host machine. The C-64 is a special case 6502 (specifically, 6510) system, due to its dual processor design, the second processor being the VIC. Since the 6510 and VIC have to share the same buses and address space, unavoidable timing constraints get into the picture, which would affect the C-64, not the 2 MHz unnamed 6502 system.

As Windfall is intimating, your design is not a 6502 unless it can execute the 6502 instruction set in its entirety, as well as correctly condition the flags in the status register according to the result of the most recent instruction. That isn't being a purist; it's merely stating an immutable fact.

Quote:
So this is a 6502-like cpu with fewer instructions and some special considerations, but its code will compile on any 6502 assembler.

One doesn't "compile" code with an assembler. :D

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 25, 2017 5:04 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1929
Location: Sacramento, CA, USA
BigDumbDinosaur wrote:
As Windfall is intimating, your design is not a 6502 unless it can execute the 6502 instruction set in its entirety, as well as correctly condition the flags in the status register according to the result of the most recent instruction. That isn't being a purist; it's merely stating an immutable fact.

Another immutable fact is that kakemoms didn't call it a 6502, he called it a cut-down 6502. If I cut a tree down and haul away everything that falls, I am left with a tree stump, not a box of kittens. Whether or not the tree stump is as useful as the complete tree is subjective ... maybe I really wanted a solid picnic table base with no shade!

Quote:
One doesn't "compile" code with an assembler. :D

:roll:

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 25, 2017 5:16 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
This certainly is an eye-rolling discussion, and not in an ideal thread for the purpose.

Can we perhaps leave kakemoms alone, until such time as the design surfaces in public? Or start a new thread to discuss this cut-down 6502, or any other cut-down 6502, or 6502 variations in general.


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 25, 2017 3:27 pm 
Offline
User avatar

Joined: Sun Nov 27, 2011 12:03 pm
Posts: 229
Location: Amsterdam, Netherlands
BigEd wrote:
This certainly is an eye-rolling discussion, and not in an ideal thread for the purpose.

Can we perhaps leave kakemoms alone, until such time as the design surfaces in public? Or start a new thread to discuss this cut-down 6502, or any other cut-down 6502, or 6502 variations in general.

As far as I'm aware, we were only discussing what deserves the name '6502'. But maybe that's me.


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 25, 2017 5:03 pm 
Offline

Joined: Wed Mar 02, 2016 12:00 pm
Posts: 343
Windfall wrote:
BigEd wrote:
This certainly is an eye-rolling discussion, and not in an ideal thread for the purpose.

Can we perhaps leave kakemoms alone, until such time as the design surfaces in public? Or start a new thread to discuss this cut-down 6502, or any other cut-down 6502, or 6502 variations in general.

As far as I'm aware, we were only discussing what deserves the name '6502'. But maybe that's me.


As for the 2MHz 6502, I was thinking of my B600. But as it contains a 6509 that would strictly not be a 6502 under you definition either.

We can put it in another tread, but the whole discussion boils down to personal preferences. Generally it would be more interesting to see an overview of all the versions of the 6502-like hardcores and softcores, cut-down, different, overblown or just plain. So I will start a new tread for that.


Last edited by kakemoms on Mon Sep 25, 2017 9:04 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 25, 2017 6:36 pm 
Offline
User avatar

Joined: Sun Nov 27, 2011 12:03 pm
Posts: 229
Location: Amsterdam, Netherlands
kakemoms wrote:
We can put it in another tread, but the whole discussion boils down to personal preferences.

In this case, I don't think so. A core is either a 6502, or 6502-like. Because the first has a well documented instruction set. The second requires it to be described.

Also, the discussion is not that interesting to start with ...

kakemoms wrote:
Generally it would be more interesting to see an overview of all the versions of the 6502-like hardcores and softcores, cut-down, different, overblown or just plain. So I will start a new tread for that.

Now that would be interesting.


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 12, 2017 3:34 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
Elsewhere, kakemoms notes that the official supported WDC core runs a lot faster on a particular Lattice FPGA than this extended Arlet core:
kakemoms wrote:
(WDC 6502 runs at 75MHz on [the MachXO3], Arlets extended 65C02 (by BigEd&Dave) runs at about 28MHz).

I thought that was worth recording! (Arlet's core uses a register file for AXYS, which on Xilinx FPGAs results in a very small and efficient implementation. I don't know if X03 parts have the same trick. It's possible WDC have done some work to make an implementation which is a good fit to this FPGA's internal organisation.)


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 12, 2017 8:30 pm 
Offline

Joined: Wed Mar 02, 2016 12:00 pm
Posts: 343
BigEd wrote:
I thought that was worth recording! (Arlet's core uses a register file for AXYS, which on Xilinx FPGAs results in a very small and efficient implementation. I don't know if X03 parts have the same trick. It's possible WDC have done some work to make an implementation which is a good fit to this FPGA's internal organisation.)


Well, WDC is a official supplier of IP cores for Lattice, so they probably have some tools that is not part of the freely available Diamond package for MachXO3. There is some information here if you want to explore the W65C832PXB (which I probably have to at some point).


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 26, 2018 12:25 pm 
Offline

Joined: Wed Mar 02, 2016 12:00 pm
Posts: 343
I have been trying to get my head around this core in order to get it faster. Its fairly easy reading (thank you Arlet!), and at first sight I couldn't see wether there was anything to improve.

I do have a couple of questions though:

Why do you use so many case statements?

Why do you use blocking assignments as part of some case statements?

From my experience with XO3, blocking assignments is usually a bad idea for speed. Maybe other tools/pld´s get around it in a better way than XO3.


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 26, 2018 5:39 pm 
Offline
User avatar

Joined: Mon Apr 23, 2012 12:28 am
Posts: 760
Location: Huntsville, AL
I can't comment on the XO3 experience regarding blocking and non-blocking assignments. Within the ISE Verilog compiler/synthesizer, blocking and non-blocking assignments produce different behavioral results in simulation, but are equivalent in synthesis. In the synthesizer, non-blocking assignments are required when assignments are made to "reg" variables, regardless of whether the "reg" variables are synchronous or asynchronous elements. Since synthesizable case <> end case statements require assignment to a "reg" variable, the assignment must be made using a non-blocking assignment: "<=".

Although it is possible to write simple case <> end case blocks using blocking assignments, in my opinion, it requires more effort on the part of the designer that the synthesizer is better able to do automatically.

In general, I use blocking statements only for logic that is simply and will always be implemented as asynchronous logic. I use case <> end case with non-blocking assignments in synthesizable code that may be implemented as either synchronous logic or asynchronous logic. I like to use case <> end case to let the tool solve the equations for me.

_________________
Michael A.


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 27, 2018 5:12 pm 
Offline

Joined: Wed Mar 02, 2016 12:00 pm
Posts: 343
The problem may be related to the Lattice Diamond. It tend to underestimate the speed one can get from a core. Your core is somewhat ok (around 14MHz) while the tc_65c02 core by Jens Gutschmidt is reported to only run at 2MHz...

Since Lattice also includes the Synplify Pro as an alternate compiler, I have been able to also check how that implements the source. Your core is reported to run around 18-20MHz, while Gutschmidt's core fail to compile there.

In real life I had your core run up to around 25-28MHz, but that was the limit. Anything above and it would be unstable.

This is probably what I would call flavor differences. Still, it remains to be seen whether I can get your core faster IRL without thinking too hard about the reported values.


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 28, 2018 1:01 am 
Offline
User avatar

Joined: Mon Apr 23, 2012 12:28 am
Posts: 760
Location: Huntsville, AL
Thanks for the feedback. I was unaware that my core had been loaded into an FPGA from a vendor other than Xilinx or Altera. When targeted to a Spartan-3A XC3S200-5 FPGA, the predicted maximum operating speed is 28.796 MHz, and after PAR the reported operating speed is 29.622 MHz using a constraint of 29.49152 MHz. The difference between the predicted operating frequency and the constraint is approximately 2.5%. I have found that this relative difference between synthesis and MAP/PAR is a reasonable amount with which to push the MAP/PAR functions.

In the past, when timing various cores outside of a SoC configuration like the M65C02A, I found that the predicted and reported speeds were frequently quite different which corresponds to your reported experience. To make the comparisons more reasonable and consistent, I wrapped the various cores I was comparing to in a frame work which placed registers on the outputs and the inputs. I think that this approach provides a more consistent view of how the core will perform in a SoC configuration. IOW, it allows the synthesizer and MAP/PAR to correctly measure/estimate the path delays that determine the maximum operating frequency. The operating frequency reported by ISE at the completion of MAP/PAR is a value corresponding to the guaranteed performance of the FPGA vendor. To do so, they calculate these values using worst case values at the minimum operating voltages and maximum operating temperatures.

It is not all that surprising that you can push the FPGA operating frequency when operating at nominal voltages and temperatures. I do think that the wide variation you are reporting is probably associated with RTL/implementation differences between the cores than with the FPGA's performance variations due to changes in operating parameters such as temperature and voltage. The real world value your tool is reporting for my core also appears to be quite reasonable. In a -4 version of the XC3S200A FPGA, the core is reported to operate at 25 MHz. A 20% improvement or loss in performance is not unreasonable for the -4 and -5 speed grades.

_________________
Michael A.


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 30, 2018 8:43 am 
Offline

Joined: Wed Mar 02, 2016 12:00 pm
Posts: 343
BigEd wrote:
Elsewhere, kakemoms notes that the official supported WDC core runs a lot faster on a particular Lattice FPGA than this extended Arlet core:
kakemoms wrote:
(WDC 6502 runs at 75MHz on [the MachXO3], Arlets extended 65C02 (by BigEd&Dave) runs at about 28MHz).

I thought that was worth recording! (Arlet's core uses a register file for AXYS, which on Xilinx FPGAs results in a very small and efficient implementation. I don't know if X03 parts have the same trick. It's possible WDC have done some work to make an implementation which is a good fit to this FPGA's internal organisation.)


Lattice´s site now has published values of the WDC65c02 core (on EP and EP2) of 42MHz. This is probably the frequency at which you can run the WDC core stable (at any temperature, weather and moon phase).

Anyone has a link to software that stresses the 65c02 core in different ways?


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 30, 2018 9:02 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
Good question - I've asked it on a new thread over here.


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 29, 2020 8:48 pm 
Offline

Joined: Wed Mar 02, 2016 12:00 pm
Posts: 343
Hi

I am trying to use this core for a project I have, but I have a problem with it. I don't think its in my testbench, but I can't be 100% sure. I am testing it under Lattice Diamond and Active-HDL simulation.

The thing is that the core starts as it should. Goes on to read reset vector and jumps to that position in memory. All is fine except that the stack pointer is undefined. It shows as 8'hxx.

So I tried to set the stack to $fd which is what the 6502.org visual simulator shows the stack to be once it resets and starts running (well, it doesn't really show the whole reset since it starts at memory location $0000 and not at $fffc, so maybe the stack pointer is different).

The thing is that the stack pointer should not be undefined, but trying to set it to some value ends with the core crashing. I don't know what happens, but something seems to become confused.. Well, at least me.

Anyway, is the stack pointer left non-initialized for a reason?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 64 posts ]  Go to page Previous  1, 2, 3, 4, 5  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: