Saturday, September 26, 2009
F1
Gah, he's driving like a pillock so I have acted to ensure Button wins this year drivers championship.
How? I hear you ask. Well, 'twas easy - I placed a bet on Barichello to win it... At the moment one of the web betting sites have a promotional deal where your first bet is essentially free, and the odds against him were something like 6 to 1, so taking a free punt on him seemed like a good deal to me. I'd like Button to win but if Barichello beats him I win £130 or so, which would go some way to moderating my indifference - disappointment, I meant.
Now, I just need someone to nobble Red Bull...
Friday, September 25, 2009
Scribblenauts
Scribblenauts is a game for the Nintendo DS and it's the first game in a long time that has impressed me. If you've got an NDS I strongly suggest you download the rom, play it and then buy the bloody thing, as I will be doing - they deserve it. It's superb.
What? Describe it? Well, basically it's a platform style game where you have to solve problems but the amazing feature is that you can write the name of just about any object you can think of into the game and have it appear.
The guys at work failed to fox it, they suggested "table" and it understands tables. They suggest "brick" and it understands bricks. I tried "osmium" expecting nothing, but it understands osmium. It knows it's dense. "Elephant" doesn't phase it, nor does "Bazooka"...
I was showing it to Sarah, on a level where there is a tree that needs to be cut down. "What would you suggest?" I asked her. "Axe" was the obvious response, so I write "axe" and one appears. I give it to the waiting lumberjack and lo, the tree was cut down. No great surprises there I hear you think.
"Suggest some other objects" I say - "Sunglasses" she replies. The game duly produced sunglasses, which the player's character then wears
"Go on, think of something awkward" I suggest. There is a pause.
"Ball gown" says Sarah. Ha! She's got it - it can't possibly... But it does. I write ball gown, and a ball gown appears. We give it to the lumberjack, who is definately not impressed and who then grumps mightily... clearly not a fan of Monty Python.
I then play about a bit. I write "atom bomb" and blow the entire level up. I write "time machine" and (glurk!) one appears and whisks me off into the past, where there are dinosaurs.
Ha! I think, and write "meteor"... One duly appears, and wipes out the dinosaurs...
At this point Psi phones and I wax lyrical at him. "Think of something!"
"Kumquat!" He says. Guess what? It knows about kumquats.
Later on I found there's a level where you have to shift a cow out of the road without harming it. I'd already found that "UFO" is recognised and gives you a flying saucer you can fly about in, so naturally... yes... you can hover over the cow and have the flying saucer pull it up. I like the way their minds work...
Thursday, September 24, 2009
Garbage
I've been finding it harder and harder to motivate myself of late and the reason, well, one reason anyway, is that I'm working on an upgrade to someone else's design and the original is such complete and utter garbage that every time I have to refer to it I want to throw the whole project in the bin and walk away.
It has a large software component - far larger than it needs to be - which appears to have been written by a beginner as their first ever software project. Unfortunately he wasn't a beginner and it wasn't his first project. Be that as it may, this piece of crap is, without doubt, the worst piece of programming I've seen in over thirty years. It is shockingly poor, a combination of just about every bad practice known to programming merged together in an orgy of sustained idiocy. None of it, and I mean none of it, shows any sign of competence whatsoever... Programmers will get an idea of what I mean when I say that the C source, all in one file, is about seven and a half thousand lines long, and that six and a half thousand lines of it is all in the main() routine. It's not that it needs to be, it's just that the author doesn't appear to grasp the idea of abstracting out common code into subroutines (whatever they're called these days)... Oh, he does know about them - he even has a couple. I'd tell you what they do, but then you'd have to kill yourselves in despair...
Oh, to hell with it. I'm depressed :(
Later: And as much as I hate it, I'm sure the bastard thing hates me even more. Wasted a lot of hours tonight trying (and failing) to figure out why I couldn't readback some ADC values, which it now appears is some sort of obscure board fault and not a problem in my FPGA design... That's the story of this project, I take one step forward and then several steps backwards with every session. Not one single fucking part of it has worked without a struggle. Every deadline has come and gone while I struggle with some obscure piece of stupidity and I'm heartily sick of it now.
[gloom]
Monday, September 21, 2009
Windoze
I must put on record that I was being unfair to Herve today.
I accused him of being the flying dutchman of the laptop world, forever doomed to spend his time running Windows 95 - but he quickly corrected me - he actually runs Windows 98 SE and is proud of it...
You know, I'm not entirely sure that using Windows 98, even the second editon, accurately portrays the dynamic, thrusting and forward-thinking aspects of Design Design as a high-technology design company. Bet he still uses lead in his solder...
[Furtively crem returns to the assembler source for an FPGA processor he's tweaking. It is clearly a variation on a Z80...]
Wallander
I've been watching the original Swedish "Wallander" TV series recently, having been a fan of the books for a while, and I was depressed to find out that the actress who played Linda Wallander (and played her well) killed herself a couple of years ago. Strange that I felt so bereft at the loss of someone I'd never have met or had any contact with whatsoever...

Tuesday, September 01, 2009
Halls of the Things in HD
There are some talented people in the world, and some of them are mad. One such is a guy called Andy Stewart who (completely of his own volition) has written a version of Halls of the Things in C# and released it on an unsuspecting world... It's so faithful to the orignal that I took it upon myself to appoint him the fourth evil lord in honour of this evil deed; I'm sure Neil and Martin would approve.
He has created a web-page for this allowing it to be downloaded : http://www.whatisblueandfurry.com/hott/halls08.html
A thing of beauty is a joy forever; but those bastards are dynamite...
[For some bizarre reason the comment option doesn't always appear on this posting. If you want to comment, click on the title and then it does. Weird...]
Friday, August 28, 2009
Just google it
Google makes life far too easy. A friend is getting reasonably good at some of the facebook games, so naturally I decide to wind them up by quietly posting slightly better scores. In the good olde days this would take skill - I'd have to figure out how to play the game... Hang on, [shudder], that's not what I meant - I meant I'd have to figure out how the game worked, where the score was stored, what form it was stored in, if there were any security checks and so on before hacking it to score whatever I wanted [phew]. This could involve several minutes of amusement...
In the really olde days you'd have to figure out their tape encoding schemes and fight off some cunning anti-piracy checks, but the days when programmers were that skilled are long gone; anti-piracy these days just means spelling your variables so badly that nobody else can figure out what the illiterate sod of a programmer meant, and it all happens by accident, not design.
But that's all moot, because now you don't hack anything, just google "bejewelled blitz cheat" and find the answer. Gah - where's the fun in that?
Pity I can't get it to score "xxx and a half", mind you. I suppose I could fake an accomplishment message... hmmm...
[later: A few days ago I found out that the wind-up worked...
Tuesday, August 04, 2009
Panes
I've just put the finishing touches to some demo code for an ARM-based operator interface panel we've designed, and it's sitting in front of me as I type with a few windows bouncing about at frame-rate in the foreground and a Mandelbrot being rendered in the background. Every now and then another view of the Mandelbrot drifts past in a stately fashion (frame-locked, of course) and if I touch the screen it pops up another window that follows the touch about under my finger, with a ghostly lattice of lines being drawn overlayed on the background to show the outlines of the various regions of the screen that are being rendered as the window position changes... It looks beautiful, as graphics that change at frame-rate usually do.
I'd include a picture, but a static photo really doesn't do it justice and I can't be bothered to work out how to include video at my time of life.
The hardware is a Cirrus ARM processor that has a fair number of peripherals on chip, including the LCD display driver. That single chip and a couple of SDRAMs, a FLASH and some glue is all that's involved, hardware-wise. The software - a complete graphical windows system and enough of an OS to run operator interface style applications - (in total about 12,000 lines of C) was all written from scratch by yours truly in about five weeks...
Since all of this is written in C and compiled with GCC (unusually for me there's not a line of assembler in there, aside from the device boot code) and it still runs fast enough on a 200MHz ARM to look bloody impressive I find myself wondering how the hell programmers manage to take hardware like this and make it appear as slow and crappy as all the ARM-based personal organisers out there look.
What the hell are they doing to slow them down?
It's amazing how bloody awful the demonstration code that Cirrus supply for their own device is, it makes the thing look like a CP/M machine struggling to write to a terminal.
This particular chip has blitter and line-drawing hardware that I haven't used, since I wanted the graphics code to be pretty generic. The demo code from Cirrus uses the blitter and still manages to run like a slug that has overdosed on valium. Gah...
The incompetence that's endemic in this industry depresses me, it really does :(
Monday, August 03, 2009
"Hey, are your feet wet too?"

Saw this image on t'web ( http://static.panoramio.com/photos/original/20677595.jpg ) and thought that there just has to be an amusing caption in there somewhere... Buggered if I can think of one, though for some reason I can't get the idea that one of the penguins is singing "I'm peeing in the river" to the tune of Peter Gabriel's "I'm feeding the rhythm" out of my head...
(Photo is by LichtenHansen http://www.panoramio.com/user/2512952)
Sunday, August 02, 2009
Mid wife crisis
There is an evil in the world and it targets middle aged men. I feel I owe it to others to warn of this insidious peril... They're small, they're sexy, they're hard to resist. You see one and you have to have it, the urge is overpowering, after all - what's the harm? Your wife/lover needn't find out. She won't suspect - with luck you'll get away with it. So you have one, but it's not enough. The thrill doesn't last and you come crashing down. Then you have to have another, and another, and soon you're spending all your money trying to maintain your addiction. You think you can control it, but it's an illusion, they're far too complicated.
I'm talking about radio controlled helicopters. Avoid them... One is never enough...
Thursday, July 30, 2009
Crotchless chastity belt
I was aimlessly Googling about today when I came across... No, let me rephrase that - when I encountered the phrase "crotchless chastity belt"...
Now is it me, or is someone seriously missing the point there? Or is someone getting the point when they shouldn't? Either way the phrase "crotchless chastity belt" has replaced "chocolate teapot" in my vocabulary...
It's over, or should that be IT is over?
I was working with a chip today, doesn't really matter what it was, when I realised that we are well and truly into the aftermath of the n'th industrial revolution. It's over, bar the shouting.
What shows this is the number of designs I now see that are fundamentally flawed, and flawed in ways that show the designers really don't know what they are doing. They get the basics wrong. I think the problem is that the leaders of the silicon revolution, or whatever fancy phrase you want to use to describe it, are now dying off and their hard-earned knowledge is being lost - the problem is that the good guys were all too busy doing it, whatever their particular "it" was, to write about how they did it, and they are now being replaced by people who have not learned from the ground up but rather were taught complicated subjects by those who weren't all that competent in the first place...
Up to the biotechnology people to take up the baton now, I guess.
Tuesday, July 28, 2009
Monday, July 20, 2009
Ruminations...
Someone asked me recently what aspect of my time in the games industry I remember most fondly. My knee-jerk answer to this sort of question is "Halls" but for a change I thought about it and there really is only one thing (aside from Halls) that still amuses me every time I come across it, and it is this couple of sentences that Psi and I wrote for the story line of Dr Strangefruit:
Strangefruit removed a dog-eared, loose-leaf notebook from an inside pocket and placed it reluctantly on the desk, as if parting with an art treasure of great value. Pratt reached over and picked it up, holding it by one corner, as one might retrieve a piece of used toilet-paper that had missed the bowl. It was not in keeping with Pratt's idea of documentation and did not appear to merit being on such an executive desk. "Might I ask what this is about ?" asked Pratt, who didn't want to have to read it to find out.
Well, there you go. More fun contained in a single paragraph than some of my complete games. We don't write 'em like that any more...
Tuesday, July 07, 2009
Ouch
So, today I'm working on a new industrial input card for our logger family. Lots of 0..20mA inputs and some switched outputs, usual sort of stuff.
For added interest it has two AVR processors. A Mega128 sitting down near ground doing most of the work (handling the comms, multplexing inputs, driving the ADC and so on) and a Mega8 sitting up near the supply positive rail watching the current drawn on the outputs and turning them off if the current exceeds preset limits. These two talk to each other through a level shifting serial link.
Doing it with two processors is both the cheapest and neatest solution to the problem, the alternative would be to have lots of level shifting hardware for the various outputs and current sensing lines, which would involve much more hardware and be less accurate with it.
But - there had to be a but - it does mean that I have to simultaneously develop software for two processors that are running at different grounds, and also one of them needs a software emulated serial port because the hardware ones are busy doing other comms jobs, hence there is some slightly awkward software and the programming requires isolated AVR programming/debugging interfaces. Well, I have those, so no problem.
Hah. The gods don't like cunning designs.
I blow the first Mega8 up when the bloody ground clip of a 'scope probe unclips itself and wanders across the PCB, managing to touch one of the AVR I/O pins. Normally this wouldn't be a problem, but it picks the AVR that has its ground up at +20V or so. It doesn't like having one of its pins dragged down to -20V (as it sees things) so bye-bye and off to silicon heaven it goes.
Much gallic muttering ensues as Herve replaces it.
A few hours later I'm busy working on the serial comms between the two processors when the 'scope probe slips out of my hand. It misses the board and I have a moment of relief until I realise it's heading for the exposed PCB of the isolated AVR programmer... It lands on it and there is a very slight, but clearly audible, click as the earthed shield of the probe makes contact with some component or other on the programmer.
Of course, it doesn't do this with the programmer that's sitting at ground, it picked the programmer that was connected to the positive rail and which was sitting with its ground at +20V or so, and that click signifies the end of that particular programmer. And, of course, the end of the bloody AVR it was connected to as well.
This happened at 10:30 pm, and at about 11:30 pm there was even more gallic muttering as Herve (dragged back into work) replaced the Mega8 again. This was accompanied by a fair bit of my own muttering as I repaired the AVR programmer.
About an hour and a half later the other AVR, which had been sitting down at ground and minding its own business, stopped talking to the debugger. After a bit of investigation it turned out that one of its I/O pins was damaged at some point in the preceeding fiasco and had quietly rotted.
Think I'll wait 'till tomorrow before I tell Herve he's got to replace the Mega128 now.
I'm starting to think the gods really don't like this design...
Tuesday, June 30, 2009
"It's alive!"
Finished the complete SoC (system on chip) design for this 'ere project, which I think is quite impressive in only a couple of weeks given how complicated it all turned out to be.
I can see me using verilog in preference to VHDL in future, I've found it fairly nice to use. There was always something a little counter-intuitive about VHDL as far as I was concerned...
And now onward and downward - the application software for it.
Saturday, June 27, 2009
Standards? What are they, exactly?
I've got to design an SPI port; they have a clock line, a data in and a data out line. Oh, and a chip select line. Four lines, in all. Should be easy enough to knock one up.
Of course it's too much to expect that I'll have been given any documentation for the device that it needs to interface with so I'd better make the port flexible. How many variations can there be?
Turns out there are chips out there with every possible variation of those signals. The chip select can be active high or active low. The clock line can be active high or active low and the input data can be latched on the rising edge, or the falling edge... The output data can change before the leading or after the trailing edge of the clock. The clock may or may not run when the chip select isn't active. The number of bits in each transaction? You think it's a constant? Foolish twisted boy...
Standards? Simplicity? Who needs 'em...
[weeks later]
I didn't make it clear that the SPI port I was grumping about there was a slave port, designing the master end is easier (I'd designed a master port as well, both of the designs are published in the R3220 data so decide for youself)... The slave port's timing is at the mercy of the master port and I didn't have any documentation for their master port... Still, it all worked so I must have made a reasonable job of things...
Thursday, June 25, 2009
Monday, June 15, 2009
R3220 microprocessor
I've been busy designing some FPGA hardware recently, and part of it uses a lovely little 32-bit microprocessor I designed a while back. I've been meaning to publish the source for it for some time, but since the contract for this design means I have to provide the source to the customer and even [shudder] document the thing to some extent I may as well take the opportunity to publish it now.
I've called it the R3220, those of a technical nature can assume this name derives from the fact it's a 32-bit RISC with about 20 instructions (while being completely oblivious of the "saturday night special" connection, I suspect).
The performance is fairly respectable, I'm using it to replace an existing NIOS II based design because the NIOS based design wasn't anywhere near fast enough.
As a guide the R3220 CPU uses between 600 and 1700 LE's in a Cyclone II array, so a complete system with one CPU with several peripherals only takes up ~12% of a Cyclone II EP2C20.
For fun I put four of these processors in the array (quad-core, anyone?) and it took up about 30% of the available logic. Since they can share memory without losing any performance it's actually not a bad idea to think in terms of more than one CPU for some applications, though I don't think I need to do it for this one.
(To facilitate the use of dual-port memory, which is common in gate arrays, the reset vector is configurable, so you can have two processors using the same memory block but not executing the same part of it. This incurs no extra delay so both will run at full speed.)
The verilog source, an example SOC design including various peripherals, a simple SDRAM controller and the r32 assembler can be found here -http://www.desdes.com/products/r3220/index.htm - note that this is the first verilog I've written so the style across the sources is inconsistent, I'm still finding my feet with the language. I'm more used to using VHDL, though I have to say I'm finding it a lot easier to write in verilog than VHDL, there's something about the 'feel' of verilog that I prefer.
This isn't the first processor I've designed and hidden away inside a gate array, but most of them have been too dedicated to a specific task to be worth discussing. This one is a nice general-purpose device to programme (in assembler, that is. If you're stuck using C then pick one of the MIPS implementations) and given how little time it took to develop (about ten days) I have to say I'm very pleased with it - it's a shame that so many embedded designers are stuck in the whole turgid morass of the linux/gcc/c bloatware mindset and can't play about like this, they really don't know how much fun they're missing...
For those who care it's a fairly classic load/store risc with a couple of unusual features. I designed it to have lots of registers (128) so I can dedicate them to interrupt handlers, and it has a nice touch that allows for 7 or 14-bit immediate values in the single-cycle instructions but also a full 32-bit immediate value can be used for all operations with only a single cycle penalty - it achieves this by taking one of the 7-bit immediate values, (-64), and using it as a flag to request that the next instruction word be used as a 32-bit immediate instead.
It has a reasonable addressing mode set with all the usual pre and post inc/dec indexed operations. The address is formed by taking a pointer register, which can be any of the 128 registers (there is no distinction between them) and optionally adding a 7-bit signed offset value. This address can be written back to the index register if required (with no extra delay) which allows auto inc/dec modes. The fact that the memory address used can be the register address or the register+offset means that there is full support for auto inc and dec with pre inc/dec and post inc/dec addresses. So any sort of stack you like, basically.
Every instruction is conditional with an option to update the flags. Sounds like an ARM, I suppose, though I first designed a CPU that did this many years before the ARM appeared so saying I got the idea from ARM might just earn you a thick ear [grin]. In fact, the bit field layout in this instruction set is remarkably similar to one of my designs from the 70's, though I was trying to outdo the PDP-11 back then so the that design had a particularly gothic and slow addressing mode set. [shudder]
The condition codes operate by having a 4-bit field that selects individual flags in the status register and then determining if the instruction should be executed using the state of the selected flag.
Doing that uses 14 of the 16 possible condition codes to handle 7 status flag bits. Of the two remaining codes one is ALWAYS which means always execute, of course, and the last is interesting - I've called it 'LOCK' and it always executes the instruction, the same as ALWAYS, but it also prevents the instruction from being interrupted. Once the processor has been put into LOCK mode it remains in LOCK mode until it executes an instruction with the ALWAYS condition code. This allows sections of code to be made 'atomic' without any overhead, and those sections can include conditional code.
Lock mode also forces locked RMW bus cycles where the bus architecture supports them, which makes it beautiful for implementing semaphores, etc. It's all much nicer than having to either flip interrupt enable/disable flags around critical bits of code or use peculiar instructions.
Another use of LOCK is in function entry/exit code, to make the stacking/unstacking of link registers etc safe. This can be handled transparently by the development tools.
I designed it to be agile, so interrupts have to be entered and exited quickly, and to that end it supports multiple interrupt levels with priority encoding on each of those for multiple interrupt sources at each level. The CPU outputs acknowledge signals when taking an interrupt vector so there are no delays while the handler has to manage the interrupt controller.
For speed it uses dedicated link registers instead of stacking the return address/state during interrupt cycles, and cleverly uses the particular link register invoked by the 'return' instruction to signal the end of that interrupt level to the interrupt controller. This means interrupt handlers are exactly as fast as calls and yet don't require any special entry/exit instructions.
Something else that's nice, though obvious, is that because you can load/store values directly to the status register and the condition codes use single bit testing peripherals can to organise their status flags so it's meaningful for the device handler software to load the peripheral's status register directly into the CPU status register and then use conditional instruction execution to determine how the flow should proceed. ie:
ld status,uart_status[peripherals]
call s0t RxByteHandler ; The s0t means execute this if status register bit 0 is true.
call s1t TxByteHandler ; The s1t means execute this if status register bit 1 is true.
The s0t, s1t (etc) are aliases for the conditions C, Z, etc.
This process is helped by the fact that the handers can preserve the status flags (they're saved in the link register and can be loaded back or not as required when returning).
The assembler is pretty powerful, as well as all the usual stuff you'd expect it handles allocating link registers automatically so the user doesn't have to know or care what they are. Thanks are due to a certain Ste for making me do this with his damned "It can't be that difficult" and "I can't see the problem" attitude.
In summary it's a nice processor, amazingly nice considering how little time it took to design. I absolutely love being in a position where I can design stuff like this and get paid for doing it...
Sunday, June 14, 2009
Interesting times
"May you live with interesting timings" I remarked, innocently enough.
"What?"
"May you live with interesting timings... You know, like the olde curse - may you live in interesting times - but updated for poor sods like me stuck trying to get their bloody logic running fast enough in a sluggish array... "
"What old curse?"
"May you live in interesting times - it's Chinese or Celtic or summat. Quite clever really, it implies that interesting times are not ones you'd want to live in"
[ponder]
"Not much of a curse, is it?"
"What?"
"I just think it's a bit mild for a curse... It wouldn't spring naturally to mind when I wanted to tell someone to fuck right off is what I'm saying... It lacks something. Live in interesting times? Pah..."
"You have no subtlety, if it was you no doubt it'd be something along the lines of 'may you have diarrhea and piles and live in the bathroom!' Oh, just fuck off!"
"See? Much more satisfying..."
"You know, thinking about it, you're right..."
Subscribe to:
Posts (Atom)