Let's Design and Build a (mostly) Digital Theremin!

Posted: 7/11/2012 12:29:03 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"Are you writing your own interpreter or compiler? (I assume this is all being done in Forth or something like that)

Also - the "most intuitively implemented" - Are you looking at this from a perspective of others using it, or do you need to sort this out so that you can use it?" - FredM

Verilog lets you specify the contents of arrays such as block RAMs.  It also allows you to declare parameters and have them represent values, so the opcode name can be the actual value.  I'm hoping to keep it simple enough so that i can program it in verilog this way (I've done this before with previous processor designs, though not extensively).

I need to sort this out so that doing the above isn't overly difficult.

The opcode is 16 bits:  2 bits specify which 1 of 4 stacks is the "primary" P operand for the operation; 2 bits specify the "secondary" S operand; one bit each for the primary and secondary operand stack pop, and the remaining 10 bits specify the operation. 

By default, writes (the result of an operation) cause an automatic push, but reads (the input(s) to that operation) don't cause an automatic pop.  If you want to consume inputs P and/or S during the operation you set their associated pop bits.

For a 2 operand operation, say subtraction, it currently works like this:

P <= P-S

So that P is the only thing ever written to. 

For single operand operations, I have the following choices:

P <= P

P <= S

S <= P

S <= S

The first is conceptually (IMO) most consistent with the two operand operation, ALU input and output decode is the simplest, but it doesn't allow for a move during the operation.  The second is still fairly consistent, and allows for a move, but ALU input decoding is more complex.  The third allows for a move, but is inconsistent in the sense that we are writing to S, and ALU output decode is more complex.  The fourth is nonsense.

If I go with 1 above I lose the optional move, which seems rash.  If I go with 3 I could make the two operand case S <= P-S, but this is inconsistent with reads, writes, jumps, etc. where P is the data being written/read/tested and S is the address.  If I stick with 2 I feel dirty ;-)

This is the problem with DIY processors: a general lack of silver bullets, and a dearth of inherent beauty / symmetry - which one usually uses in order to gauge when to quit tinkering and move on already.  IMO, most designers stop too early (or punt) and you end up hanging bags on the side (caches, coprocessors, etc.) that only compound the complexity.

With his "Everything should be made as simple as possible, but no simpler" adage, it's too bad Einstein wasn't a processor designer.

Posted: 7/11/2012 8:25:16 PM
FredM

From: Eastleigh, Hampshire, U.K. ................................... Fred Mundell. ................................... Electronics Engineer. (Primarily Analogue) .. CV Synths 1974-1980 .. Theremin developer 2007 to present .. soon to be Developing / Trading as WaveCrafter.com . ...................................

Joined: 12/7/2007

"With his "Everything should be made as simple as possible, but no simpler" adage, it's too bad Einstein wasn't a processor designer" - Dewster

Not too sure about that.. Einstein's refrigerator design was elegant, but not particularly simple - and is almost impossible to get working well... Which is a shame - because it never had CFC's, and if it had been adopted CFC may never have been used in aerosols .. etc.. (hell - I really have a problem staying on-topic, dont I ;-)

Anyway, LOL, what I was getting round to was that I dont think Einstein would have been a good processor designer..

ROFLMAO ;-)

Posted: 7/11/2012 9:40:28 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Wow, that the first I'd heard that Einstein did any refrigeration design.  From the article at Wikipedia:

"It has been suggested that most of the actual inventing was performed by [Leo] Szilárd, with Einstein merely acting as a consultant and helping with the patent-related paperwork."

Posted: 7/11/2012 9:41:47 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

If anyone is interested I stuck a small spreadsheet at the digital Theremin share point called "s44_opcodes.xls".  It's just an enumeration of the various opcodes in my processor.

Let's have a naming contest!  I'm obviously calling this processor "S44" during development (the previous design was "S3" for "Simple, Stateless, Stack" processor; the "44" here is for 4 stacks and 4 threads) but something snappier would be nice.  Since it uses registers with stacks underneath it represents something of a "middle way" - so I was thinking of naming it "Zen", but perhaps too many other things have already used that moniker. 

Suggestions anyone?

Posted: 7/11/2012 10:13:38 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"Am I understanding correctly that you have actually implemented a "CPU" (as in, ALU, registers etc) using the CPLD - as in, you have effectively designed your own processor?"  - FredM

Yes, I just put the (very preliminary and not well tested) verilog code up at the share point in an archive named "s44_2012-07-11.rar" if anyone is interested.  It compiles fine in the Quartus and ISE tools.

The digital Theremin share point:

http://www.mediafire.com/?w36b3brqyg2g3

Posted: 7/11/2012 10:39:24 PM
FredM

From: Eastleigh, Hampshire, U.K. ................................... Fred Mundell. ................................... Electronics Engineer. (Primarily Analogue) .. CV Synths 1974-1980 .. Theremin developer 2007 to present .. soon to be Developing / Trading as WaveCrafter.com . ...................................

Joined: 12/7/2007

"Am I understanding correctly that you have actually implemented a "CPU" (as in, ALU, registers etc) using the CPLD - as in, you have effectively designed your own processor?"  - FredM

"Yes", - Dewster

Hmmm - Ok, that is impressive! ..... Feels even more impressive to me perhaps because I have just spent most of the last 2 days trying to get my head arround the Digital Filter Block in the PSoC - this is a mini processor contained in PSoC 3 and 5 parts (not the main processor, but entirely seperate one), a sort of DSP block with its own assembler, ALU, registers etc..

Have been trying to implement a pair of BP filters for vocal formants, but got out of my (and the experts at Cypress) depth because I want to manipulate the coefficients in real time - the "component" container does not cover this type of application, so I need to get inside the DFB and deal with it for what it is - a partially re-configurable processor.

I am not designing a processor - just trying to use one.. And I am well out of my depth, rapidly retreating back to analogue which I know and trust!

LOL.. Not that I dont trust digital - I realise its just that, when I get to this kind of digital, I dont trust myself (with good reason) !

Fred

Posted: 7/11/2012 10:40:05 PM
FredM

From: Eastleigh, Hampshire, U.K. ................................... Fred Mundell. ................................... Electronics Engineer. (Primarily Analogue) .. CV Synths 1974-1980 .. Theremin developer 2007 to present .. soon to be Developing / Trading as WaveCrafter.com . ...................................

Joined: 12/7/2007

Why not call it "Lev" ? ;-)

Posted: 7/11/2012 11:14:41 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

When I was still gainfully employed I was allowed to see one of the coolest multi-threaded processors implemented quite nicely by a "skunk works" group.  Pretty simple really. It mostly boils down to keeping the ALU busy.

[Warning: tough guy talk ahead] Modern processors are so overblown with all their fancy caches, TLBs, super scalar this and that, out of order execution blah blah - implemented in a billion leaky transistors!  It's mostly crap hidden behind a huge obfuscating wall of arcane compiler software.  If it weren't for life support in the form of Moore's Law most of them would be dead and buried (IMO).

 

"Why not call it "Lev" ? ;-)" - FredM

Hmm.  I didn't think about Theremin tie-ins.  Though that's maybe where it will experience it's debutante ball.

So, what would LEV stand for, acronym wise?  (The ARM in the PSoc is/was "Acorn RISC Machine" - a total surprise to me that ARM came from the old Acorn).

Posted: 7/11/2012 11:31:51 PM
FredM

From: Eastleigh, Hampshire, U.K. ................................... Fred Mundell. ................................... Electronics Engineer. (Primarily Analogue) .. CV Synths 1974-1980 .. Theremin developer 2007 to present .. soon to be Developing / Trading as WaveCrafter.com . ...................................

Joined: 12/7/2007

"Hmm.  I didn't think about Theremin tie-ins.."

LOL! - To be honest, neither did I  !  - thats why I made this slightly naughty suggestion.. ;-)

When in Theremin World, its probably good to keep things sweet by mentioning theremin occasionally! ;-)

Fred.

Posted: 7/12/2012 4:10:27 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

L - LIFO

E - Execution

V - Vector (or verilog?)

You must be logged in to post a reply. Please log in or register for a new account.