A DE2-115 Propeller retromachine - 1920x1080 enabled
pik33
Posts: 2,366
The post #56 contains new version 0.98b
Changes: P14..P17 connected to UART which enables RS232 port on DE2-115.
Edit: the post #55 contains new version 0.98a.
Changes: Amiga-like Hold-and-Modify (HAM) graphics modes added
Edit: the post #54 contains new version 0.98. Added 3 new registers to make blitting easier with hardware supported shl/shr write operation which is very hard to do with the Propeller and slows things down
Edit: the post #50 contains new version 0.97b
Changes:
Display resolution selectable at boot with SW17 - 0: 1920x1200, 1: 1920x1080
So if you have a 1920x1080 monitor you can now try it. The demos in spin are written for 1920x1200 but if the machine will be started with SW17 on, they will work @ 1920x1080 too; the down part of the screen will be of course cropped.
Two new registers added to make possible hiding the sprites under the playfield and signalling playfield/sprite collisions. Now writing a game like Arkanoid or other oldschool type games will be much simpler
Post #29 updated to add definitions of these registers.
You can program the Propeller on the retromachine with the Propplug as in the original p1v; if you generate an eeprom file from your program, rename it to boot.sys and place on the SD card, the machine will boot it.
The p1v used has disabled video circuits and mul instruction added.
Edit: the post #37 contains new version 0.97a
Edit: the post #29 contains the memory map of the retromachine
Edit: version 0.96 added (post #26)
Change: added sound input port $8E000. Now you can record the sound or make a filters/dsp/denoising with the retromachine .
Samples are 16bit signed @ 44100 Hz. Sample ready interrupt input is at ina[6].
Edit: SD card booter added (post #21)
Now the retromachine will boot any program from boot.sys file on SD card
Edit: The 0.95 added (post #20)
It seems to have all planned features working. Now it needs debugging, cleaning, testing and making the software for it
This is work in progress which emerged from my VGA driver for P1V. Now, I have connected SD, keyboard, mouse, SDRAM and the sound chip. There is a sound buffer which can be used to play WAV files, but I started to implement Paula-like sound chip
So I started now a new topic for this.
Still to do:
- Paula (something based on it)
- 1920x1080 based graphics modes
- xmm machine and programming language to make this PC free
Attached a self starting demo pof/sof and a spin demo program - you can program the Propeller via Propplug and play with the system
The PS2-Y cable is needed to attach a mouse and a kbd to a single PS2 port available on DE2-115. Then you can draw on the high-res GUI simulation demo screen with the mouse.
The verilog sources I will add later; now there is too much chaos in them.
Changes: P14..P17 connected to UART which enables RS232 port on DE2-115.
Edit: the post #55 contains new version 0.98a.
Changes: Amiga-like Hold-and-Modify (HAM) graphics modes added
Edit: the post #54 contains new version 0.98. Added 3 new registers to make blitting easier with hardware supported shl/shr write operation which is very hard to do with the Propeller and slows things down
Edit: the post #50 contains new version 0.97b
Changes:
Display resolution selectable at boot with SW17 - 0: 1920x1200, 1: 1920x1080
So if you have a 1920x1080 monitor you can now try it. The demos in spin are written for 1920x1200 but if the machine will be started with SW17 on, they will work @ 1920x1080 too; the down part of the screen will be of course cropped.
Two new registers added to make possible hiding the sprites under the playfield and signalling playfield/sprite collisions. Now writing a game like Arkanoid or other oldschool type games will be much simpler
Post #29 updated to add definitions of these registers.
You can program the Propeller on the retromachine with the Propplug as in the original p1v; if you generate an eeprom file from your program, rename it to boot.sys and place on the SD card, the machine will boot it.
The p1v used has disabled video circuits and mul instruction added.
Edit: the post #37 contains new version 0.97a
Edit: the post #29 contains the memory map of the retromachine
Edit: version 0.96 added (post #26)
Change: added sound input port $8E000. Now you can record the sound or make a filters/dsp/denoising with the retromachine .
Samples are 16bit signed @ 44100 Hz. Sample ready interrupt input is at ina[6].
Edit: SD card booter added (post #21)
Now the retromachine will boot any program from boot.sys file on SD card
Edit: The 0.95 added (post #20)
It seems to have all planned features working. Now it needs debugging, cleaning, testing and making the software for it
This is work in progress which emerged from my VGA driver for P1V. Now, I have connected SD, keyboard, mouse, SDRAM and the sound chip. There is a sound buffer which can be used to play WAV files, but I started to implement Paula-like sound chip
So I started now a new topic for this.
Still to do:
- Paula (something based on it)
- 1920x1080 based graphics modes
- xmm machine and programming language to make this PC free
Attached a self starting demo pof/sof and a spin demo program - you can program the Propeller via Propplug and play with the system
The PS2-Y cable is needed to attach a mouse and a kbd to a single PS2 port available on DE2-115. Then you can draw on the high-res GUI simulation demo screen with the mouse.
The verilog sources I will add later; now there is too much chaos in them.
Comments
What is the speed of the ram chip? More specifically, if you are running a cog with spin in a local 32k memory space, is there much of a time penalty to run from external memory?
Fast external ram (and internal ram as well on these high performance FPGA chips) means more ram for video and more ram for code memory.
Keep us posted - this is a great thread
Added to the first post. This is a mouse cursor shape definition file.
When using 2 MB SRAM it is synchronized with the vga tming, so theoretical best is one access per 16 pixels=12 Propeller clock. The worst case is 25 pixels, 18..19 Propeller clock - 5 instructions.
When using SDRAM i didn't try the maximum speed. I am using the same procedures for both sram and sdram.
This is a fast blit procedure:
A main blitter loop starts from p111 doing one 32-bit memory to memory transfer with 9 Propeller instruction = 36 clocks=48 pixels. The waitpeq synchronizes it with ready signal from the vga driver. This is 2x slower than theoretical maximum ram speed.
on the BeMicroCV yet without an avalon bus.
To make a beep, place the beep samples in the SRAM, then set start, length and freq registers, and when the volume is non-zero, the channel will start play.
If the volume is set to zero, then target synth addresses $83010-$83013 are not changed by the synth, so they can be written from the Propeller, making possible to make the sound with the software (SIDcog!)
To play a wav, there is another mechanism: a 256 longs buffer at $84000. Put a wave samples here. There are two empty bits, for every half of the buffer, connected to P5..P4, so if the empty signal is set, you have to fill the half of the buffer, while the second half is playing. One half of the buffer is 128 longs=512bytes=one SD sector. I did a WAV player before with this mechanism, but now there is a better way: make a big buffer in SDRAM, then blit the bytes from there. The buffer should be working in the demo I added before.
Now I need to do some testing and code cleaning... then make it available to the forum.
Can you tell me why you couldn't instantiate the dd3 controller ?. I can instantiate it but did not configure the reset and pll correctly. I mean reset handling was not right.
Which Altera IP were you using for that? The controlled I tried to use was avalon-only, so I had trouble
making it work with anything else.
As it is now, my circuit is not stable; not every compilation works as expected. I hope I can make it stable today after some code cleaning; there are unused regs and interleaved fragments of code that doing different things. When it passes the tests I will put the project source here.
The VGA timings are now reconfigurable, so it should work in any resolution, where pixel count in display line is >=2080 and pixel clock is near 150 MHz. It seems to be possible to run @ 1600x1200, 1680x1050, 1920x1080 and 1920x1200. All of these resolutions have pixel clocks about 150 MHz, so this 152 MHz clock I am using now should be tolerated by most of monitors.
The pixel clock for 1920x1200 should be 154 MHz but I had to synchronize this thing with an audio chip, so the pixel clock has to be 44100 Hz*384*9=152_409_600 Hz. The Cyclone 4 pll cannot do exactly this. It can do 152_380_952 Hz which gives 44091.7 Hz instead of 44100 Hz for the sound chip. It is 0.019% deviation and should be not hearable.
The Propeller clock is 3/4 of this = 114_285_714 Hz
I added the possibility to control hex and leds via memory mapped ports, there is also key/sw input port
****** Chaotic code warning ****
The code needs cleaning, the wrong comments are now in wrong places - I put it simply "as it is and works now"
The Propeller now has commented out video circuit to save some FPGA resources. It is mul-enabled and unscrambled. It can be reprogrammed in standard way (a Propplug in GPIO)
The memory map: (I need to prepare a detailed documentation)
0-$7FFFF - SRAM - "chip ram"
$80000 - pallette, 1024 long entries
$81000 - font definition, 2048 byte wide entries
$82000 - sprite data, 1536 longs
$84000 - sound buffer, 512 longs
$8F000 - 12 VGA timing registers
$83000 - register block:
- $83000 frame counter
- $83001 display start address
- $83002 graphic mode
- $83003 border color
- $83004 - pallette bank
- $83005 - pallette switch (you can change pallette bank in the middle of the screen with it )
- $83006 - display list start
- $83007 - fine horizontal scroll
- $83008 - line length
- $83009 - $8300E - sprite control
- $8300F- collision register
- $83010 - $83013 - current sound samples #1-4
- $83014-$83017 - frequency
- $83018-$830B - sample start
- $8301C-$8301F - sample length
- $83020-$83023 - sample volume
- $83024-$83026 - LED and HEX
- $83027-$83028 - SW/KEY anl cog led input
- $83029 - cog led input disable
To use these addersses, use vga.poke and vga.peek methods. Look at the demo code.
The hardware was not changed, but hardcoded software now is a booter instead of the demo. It looks for a file boot.sys on SD card, then run it.
The attached boot.sys file contains the demo as it was yesterday.
So now there is no need for a propplug or other kind of serial programming tool. Simply compile your program, make .eeprom file, save it on the SD root directory as boot.sys, insert the SD into DE2-115 and switch the system on
Are you willing to share your SD-Booter code so I can update my BeMicroCV version as well?
Edit: I rewrote the booter:
My booter inits the graphics 5, writes the invitation, then boots.
All the rest is used now...
- port B - system bus (all)
- P0..P7 - "interrupt request"
- P18..19 - i2c for sound chip
- P20..23 - SD
- P24..27 - PS2
- P28..29 - reserved for eeprom (there is one onboard... too small I will replace it as soon as I can.. )
- P30..31 - Propplug
Tested $8Fxxx registers and it seems they work, so you can change VGA timings.
Some things are hardcoded in the verilog code, so the line can't be too short; the right border should start somewhere about 1953, then the line should not be shorter than 2080.
If your monitor cannot display 1920x1200, try this. It sets 1680x1050 @ 63 Hz; it works with my monitor
After the chip initialization (in the demo: pub initsound) this:
A simple demo code:
causes the machine to play the sound from its line in to line out using sound channel #0
(Spin is too slow for this, so there may be audible distortions but what I can hear now is not so bad for a simple spin loop. This is a task for pasm procedure.).
Edit: this pasm loop works good and the output sound is now clean.
Edit: if you have programmed your DE2-115 with this retromachine and want to play with this simple demo, place attached boot.sys on the sd card. Add a file named "001.dmp" with your favourite sid dump file (50 Hz only). Insert a sd to the de2-115 and boot the retromachine - the sid will start playing and a simple visualisation can be visible on the screen:)
The attached 013.dmp is original Ahle's sidcog-demo dump so it starts with the long silence and then famous two beeps.
You can set playing speed with SW0..2. All off - 50 Hz, SW0 - 100 Hz, SW1 - 150 Hz, SW2 - 200 Hz This is needed when playing some parts of this file.
The SID has 12 dB/oct filters and plays @ 64 kHz
$0-$7FFFF - SRAM, 512kx32bit
$80000-$803FF - pallette - 1024 color registers, $00RRGGBB
$81000-$817FF - font definition. 2048 bytes, 128 characters, 16 bytes for one character. Default is ST mono font; you can redefine it by poking here
$82000-$825FF - sprites definition, 6 sprites, 256 longs each
$83000-$8302a - hardware registers:
$83000 - frame counter
$83001 - display start address; default 0
$83002 - graphics mode
-bits 1,0 - vertical zoom (00-x1,01-x2,10-x4,11-x8)
- bits 3,2 - horizontal zoom/colors (00 - x1, 4 colors; 01 - x2,16 colors, 10 - x4, 256 colors, 11- not valid)
$83003 - border color, 32 bit, 00RRGGBB
$83004 - pallette bank. There are 1024 pallette entries, it gives 4 banks for 256 colors, 64 banks for 16 colors and 256 banks for 4 color modes
$83005 - horizontal pallette selector.
bit 31: selector on
27..20: amount to add to $80004
11:0 - pixel number to switch palette banj
Example: 1_000___0000_0001___0000_0000___0001_0000_0000 will change pallette bank adding #1 when pixel# is 256 makes two areas on the screen with different pallettes
$80006 - display list start address. Bit 31 set=display list active. The DL has 1200 entries, one for one line. The entry bits are:
31- entry active
30- generate interrupt signal
29..22 palette index for the line (and next lines until next active DL entry)
21..18 graphics mode for the line (and next lines until next active DL entry)
17..0 display start address for the line >>1 (the address should be 19 bit and no place left in the entry)
If the address is 11_1111_1111_1111_1111, the field is inactive
$83007 - horizontal scroll right register. Amount is always in the high resolution pixels
$83008 - line length in memory (in 16 bit words, default=224)
$83009..$8300E - sprite 0..5 control
bit 31..30 - y zoom, 00-x1, 01-x2, 10-x4, 11-not valid
29..28 - pallette bank 0..3 select
27..16 y position, always in hires pixels; visible area is from 66 to 1185, lhe position is left upper corner of the sprite
15..14 - x zoom
13..0 - x position, always in hires pixels; visible area is from 160 to 1951 (may be 159 to 1950, it depends on project version)
$8300F - collision register
bit 0 - sprite 0 and 1
bit 1 - sprite 0 and 2
bit 2 - sprite 0 and 3
bit 3 - sprite 0 and 4
bit 4 - sprite 0 and 5
bit 5 - sprite 1 and 2
bit 6 - sprite 1 and 3
bit 7 - sprite 1 and 4
bit 8 - sprite 1 and 5
bit 9 - sprite 2 and 3
bit 10 - sprite 2 and 4
bit 11 - sprite 2 and 5
bit 12 - sprite 3 and 4
bit 13 - sprite 3 and 5
bit 14 - sprite 4 and 5
bits 15..20 - sprite 0..5 and playfield (from 0.97b)
$83010..$83013 - synth 0..3 output registers. When these synths are not working, you can set the value of these registers from the Propeller (SIDcog, etc.)
$83014..$83017 - synth 0..3 frequency
$83018- $8301B - synth 0..3 sample start address
$8300C-$8300F - synth 0..3 sample length (in longs). If bit 31 set, "one shot", the synth channel stops when reached sample end (from 0.97a)
$83020-$83023 - synth 0..3 volume. Volume 0 - the synth channel is off and you can use its output register to output the sound from the Propeller
The synth samples has to be stereo, 16 bit signed - one long=one stereo sample. The volume has to be in range 0-$7FFF - bits 30..16 left, 14..0 right
$83024 - DE2-115 leds. Bits 31..24 - green leds 7..0; 18 - LEDG8, 17..0 - LEDR
$83025 - HEX3..0; 8 bits for segment
$83026 - HEX7..4
$83027 - SW (bits 17..0) and KEYs (bits 31..28)
$83028 - COG LEDs input
$83029 - if bit 0 of this register is 0 then LEDGs will display COG LED state, else LEDG can be programmed with port $83024
$8302A - (from v.0.97 hardware) sound input register dedicated for SIDCog sample output. without need to switch off synths.
$8302B - (from v.0.97b hardware) - playfield priority color number. If the color is higher than this, the sprite will hide under the playfield
$8302C - (from v.0.97b hardware) - playfield collision color number. If the playfield pixel color is higher than this, the sprite will collide with a playfield pixel setting 1 in the collision register
$8302D - (from 0.98) - amount to shift data left (if bit 31==1) or right before writing
$8302E - (from 0.98) - place for bits shifted out to use in the next write. This is RW register; you can set these bits with the Propeller too
$8302F - (from 0.98) - amount to add to R/W address before reading/writing. This enables easier double/multi buffering without making changes in graphics procedures.
$84000 - $840FF - audio buffer. UPDATE: from version 0.97a $84000-$843FF
$8E000 - read only - current soundchip ADC sample
$83F00-$83F0C - VGA timing registers
$8F000 - left border start, default 96
$8F001 - active display start -1, default 159
$8F002 - right border start-1, default 1953
$8F003 - horizontal front porch start, default 2016
$8F004 - horizontal sync start, default 2064
$8F005 - horizontal back porch start, default 2080
$8F006 - upper border start, default 25
$8F007 - active display start, default 65
$8F008 - lower border start, default 1185
$8F009 - vertical front porch start, default 1225
$8F00A - vertical sync start, default 1228
$8F00B - vertical back porch start, default 1234
$8F00C, bits 0..1 - sync polarity, horizontal bit 0, vertical bit 1
$1000000-$1FFFFFF - reserved for future I/O space
$2000000-$3FFFFFF - SDRAM, 128 MB, 32Mx32 bit
End of memory map
To write a long to the memory:
To read a long from the memory
Propeller pin map
P0 - vertical blank
P1 - horizontal blank
P2 - display list interrupt
P3 - read data ready
P4 - audio buffer flag; 0: you can write to upper half of the buffer ($84080-$840FF); 1: you can write to lower half of the buffer ($84000-$8407F)
P5 - not connected
P6 - sound chip interrupt (you have to get ADC sample and put DAC sample when 1)
P7 - not connected
P8..P17 - connected to GPIO8..GPIO17
P18 - I2C_SCLK
P19 - I2C_SDAT
P20 - SD_DAT0
P21 - SD_CLK
P22 - SD_CMD
P23 - SD_DAT3
P24 - PS2_CLK
P25 - PS2_DAT
P26 - PS2_CLK2
P27 - PS2_DAT2
P28..29 - not connected
P30..P31 - connected to GPIO for PropPlug
It would be interesting to know what would be required besides a real Prop 2 when it ships to support this.