October 31, 2014

Transistor - 1: A 16-bit madness designed right out of discrete transistors

Hi there again,

I've decided to go a little crazy and design a whole 16-bit processor out of individual discrete transistors.  Why?  Well, why not?
A nice full adder with just 9 transistors.
Let me know if you can do better.
I actually had this idea for quite some time now and I'm kinda taking a CPU arch design as a kind of a hobby...  I just find it fun for some reason. But now I actually sorta got to it and I have designed a couple of basic building blocks.  Not just logic gates.  Designing stuff just out of logic gates is pretty lame, trust me.  I have actually done a few transistor-level optimizations already, and well, I kinda find making a 3-transistor XOR kinda impressive. :P

Anyway, there's a couple of various schematics of those blocks on the side. Sorry if they're ugly or unclear, but yeah, it seems to work, so I'm happy.

A full, 1-bit ALU slice. In case you wonder,
bit-shifting is done in a separate bit shift unit.
I've also missed those ZX and ZY bits,
but that should be rather easy to implement
- just don't read an input from a register. Easy.
I've managed to squeeze a full 1bit ALU slice down to 20 transistors, but I bet I could still do better than that, hopefully.

I figured the thing taking the largest amount of transistors would probably be the register file.

I'm having about 8 general purpose registers there as well as a couple of 'special' ones, and each of them being at least 4 transistors worth per bit, and well... that doesn't really make a smiley face, does it?  I'm thinking about using 'dynamic' registers in the actual physical version of this thing instead, but refreshing the actual registers all the time... not really sure. But I guess that might not be a problem since I might use some nice MOS transistors to read that out and some massive electrolytics caps to hold the charge...  I'll see, it's all still in quite an early phaseof design as you can see.

I'm designing the logic using a combination of RTL and DTL by the looks of things, but I don't know really.  I'm just really whacking it up the way I try to get to the lowest possible transistor count.  I've set myself a limit of roughly 1000 transistors pretty much for no reason whatsoever.  I'm quite doubtful about that, but I'll see.  I'll probably actually end up making the ALU just 8 bit and pass stuff through twice - that actually saves a whole bunch of transistors, but it makes it quite a bit slower.  But I don't mind that really, I guess.

I think I should describe the whole architecture a bit more. I'd be making a softcore version of it in VHDL soon, so in case you'd like it, just ask me for that somewhere or write your own if you're so inclined.

So there you go.  I will hopefully finish the design sometime and possibly even make it someday...
In case I'll be REALLY building this, I'd go oldschool wire-wrapping style, I guess.  Let's face it - soldering wires to all those 3500+ joints?  No thanks.  That would just take ages.  So I'll just quickly solder the leads of all of those things to a board and then wrap it, test it, blow it up, fix it, blow it up again, fix it again, give up, get back to it, fix it again like a pro, make sure it works, pot it up and be done with it.  I guess.  I bet it's not gonna be so easy, so expect a couple of more entries about this thing since I'm actually fairly excited about it.

October 3, 2014

ST Nucleo Development Board Review

So I got my wage once again and wondered what to spend it on, so I thought I might get one of those ST Nucleo devboards, because they're pretty cheap, I might wanna learn how to program those nice ARM micros, and they come with a fairly decent support and hardware resources as well, so I got one. Yay.

I've ran for the L152RE one for a number of reasons:

  • Amount of flash memory. It's got whopping 512KiB of it. Freaking half a meg. Suck that, Arduino!
  • Amount of SRAM. I almost went jawdrop mode when I saw it's got 80KiB of it. Why'd I ever need so much memory anyway? More about that later.
  • It's also got a pretty much standalone ST-Link V2 on it, which could be used to program other micros and hack random other stuff, and seems to be supported by the OpenOCD too! Yay!
    This thing alone's worth a nice buck.
  • Triple SPI and double I2C, not bad.
  • No less than 5 USARTs. Neat.
  • It also supports USB somehow, too.
  • It has arduinous headers on it too, in case one might wanna use any of those ubiquitous shields
  • They claim it's also got 11 timers and up to 34 capacitive sensing channels and it can drive up to 8x40 segment LCD. Yeah, not bad. also a 1MSPS ADC - cool.
  • It's also got two 12bit DACs. Yup. THIS was the main reason why I bought it.
There it is.

When I got it (I even was late for school just to pick it up at a local post office, because I thought I could play with it at school, but alas, I didn't have the goddamn miniUSB cable it needs that day, damnit), I was actually fairly surprised when I discovered it acts like a flash drive after plugging it in! It comes with a little html file on it which pretty much only redirects you to the mbed.org site and gives you their online compiler. That thing also comes with a whole range of examples, I haven't even tried a half of them, even though I might do so later, and I went straight to playing around with that dual-channel DAC on the thing, because you know, I just love drawing stuff on the 'scope in XY mode. I dunno why, but that's one of the few things that kinda satisfy me.

And that turned out to be pretty nice.


Anyway, back to the review,
Both of those waveforms should display the same, but they don't.
The first one comes from the DAC on PA_4 (aka A2),
the second comes from the PA_4 (D13) crippled by the onboard LED.
One thing I found slightly disappointing, is the fact it's got an LED connected to one of the DAC outputs. I know why, the DAC just so happens to end up on Arduino pin D13, which is where a LED is typically attached to on most arduinous boards of this form factor. So what's the problem, dude? Well, it just so happens the LED cripples the wave coming out of the DAC in a pretty ugly fashion. So it basically doesn't let anything over about 2V out, which almost made me go mad. This can be solved by removing a little jumper resistor at the bottom, but since I'm lazy, I've just downscaled the output in the code to be always under that value in the linear range. Nailed it.

But apart from that, I can't really complain much about this thing. I think I'd even recommend you getting one - they have a very wide range of them, each sporting a different processor with a different set of features that might be handy for something else. Anyway, it costs less than a half of the price of the Arduino Uno, and it has the same headers too, so in case you happen to be running low on money and actually think going with something slightly nicer than just a simple 8bit micro, I guess this might be the choice for you. I also really like the fact it's got that ST Link debugger on it ready to be broken out and being used standalone, so that might really come in handy too later, once you actually make your own little board or something.