It compiles!
Mar 22, 10:19 PM
As of tonight, Computer.Build’s Clojure implementation successfully generated a complete microprocessor design. I had something close for about a week now, but I’d forgotten to hook up the control unit’s opcode signal to anything meaningful, so Quartus was optimizing away all of the instructions. Once that was fixed, everything compiled properly, and the states seem to be sequencing reasonably. I haven’t built any meaningful pieces of code for this processor yet, but I’m close.
This represents a major milestone for Computer.Build. I had originally planned on having both the Clojure and Ruby implementations complete last week (the half-way point for the semester), but other priorities and work on the paper I’m writing around this project got in the way. I’m still very much on track to have things wrapped up by the end of the semester, since all that really remains is re-implementing things in Ruby, testing, writing the paper, and maybe adding some cool features like a data path generator.
Now that the Clojure is making something meaningful, I can turn my attention to the Ruby version. I haven’t actually touched the Ruby since early February, but a lot of the work on the Clojure has been getting its state machine generator up to par with Ruby. The actual Computer.Build code that generates the state machine from microcoded instructions is not too complex, so porting it to Ruby will be fairly simple.
The syntax of the microcode, though, is bugging me. I really like the way the Clojure syntax turned out, but Ruby is getting in my way for its counterpart. I might end up overloading the <= operator in the Symbol class, but that just feels wrong. What I have right now feels awkward and verbose, but maybe that’s just the object-orientedness bugging me again.
The major side-effect of this project has been turning me into a serious Lisper. Once the code-is-data, data-is-code revelation sinks in, you sort of can’t go back. Any code I write now is going to end up looking a little bit Lispy, and attempts at macros in other languages will litter my code. I’m already taking a liking to Python generators for exactly that reason: they remind me of real macros. The data/code duality has been especially strong with Computer.Build because the Clojure implementation uses native data structures that look fairly code-like to define the microcode and state machine. It’s going to be an interesting experience switching back to Ruby and the world of objects now.
