SRAM VGA text mode module added to p1v - now with high-level Spin driver
pik33
Posts: 2,366
I did first tests with this module. This is text mode driver for 1440x900 resolution. Active screen is 1280x800, 50 lines of 160 characters, 8x16 pixels, attached to the Propeller via extended portb
The memory map is: 8000 words from 0 - character/attribute (as in CGA)
$FFFF0 - border R
$FFFF1 - border G
$FFFF2 - border B
$FFFF3 - cursor position
The rest of 2 MB SRAM chip is free for any use.
To write the data put the address on dirb and the 16-bit data on outb, then strobe the data with dirb[31]. To read the data put the address on dirb, then read the data from inb.
Test program:
The memory map is: 8000 words from 0 - character/attribute (as in CGA)
$FFFF0 - border R
$FFFF1 - border G
$FFFF2 - border B
$FFFF3 - cursor position
The rest of 2 MB SRAM chip is free for any use.
To write the data put the address on dirb and the 16-bit data on outb, then strobe the data with dirb[31]. To read the data put the address on dirb, then read the data from inb.
Test program:
pub testvga |i,j,k dirb:=$FFFF0 outb:=0 dirb[31]:=1 dirb[31]:=0 dirb:=$FFFF1 outb:=$40 dirb[31]:=1 dirb[31]:=0 dirb:=$FFFF2 outb:=$80 dirb[31]:=1 dirb[31]:=0 dirb:=$FFFF3 outb:=$0101 dirb[31]:=1 dirb[31]:=0 repeat j from 0 to 49 repeat i from 0 to 159 dirb:=i+160*j outb:=0 dirb[31]:=1 dirb[31]:=0 repeat j from 0 to 49 repeat i from 0 to 159 dirb:=i+160*j outb:=i<<8+j dirb[31]:=1 dirb[31]:=0
Comments
Dr Acula, of course the 1M16 SRAM on the DE2-115 can be used for full graphics, I have done that in my Soft Cog project. There are 2 problems however that need to be solved in the Verilog code:
- This memory is slower that the internal M9K memory blocks, I have used it at 40MHz only (for a 800x600 VGA display, one byte per pixel)
- You have to time-multiplex the memory between write-access (from the user) and read access (from the VGA controller). One time slot for write access, one timeslot to read 2 pixels
The internal M9K blocks are dual ported by nature so read and write access can be independant and the Verilog can be much simpler.
Yes, it can do, I have a 800x600x24 graphic driver, but it is extremely slow. The vga get all bandwidth and you can access the RAM olly during h/vblank.
It seems to be possible making a palette registers for this.
It is possible, with the same timings, do an 1280x800 graphics in a 1440x900 screen. It reads two bytes and makes 8 pixels, so we can have 1280x800x4 colors. To do.
pik33
Thank you for the excellent sources and explanations. I have about 2 days of actual verilog study. Mostly browsing.
I am running 32bit Quartus 13.0.1 on an XP machine, using SystemVerilog.
When I try to compile, it stops almost immediately with 3 errors.
The first seems to be the issue:
"Illegal Assignment : IP_Generated_Device family. Specify a legal assignment name"
I thought that I had a problem in Assignments->Devices, but that appears to be ok.
Thanks,
Rich
Download again the project and delete project file prop-vga.qpf. Then make a new project for de2-115. Use prop-vga.bdf as main entity. Import the assignments from DE2_115_pin_assignments.mod.csv. Set in fitter option "aggressive routability optimizations" - always or it will compile forever hanging on 72..80%. Maybe you will have to remove pll and create it again. It should output 212.5 MHz.
- the Propeller clock is synchronized with pixel clock (106.25 MHz). Not synchronized clock causes random errors when scrolling up/down
- RGB components was changed so color 1 is blue and 4 is red, to meet CGA standard color map
Edit: I uploaded rs-232 programmable version of it. There are green labels under UART pins. Replace the UART_xxx with GPIO[xxx] as in these labels to make the project programmable with a Propplug
Edit 2: Added a PropPlug version
No more floating pixels in the first column of active screen. This was the case when "=" was useful.
This is rs232 programmable version. To make it propplug programmable, replace the UART_xxx with GPIO[xxx] as in the green labels near UART pin and recompile. The RS232 cable seems to be more stable thing than the propplug inserted into GPIO with an USB cable attached to it
There should be a way to make the circuit programmable with both methods - RS232 and Propplug@GPIO, but first try didn't work, the Propeller was not programmable at all.
There is Spin driver in the project directory. Now it uses pasm for fast scrolling, color changing and clearing the screen
I added some internal RAM to store border colors and cursor position (the rest of 64 word block is now unused). The internal RAM is accessible with addresses with bit 20 set.
The Propeller works now @ 125 MHz
Thanks again for your posts. I particularly like how you have configured dirb and outb. In this sense your code serves as a template for experimentation.
I upgraded to Quartus II ver 14. I am now able to compile without errors... but there is no .cof file.
It occurred to me that I might have my settings wrong or that I am missing something.
I searched the web and looked through Quartus documentation mostly looking for causes of missing .cof files to no avail.
Any help would be appreciated.
Rich
You need .sof or .pof to program the device. You can find it in the project directory or in its output_files folder if it exists.
Now I am working at graphics driver with the same inb/outb/dirb configuration. Some work still needed before I will put it here.
This would be a generalized memory controller... all available through the same interface...the beauty of it all:)
There are no good examples that I can find anywhere for either SDRAM or embedded memory that doesn't use either IP or NIOSII.
I found this link helpful:
http://quartushelp.altera.com/12.1/mergedProjects/reference/glossary/def_file_types.htm
I am looking once again, trying to gain a better understanding. I looked through the files trying to figure out how you hooked up outb and dirb to the SRAM. The only connection I see is in the block diagram... is this correct? Nothing in the .v files that I missed?
By the way, I am just a little bit familiar with VGA, it is really fascinating to see how it is done in Verilog... pretty snazzy.
Thanks
When I open st4font.hex as a binary image 32 X 2048 I don't see the final font representation... how are the bits in the hex values computed?
Ports are connected to vga module in the block diagram, so there is no verilog code for this connection.
VGA verilog module gets input from the Propeller via this connection and then generates signals for SRAM chip. This is done in verilog inside the VGA module
Font is 8x16 pixels, 128 characters defined, one byte is one line of character, 1 bit=1 pixel. The font is ripped from Atari ST and it is the same font I used in my Propeller vga "nostalgic" driver
Thank you... again and again. This is as I understood the connections and code. But I just was not confident.
The code is very clear once the connections in the block diagram are considered.
I will have to go back later and look at the font again. I am not on my home computer right now.
This is beyond me at the moment, would it be possible to use m9k memory blocks as a dual ported screen buffer... so that the VGA display could have full time read access and writing to the buffer by portb could be done simultaneously?
Regards,
Rich
It is possible and it is much simpler to do than fighting with SRAM timings and signals. I rewrote this driver for DE1-SoC. This board doesn't have SRAM so I simulated it with its internal memory blocks. No problems with timings, no problem with addressing. The problam was when I tried to compile this for the first time: it compiles forever and eats all 8 GB of RAM i have in my computer. The solution was using RAM megafunction: I created RAM module with the megafunction and then connected it to the VGA driver instead of SRAM. Then it compiles in less than 10 minutes.
This was one port RAM - to simulate a real SRAM and don't change driver's timings.
Full writing acces is not needed. The Propeler needs at least 8 instruction to effective write to SRAM (including loop, rdlong or calculating next value). This is over 24 pixels. The Propeller has acces to SRAM every 8 pixels.