User:Petter.kallstrom/CHDL

A project I have.

A have used VHDL for a while, and starts to be pretty familiar with the language. Because I as well have skills in C++, I get irritated of VHDL, it's so much yada yada in it. Unnecessary many words and lines are offered for the syntax of doing things, causing less (effective) code can be displayed at the same time (but the same amount of words to look at for the eye). Annoying.

Why can't there be a more C++-similar HDL language? All the time when I code VHDL, I see how all the things I do could be better with some C++-syntax.

I don't "speak" Verilog or SystemC very good, but Verilog isn't very like C/C++, strictly speaking, and System-C isn't a HDL, it's a HDL-wannabe-library to C++. I really have to learn SystemC one day.

So, I decided to give C-like HDL (CHDL) a thought. I have never created a language before, so I have no clue how to do this.

This is just a hobby project, but if someone whould like to contribute, please do so.

Some thoughts:
 * What do I want the language to look like? C++ of course. Subculture... VHDL, Verilog, SystemC or something else?
 * Preprocessor? The same as C++, with include, defines and so on.
 * Building blocks and so on? Classes and functions...
 * How to handle processes? Should there be processes? Well, if there should be, just call them process(...) { ... }
 * If there's not processes, how to handle variables vs (synchronous vs asynchronous) signals? keywords, perhaps... "asynch int bus;", "synch int bus", "[variable ]int bus", for instance...
 * Should the language be optimized for hight or low level HDL? Simulation or orientation? Well... C++ is optimized for "high" level programming, but is easy to write as low-level. How to do the same here?
 * How to handle pins? in vs out signals in modules? references used for outgoing signals? std_logic inc(const std_logic in_data[]; std_logic& out_data[]) // return carry-out ...? reserved words in resp. out?
 * How to handle top module? void main(...), or class main{...}?
 * Inherit inheritance from C++ (for instance a DFF with enable-signal, that inherit the usual DFF)?

With some luck, this could be implemented so that a project can be both compiled and simulated and synthesist to hardware using MAKE-macros...

Example of code
Lets find out what to do by writing some examples in the CHDL. Start with a simple xor gate for a fpga, with pin assignments and everything.

The gate is written in two variants of CHDL and one in VHDL. One CHDL is designed "from scratch", and one is a pretty sharp modification of VHDL. In the first CHDL variant I'm using a class as top module, and declare it. Nice and dynamic - choose between class or a function as top module.

Discussion about the "from VHDL" CHDL: Instead of having an architecture, like in VHDL, there is an undeclared function to all classes, that is called void, takes no arguments and returns nothing, that can operate on class members. If user want to have more such functions (s)he is free to declare them (this is a very RTL level of coding), e.g:

All functions returning void and taking no arguments are called active functions, they have the right to change value on the class members.

An std_logic(*) friendly definition of the dff<> used above could be: (* "std_logic friendly" because the clock, reset and enable is explicitly used as std_logic)

The simulation procedure should be similar to VHDL's, I suppose:
 * 1) Find out which classes/global functions are affected by last change (that is all during first iteration)
 * 2) All active functions in each affected class should be run (in parallell). Two different functions may not set common variable (unless there is a resolution function).
 * 3) All used/affected variables are copied into own copies for each function, where they are updated (with it's eventual delay).
 * 4) When all functions is done, copy the output of the functions to an signal-update-table (the VHDL simulator does so), including the signal delays.
 * 5) Find the next events to happen (immediate or after a an delay) from the signal-update-table. The time until then = dt = min(deltas in table)
 * 6) Update simulator time += dt. Decrease all delays in table. Pic out all with resulting delay 0. Start over with those signals (and their affected classes/functions)

To be continued...