VHDL on 6502?
VHDL on 6502?
in the interest of developing other languages and environments for the 6502, Id like to look at VHDL.
it is 'compiled' to an ASCII text format, is simple, small and can be implemented on the 6502 'capably'.
It is a general purpose language and as such, may be very suitable to write, compile, elaborate, simulate and even use as an exe.
I might try my hand at this in the future. I am interested in whether or not there is much call for it. I would be highly interested in using a 65xx vhdl environment for all sorts of programs.
Any experience or information here?
Things we need:
A text editor1;
A text parser/syntax checker;
an analysis stage evaluator, this runs through everything.
an elaborator, this links and creates a file.
a simulator, that runs that file, and can evaluate all signals, time deltas etc.
a waveform viewer. this just looks at a wave file, and turns it into pixels.
so the elaborator/simulator, may be computationally intensive. drawing fractals is too,
so it will depend on the hardware, the vhdl desired, etc. how complex of a program you create,
however, vhdl is incredibly portable.
it is 'compiled' to an ASCII text format, is simple, small and can be implemented on the 6502 'capably'.
It is a general purpose language and as such, may be very suitable to write, compile, elaborate, simulate and even use as an exe.
I might try my hand at this in the future. I am interested in whether or not there is much call for it. I would be highly interested in using a 65xx vhdl environment for all sorts of programs.
Any experience or information here?
Things we need:
A text editor1;
A text parser/syntax checker;
an analysis stage evaluator, this runs through everything.
an elaborator, this links and creates a file.
a simulator, that runs that file, and can evaluate all signals, time deltas etc.
a waveform viewer. this just looks at a wave file, and turns it into pixels.
so the elaborator/simulator, may be computationally intensive. drawing fractals is too,
so it will depend on the hardware, the vhdl desired, etc. how complex of a program you create,
however, vhdl is incredibly portable.
Last edited by wayfarer on Wed May 14, 2025 2:54 pm, edited 1 time in total.
Re: VHDL on 6502?
VHDL is a Hardware Description Language. I can see using VHDL to create logic hardware. i.e. 6502 itself or some other digital logic. But using VHDL seems like a lot of work to run on the 6502 and would run slow if there was a 6502 VHDL simulator. It would be fun and challenging I suppose.
Greg
Greg
-
White Flame
- Posts: 704
- Joined: 24 Jul 2012
Re: VHDL on 6502?
Specifically, VHDL is a parallel execution spec, and you'll need tons of code, data, and time to execute that on a sequential processor. I don't really see what makes sense with this, can you elaborate?
Re: VHDL on 6502?
well, VHDL, is a very simple language, with a few keywords, operators and types.
and all operations can be mapped to the 6502 fairly easily,
except for multiplication and exponentiation.
the ieee.std_libraries, are fairly simple and self contained.
both the creation of VHDL files, and the output of 'compilation' are ASCII files (iso-8859?)
making a vhdl programming environment, is just a text editor.
making a 'compiler' would take time, though it is largely byte manipulation.
Simulating a vhdl file can be quite intensive, if you have a lot of signals and complex values.
that can take some time, if you want a waveform to review in a waveform viewer.
text.io packages allow for simple text input and output. and a few other features allow OS integration.
you can make an exe in vhdl, that gets and prints text. So for simple discrete logic, programs and math,
VHDL, is 'as fast or good as the compiler and how its used'.
You do not have to use vhdl, to write a video accelerator simulation. you can write OS calls, text programs and
math or logic solving programs, that are basically ASCII, until final compilation to exe, elaboration, simulation
or interpretation, on software.
You can totally write Hollywood Hyjinx of some Dork Lost in Caverns under some Maniac's Mansion in VHDL.
you can calculate the 4th digit of Pi or the Fibonnacci sequence. VHDL, is a general purpose, component/signal
based language, that is human readable, easily parsed. and can do text.io; im not saying its the Best General Purpose language,
being able to model in it, on a 6502, to write programs, its as good as anything else.
and all operations can be mapped to the 6502 fairly easily,
except for multiplication and exponentiation.
the ieee.std_libraries, are fairly simple and self contained.
both the creation of VHDL files, and the output of 'compilation' are ASCII files (iso-8859?)
making a vhdl programming environment, is just a text editor.
making a 'compiler' would take time, though it is largely byte manipulation.
Simulating a vhdl file can be quite intensive, if you have a lot of signals and complex values.
that can take some time, if you want a waveform to review in a waveform viewer.
text.io packages allow for simple text input and output. and a few other features allow OS integration.
you can make an exe in vhdl, that gets and prints text. So for simple discrete logic, programs and math,
VHDL, is 'as fast or good as the compiler and how its used'.
You do not have to use vhdl, to write a video accelerator simulation. you can write OS calls, text programs and
math or logic solving programs, that are basically ASCII, until final compilation to exe, elaboration, simulation
or interpretation, on software.
You can totally write Hollywood Hyjinx of some Dork Lost in Caverns under some Maniac's Mansion in VHDL.
you can calculate the 4th digit of Pi or the Fibonnacci sequence. VHDL, is a general purpose, component/signal
based language, that is human readable, easily parsed. and can do text.io; im not saying its the Best General Purpose language,
being able to model in it, on a 6502, to write programs, its as good as anything else.
Re: VHDL on 6502?
The output of the VHDL compilers I use is generally not a text file. I get binary .bit or .bin files that can be programmed into the FPGA/CPLD that I wrote a Hardware Description for in VHDL (while you can get ASCII versions of those, they are either just 0s and 1s or a hex format for programming into a flash chip). The binary output files are specific to an exact make/model of FPGA or CPLD and will only work with that device. Most of the generated files are larger than 64K, with some ranging into the megabytes.
While VHDL does have some general purpose programming facilities, most of those exist to assist with the business of generating a hardware description or running a simulation. Some of the constructs are only available when doing simulation.
If you want an actual general purpose programming language that is designed for a sequential processor like the 6502, with almost identical syntax to VHDL, then you probably want an Ada compiler. The VHDL syntax was lifted almost directly from Ada. Pascal would also have a similar syntax. You could write a small version of those languages that could output executables for a 6502. Many of the Pascal compilers output bytecode for a Virtual Machine that would then be run with an interpreter program (ask the interwebs about UCSD Pascal and P-code for more information on that).
While VHDL does have some general purpose programming facilities, most of those exist to assist with the business of generating a hardware description or running a simulation. Some of the constructs are only available when doing simulation.
If you want an actual general purpose programming language that is designed for a sequential processor like the 6502, with almost identical syntax to VHDL, then you probably want an Ada compiler. The VHDL syntax was lifted almost directly from Ada. Pascal would also have a similar syntax. You could write a small version of those languages that could output executables for a 6502. Many of the Pascal compilers output bytecode for a Virtual Machine that would then be run with an interpreter program (ask the interwebs about UCSD Pascal and P-code for more information on that).
Re: VHDL on 6502?
plasmo wrote:
WHAT?!
Code: Select all
-- Console Write Line program
use std.textio.all;-- Imports the standard textio package.
-- Defines a design entity, without any ports.
entity consolewrite is
end consolewrite;
architecture behaviour of consolewrite is
begin
process
variable l : line;
begin
write (l, String'("Output String Literal."));
writeline (output, l);
write (l, String'("Input String Please."));
writeline (output, l);
readline (Input, l);
writeline (output, l);
wait;
end process;
end behaviour;its fairly large, though there is way more windows code in there than vhdl, such is the beast of compiling to a modern 64b OS
here is a disassembly (of .o maybe) on dogbolt:
https://dogbolt.org/?id=fc80475a-6653-4 ... 1d0#angr=1
attached is a pic from Reko Disassembler, you can see a lot of WinFluff.
here is the intermediary code created by ghdl prior to compilation:
however, this is the .o file for that code, this is what vhdl 'compiles to',:
_____
d† c I .text ” l $ P`.data h @ 0À.bss € 0À.xdata ( h @ 0@.rdata Ô d @ P@/963 ú
@@@/53
@@@/18
&
@@@/4 = 0
@ B/200 m
@ B/144 Î @ B/128 ì û
@ B/112 @ B.pdata 0 ! Q @ 0@/298 É Y @ BÃf.„ D Ãf.„ D Hƒì(H‹ €8 uè HƒÄ(ÃD Hƒì(H‰L$ H H‰è HƒÄ(ÃfHƒì(H‰L$ è H‹L$ LIH L è H‹D$ HÇ@ H‹D$ Ç@ HƒÄ(Ä VWSHì0 H‰Î‹A‰D$$H= ë H‰ùº A¸ è ÇD$$ ‹D$$ƒøtÜ…ÀtH‰ùº A¸ è ëÞè H‰„$ð H~H‰¼$Ð H‹FH‰„$Ø H H‰„$( H‰„$ H H‰„$ H„$ H‰„$à Æ„$è Ç„$ü Ç„$ì HŒ$Ø è H‹„$Ø H‹Œ$Ð H‰H‹Œ$ð è è H‰„$È H‹ ‹‰„$¸ H‰¼$° H‹FH‰„$À HŒ$¸ è H‹„$À H‹Œ$° H‰H‹Œ$È è è H‰„$¨ H‰¼$ˆ H‹FH‰„$ H H‰„$ H‰„$ H H‰„$ H„$ H‰„$˜ Æ„$ Ç„$ø Ç„$¤ HŒ$ è H‹„$ H‹Œ$ˆ H‰H‹Œ$¨ è è H‰„$€ ‹‰D$pH‰|$hH‹FH‰D$xHL$pè H‹D$xH‹L$hH‰H‹Œ$€ è è H‰D$`H‹ ‹ ‰D$PH‰|$HH‹FH‰D$XHL$Pè H‹D$XH‹L$HH‰H‹L$`è è H‰D$@‹‰D$0H‰|$(H‹FH‰D$8HL$0è H‹D$8H‹L$(H‰H‹L$@è è ÇF HÄ0 [_^Ã' 1 % L ' T " j # z ) * † + Ç , ß - - . 5 / L 0 1 ¯ 2 ´ . à í 3
2 . 5 4 L 5 1 ¯ 2 ´ . Ú 3 ô 2 ù . # 6 : 2 ? . b 3 y 2 ~ 7 B B B
& 0p` consolewrite.vhdl consolewrite l P0 behaviour Output String Literal. Input String Please.( 9 @ : P ; X , ˆ = 8 ° > ¸ , È ? à ' ð @ B C 0 A P * D E F %´B . @:;?2 . @?2 © ” W9 WW Wu @ W’ ` H WÁ ° ä Wð + 9 A O W e k y — ¥ ortho-llvm consolewrite.vhdl C:/Users/Max/Documents/vhdl work__consolewrite__DECL_ELAB work__consolewrite__STMT_ELAB work__consolewrite__PKG_ELAB work__consolewrite__ARCH__behaviour__DECL_ELAB work__consolewrite__ARCH__behaviour__STMT_ELAB work__consolewrite__ARCH__behaviour__P0__PROC * work__consolewrite__DECL_ELAB @ work__consolewrite__STMT_ELAB V work__consolewrite__PKG_ELAB j work__consolewrite__ARCH__behaviour__DECL_ELAB € work__consolewrite__ARCH__behaviour__STMT_ELAB – work__consolewrite__ARCH__behaviour__P0__PROC ; @ ^ ` ¨ ° ” $ ( , Œ ) û
consolewrite.vhdl
òî
N ž
Jt< t
J ‚Ã
È.ržJyȦ^¢EF?º 7 .text ” $ (ßC .data .bss .xdata ( v%ös .rdata Ô ¡Xaà Ã Ê 5 < = wöÕù È
[ ‹
gcFò € r þ× p
y$É
.pdata 0 í}Dð * 7»h´ @feat.00 ÿÿ ” G ² 6 e @ Ö € ` ê ° h À ° ü › Ô ð € ¥ ` Ï ç ý ä À t W 9 ) ` / { p • x Ê @ M P D * ˜ 0 ÿ ö ( Q Ò D ! .file þÿ gortho .debug_abbrev .rdata$.refptr.std__textio__output .rdata$.refptr.std__textio__input __ghdl_process_wait_exit .debug_pubtypes .debug_pubnames .debug_str __ghdl_program_error __ghdl_process_register .debug_info __ghdl_stack2_mark __ghdl_stack2_release std__textio__writeline std__textio__readline .debug_line std__textio__ELAB_BODY work__consolewrite__ARCH__behaviour__RTIARRAY work__consolewrite__RTIARRAY work__consolewrite__ARCH__behaviour__P0__RTIARRAY work__consolewrite__ARCH__behaviour__RTISTR work__consolewrite__ARCH__behaviour__P0__l__RTISTR work__consolewrite__RTISTR work__consolewrite__ARCH__behaviour__P0__RTISTR work__consolewrite__ARCH__behaviour__P0__U1__STL work__consolewrite__ARCH__behaviour__P0__U0__STL work__consolewrite__ARCH__behaviour__RTI work__consolewrite__ARCH__behaviour__P0__l__RTI work__RTI work__consolewrite__RTI std__textio__line__RTI work__consolewrite__ARCH__behaviour__P0__RTI work__consolewrite__ARCH__behaviour__INSTSIZE .rdata$.refptr.std__textio__ELABORATED work__consolewrite__ARCH__behaviour__P0__PROC work__consolewrite__ARCH__behaviour__STMT_ELAB work__consolewrite__STMT_ELAB work__consolewrite__ARCH__behaviour__DECL_ELAB work__consolewrite__DECL_ELAB work__consolewrite__PKG_ELAB std__textio__writeO7 _UI00000002 _UI00000001 _UI00000000
____
It is just ASCII characters, and this file, is fairly portable now. I should be usable on other platforms, though Im not 100% on that, from what Ive read, this file is the actual intermediary output. You can make text games in vhdl. If you can do that, you can do many other things. This uses about 0.5MB of resources on my laptop, +7MB of ram for the DOS window that runs it.
I have a similar ".work" file from Altera taken from edaplayground, so the level of complexity of a file, vs the output, vs how it is used is very dependent on the user
Now if we take that extra windows/64 away, its an ascii file that was compiled into something that displays a text box, gets input, and displays that input. I think porting this to 65xx, is a really cool idea. We can make a 'runner' that takes signals to and from. you can jam up any machine with any language if you try. we can Describe how we want our Hardware to work, in the Very High Speed, Integrated Circuit Language... with a simulation vs synthesis approach, and our 'os' can respond to its form of 'stdio' as we develop it to.
. Ill map the vhdl spec to 6502 operations on a spreadsheet!
(edit, replaced incorrect code file)
it is possible to test now, using this toolchain, Im not set up to implement this just yet however...:
https://github.com/nickg/nvc
uses llvm to compile VHDL to machine executable code.
https://github.com/llvm-mos/llvm-mos
has a 6502 backend for llvm
Im not able to test this for at least a couple of weeks, if someone want to give it a go, thats a very simple text io program there.
Id be interested in seeing how big/garbled it gets going to 6502.
Re: VHDL on 6502?
My "man ascii" say:
The file visibly uses some chars with 8 bits and look as much "being ASCII" as any other exe, com or similar binary file to me ...
Quote:
ASCII is the American Standard Code for Information Interchange. It is a 7-bit code.
Re: VHDL on 6502?
The .o file is an object file - the communication between a compiler and a linker. It is very much not ASCII, and very much not portable - it contains machine code. That particular one is, I believe, in COFF format. GHDL is going to come with a substantial runtime system that needs to be linked with the object file before it can be run. The runtime will be the part that manages simulating a highly parallel hardware description on a sequential CPU.
A wise person I know is fond of saying "just because you can, doesn't mean you should". VHDL is technically a general purpose programming language, and could in principle be used for any computing task that fits within its I/O limitations. You could get it running on a 6502, given enough memory. That doesn't mean it's a good idea. There are reasons why people generally stick to using it for its intended purposes.
If you really want to do it, just for the challenge, no one's going to stop you. But I believe you are vastly underestimating the work required, and vastly overestimating the usefulness of the result.
A wise person I know is fond of saying "just because you can, doesn't mean you should". VHDL is technically a general purpose programming language, and could in principle be used for any computing task that fits within its I/O limitations. You could get it running on a 6502, given enough memory. That doesn't mean it's a good idea. There are reasons why people generally stick to using it for its intended purposes.
If you really want to do it, just for the challenge, no one's going to stop you. But I believe you are vastly underestimating the work required, and vastly overestimating the usefulness of the result.
Re: VHDL on 6502?
The clock is running, but the gates aren't hooked up right...
Re: VHDL on 6502?
SamCoVT wrote:
The output of the VHDL compilers I use is generally not a text file. I get binary .bit or .bin files that can be programmed into the FPGA/CPLD that I wrote a Hardware Description for in VHDL... [SNIP].
Quote:
While VHDL does have some general purpose programming facilities, most of those exist to assist with the business of generating a hardware description or running a simulation. Some of the constructs are only available when doing simulation.
Quote:
If you want an actual general purpose programming language that is designed for a sequential processor like the 6502, with almost identical syntax to VHDL, then you probably want an Ada compiler. The VHDL syntax was lifted almost directly from Ada. Pascal would also have a similar syntax. You could write a small version of those languages that could output executables for a 6502. Many of the Pascal compilers output bytecode for a Virtual Machine that would then be run with an interpreter program (ask the interwebs about UCSD Pascal and P-code for more information on that).
see, Pascal and COBOL went on vacation somewhere tropical. While on vacation in this tropical location, in a market, they adopted a dog. Like a little purse dog you know? And when they got home, Pascal and COBOL gave the little dog a makeover (that went very, very badly) and it turned out the little dog wasn't a dog at all; it was an aardvark. I just love <3 VHDL.
- BigDumbDinosaur
- Posts: 9425
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: VHDL on 6502?
wayfarer wrote:
see, Pascal and COBOL went on vacation somewhere tropical. While on vacation in this tropical location, in a market, they adopted a dog. Like a little purse dog you know? And when they got home, Pascal and COBOL gave the little dog a makeover (that went very, very badly) and it turned out the little dog wasn't a dog at all; it was an aardvark. I just love <3 VHDL.
That makes almost as much sense to me as installing a sunroof in the International Space Station.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: VHDL on 6502?
While I don't think I want to invest any of my time working on such a project, I'd be interested to hear about any progress (successes or failures) you make on this if you decide to pursue it further. You may want to focus on one particular aspect of the project, such as the editor, that would be useful for any kind of self-hosted language. That may give you additional perspective on the amount of work it might take to complete more of the project.
Do you have a particular 6502 hardware you want it to run on?
Do you have a particular 6502 hardware you want it to run on?
Re: VHDL on 6502?
gilhad wrote:
My "man ascii" say: The file visibly uses some chars with 8 bits and look as much "being ASCII" as any other exe, com or similar binary file to me ...
Quote:
ASCII is the American Standard Code for Information Interchange. It is a 7-bit code.
John West wrote:
The .o file is an object file - the communication between a compiler and a linker. It is very much not ASCII, and very much not portable - it contains machine code.
Quote:
That particular one is, I believe, in COFF format. GHDL is going to come with a substantial runtime system that needs to be linked with the object file before it can be run. The runtime will be the part that manages simulating a highly parallel hardware description on a sequential CPU.
Quote:
A wise person I know is fond of saying "just because you can, doesn't mean you should". VHDL is technically a general purpose programming language, and could in principle be used for any computing task that fits within its I/O limitations. You could get it running on a 6502, given enough memory. That doesn't mean it's a good idea. There are reasons why people generally stick to using it for its intended purposes.
Quote:
If you really want to do it, just for the challenge, no one's going to stop you. But I believe you are vastly underestimating the work required, and vastly overestimating the usefulness of the result.
BigDumbDinosaur wrote:
wayfarer wrote:
see, Pascal and COBOL went on vacation .... I just love <3 VHDL.
SamCoVT wrote:
While I don't think I want to invest any of my time working on such a project, I'd be interested to hear about any progress (successes or failures) you make on this if you decide to pursue it further. You may want to focus on one particular aspect of the project, such as the editor, that would be useful for any kind of self-hosted language. That may give you additional perspective on the amount of work it might take to complete more of the project. Do you have a particular 6502 hardware you want it to run on?