A little over twenty years ago, some loosly-coupled friends and I collaborated on a demo for the Commodore Amiga. This was a few years before any of us had modems, never mind internet connections, so our collaboration took the form of mailing physical floppy disks to eachother in jiffy-bags (we lived in different parts of the UK).
The demo was written in 68000 assembler and ran entirely on the "bare metal" of the Amiga hardware (i.e I even had to do my own MFM decoding of the track bitstream from the floppy disk). It took many months to write, including one evil 60-hour straight coding session, which in itself was a fascinating (if unpleasant) experiment in neuroscience. It was finally released in August 1992, and dedicated to the memory of Isaac Asimov, who had died earlier that year.
I'd like to record a video of the demo running, to put on YouTube. I tried running it on UAE, but the result wasn't very good; I obviously relied heavily on the precise cycle-timing of the 68000 and blitter in the A500 to synchronise various aspects of the demo, so there are a few annoying visual artefacts in UAE.
I wonder how hard it would be to sample the 12-bit digital video stream coming out of Denise (the Amiga video chip) using an FPGA and save the raw frame data on a PC? The pixel data rate is only about 7.8MiB/s in lo-res mode (320x256 PAL) and twice that in hi-res mode (which is used briefly in the demo). FPGALink would deal with that very easily.
Following the MakeStuff tradition of "silly things to make around Christmas time", I present the Mariokart Randomizer:
Mariokart is a pretty popular game in our household. The only problem is, it's hard to give each character and each track an equal chance of being played. I know what you're thinking ("huh...first-world problems"), but I'm not kidding: this is serious business!
So, enter the Mariokart Randomizer. It's a small, featureless black box with a 20x4 LCD, a toggle switch and a nice red button. Flick the toggle switch to the "on" position and press the red button for a few seconds. When you release it, what you see is four Mariokart characters chosen at random from the 19 currently available to us, and four tracks chosen at random from the 32 available to us (eight cups, each with four tracks). So now, up to four players can be assigned characters and four tracks chosen for them to race!
I added a software USART to FPGALink's FX2LP firmware, to facilitate firmware debugging. The code is here. By default it uses
PD7 to output debug messages. I wired my FX2FPGA board up with a SAVR:Serial thus:
To enable it, just uncomment the
#define DEBUG in firmware/debug.h and run
sudo minicom with this config:
chris@wotan$ cat /etc/minicom/minirc.dfl pu port /dev/ttyS0 pu baudrate 115200 pu bits 8 pu parity N pu stopbits 1 pu rtscts No pu addlinefeed Yes
You can now send debug messages to minicom from the FX2 firmware:
void usartInit(void); void usartSendByte(uint8 c); void usartSendByteHex(uint8 byte); void usartSendWordHex(uint16 word); void usartSendLongHex(uint32 word); void usartSendString(const char *s);
Why hadn't researchers pieced together a similar theory of the density-limit puzzle before? The answer, says Gates, lies in how ideas percolate through the scientific community. "The radiation-driven islands idea never got a lot of press," he says. "People thought of them as curiosities. The way we disseminate information is through publications, and this idea had a weak initial push."
This rather euphemistic indictment of the scientific community immediately made me think of three other things I read recently.
Economics is haunted by more fallacies than any other study known to man. This is no accident. The inherent difficulties of the subject would be great enough in any case, but they are multiplied a thousand fold by a factor that is insignificant in, say, physics, mathematics or medicine: the special pleading of selfish interests.
Secondly, from "Po: Beyond Yes and No" by Edward de Bono (Penguin, 1973):
It is bad enough when an idea resists change because it cannot be faulted...but it is worse than that. Often it is impossible to change an idea that can be faulted. This is because ideas are affirmed not simply on logical grounds but also on emotional grounds.
A person who is determined to believe in flying saucers travels to Norway to examine the wreck of a saucer that is said to have crashed there. If he finds nothing, then clearly the wreckage has been removed by the government in order to pretend it never happened. If he finds the wreckage of an ordinary plane, then clearly the government has substituted the plane deliberately to mislead the investigators. So lack of actual evidence for the flying saucer is actually evidence of a conspiracy to hush it up and hence evidence for the saucers, since you do not hush up something which is not true.
At any given moment there is an orthodoxy, a body of ideas which it is assumed that all right-thinking people will accept without question. It is not exactly forbidden to say this, that or the other, but it is ‘not done’ to say it, just as in mid-Victorian times it was ‘not done’ to mention trousers in the presence of a lady. Anyone who challenges the prevailing orthodoxy finds himself silenced with surprising effectiveness. A genuinely unfashionable opinion is almost never given a fair hearing, either in the popular press or in the highbrow periodicals.
At this moment what is demanded by the prevailing orthodoxy is an uncritical admiration of Soviet Russia. Everyone knows this, nearly everyone acts on it. Any serious criticism of the Soviet régime, any disclosure of facts which the Soviet government would prefer to keep hidden, is next door to unprintable. And this nation-wide conspiracy to flatter our ally takes place, curiously enough, against a background of genuine intellectual tolerance. For though you arc not allowed to criticise the Soviet government, at least you are reasonably free to criticise our own. Hardly anyone will print an attack on Stalin, but it is quite safe to attack Churchill, at any rate in books and periodicals.
I wonder how much the Internet (from email to www to social networks) is really changing how science is actually done? It's tempting to think of scientists as dispassionate, curious and above all free people, with an absolute respect for the scientific method. But of course scientists are just human beings: brilliant, quirky, insightful, curious and perhaps slightly obsessive beings certainly, but also economic beings, political beings, emotional beings, scared beings, pay-the-mortgage beings. It was hard enough to join up apparently unrelated dots when it was possible to conduct research with no foreseeable economic benefit, but in the modern world where research seems to be driven more by questions of funding than by genuine scientific curiosity, the crucial dots that need to be joined might not even be visible, having been dismissed as "curiosities" by the scientific literature.
Recently I was working on an FPGA design and was running out of pins, so I started looking for superfluous pin assignments. The asynchronous
reset_in line caught my attention:
architecture behavioural of toplevel is type StateType is ( STATE_IDLE, : ); signal state : StateType; signal state_next : StateType; begin process(clk_in, reset_in) begin if ( reset_in = '1' ) then state <= STATE_IDLE; elsif ( rising_edge(clk_in) ) then state <= state_next; end if; end process; :
"Surely," I thought, "an FPGA comes out of configuration with its registers in a known state, making the asynchronous reset presented throughout Chu's book superfluous?" Well, it turns out that this intuition is backed up by a Xilinx white paper from 2008. So, I tried removing all my asynchronous resets:
architecture behavioural of toplevel is type StateType is ( STATE_IDLE, : ); signal state : StateType := STATE_IDLE; signal state_next : StateType; begin process(clk_in) begin if ( rising_edge(clk_in) ) then state <= state_next; end if; end process; :
...and noticed some, but not all of my designs were giving a weird synthesis warning:
WARNING:Xst:1426 - The value init of the FF/Latch state_0 hinder the constant cleaning in the block toplevel. You should achieve better results by setting this init to 1.
It's weird because it suggests using a different numeric value to initialise the state machine whose state is defined by an enumerated type (numeric values for which are chosen by the synthesis tool). The related Xilinx KB article is not very helpful, nor (on initial reading) is the explanation given by one of the experts on the Xilinx forums:
Regarding that warning message: ignore it. The "constant" XST is rambling about, is your state_fsm register – if you gave it the initial value of 0, then it would never change and could be replaced by a constant (which is not what you want). XST can sometimes be a little dense about these things. If anything, this message should be an "Info", not a "Warning".
So I went about trying to narrow down what distinguishes the VHDL which generates such warnings from the VHDL which does not. And it seems like the warning will be given if the state machine ends up in a state from which there are no transitions.
So, for example, this state machine will generate the warning, because once it gets to
STATE_FINISHED, it remains there forever:
process(state) begin state_next <= state; -- by default stay in the current state case state is when STATE_IDLE => state_next <= STATE_FINISHED; when STATE_FINISHED => --state_next <= STATE_IDLE; when others => state_next <= STATE_IDLE; end case; end process;
...whereas this state machine does not, because it continues transitioning forever:
process(state) begin state_next <= state; -- by default stay in the current state case state is when STATE_IDLE => state_next <= STATE_FINISHED; when STATE_FINISHED => state_next <= STATE_IDLE; when others => state_next <= STATE_IDLE; end case; end process;
Suddenly awillen's advice to ignore the warning makes sense. XST notices that the state machine ends up in a given state, and says, "hey you end up in this state anyway so why don't you just initialise to that state in the first place?" Err...maybe because I consider the work done by the state machine before it reaches the steady-state to be kinda important?