For Christmas I got a DE0 FPGA Devkit from Terasic. It is based on a Cyclone III FPGA, which is a little bit old now but it works fine for learning and hopefully for what I plan to do with it.

Programming these is easier than I thought, at least using Verilog. A basic blink program looks like this, for example:

module simple (input clk, output reg led);

reg [31:0] counter;

always @ (posedge clk) begin
	if (counter <= 25000000) begin
		counter <= counter + 1;
	end
	else begin
		counter <= 0;
		led <= ~led;
	end
end

endmodule //simple

The first line declares the module and its inputs/outputs. In this case there is an input called clk and an output called led. These inputs and outputs don’t actually correspond to anything in this code, you assign them to pins on the chip later.

Counter is declared as a 32 bit register, so that it can count high enough

The always statement is pretty self explanatory, every positive edge of clk, it will run whatever is between the begin and end statements. This program first sees if counter is less than or equal to 25 million. With a 50MHz clock, this is every half second. After that half second, the counter is reset and the ouput is inverted.

One thing you might notice is the <=. This works like normal in the if statements, but its also used as a non-blocking assignment. This means that the counter will be set to 0 and the led will be inverted at the exact same time. It might look like a program now, but after this gets put on the FPGA there are no lines of code or instructions to read, it’s all in hardware.

After you write the program, you assign the pins in this menu. Since I didn’t make this board, I’m using whats written in the user guide. pinplanner

The board has a built in programmer so all you have to do is plug it in with a regular USB cord and upload the file.

My plans for this is to make a graphics solution for my 6502 computer. This board has VGA onboard which makes it a lot easier. It just as a basic resistor-ladder DAC which gives it 4 bits for each color for a total of 4096 colors. Here is a quick program which goes through some of them:

Next I need to work on an interface for the computer and figure out how to store data in memory. Once I have that figured out, I should have a graphics chip with no limitations. The board can also be used for things like a PS2 keyboard, SD card storage, and a bunch of extra inputs and outputs.