I am using Altera DE2 FPGA board and verilog, designed a simple CPU using these. I need to print the value of a register using the VGA output of the board.
How should I go about this?
Quite a long path I'm afraid.
First you need to get hold of a VGA output peripheral. That takes values from memory and sends the appropriate RGB values to the screen at just the right times relative to the sync pulses (which it also must generate).
Once you've done that, you processor needs to write to the memory a set of dots which look like the characters you want to display - so you need a simple bitmapped font. Alternatively, you can make the memory character-oriented, so the processor just has to put a set of ASCII values into it and the VGA output will then look up i(in an internal font look up table) what the pattern of dots for an 'a' (say) should be on whichever line of the display it is creating at the time.
Video output is a good fun project though!
Adding onto what Martin is saying, if you would want to shorten that path by kind of hacking through it, you can essentially make a segments library. To understand what I am saying, if you looked at a 7-segment display, each segment lights up individually to create a value from 0-9, essentially you can write a library to create each of these segments and then transpose them to represent to one's place, ten's place, and so on. Here is a snippet of some code that displays the segments on the bottom right.
/*
__5__
| |
1|__6__|3
| |
2|_____|4
7
offset referring to the position meaning tens or ones place.
If you would like ones place, call seg_1(0) for example and
if you would like tens place, call seg_1(1) and so forth.
*/
void seg_1(int offset) {
for(i = 360; i < 420; i++) //y-axis
{
for(j = 540-(offset*120) ; j < 560-(offset*120); j++) //x-axis
{
Vga_Set_Pixel(VGA_0_BASE,j,i);
}
}
}
void seg_2(int offset) {
for(i = 420; i < 460; i++) //y-axis
{
for(j = 540-(offset*120) ; j < 560-(offset*120); j++) //x-axis
{
Vga_Set_Pixel(VGA_0_BASE,j,i);
}
}
}
...
...