Shop OBEX P1 Docs P2 Docs Learn Events
A DE2-115 Propeller demo board project - now programmable with the Propplug — Parallax Forums

A DE2-115 Propeller demo board project - now programmable with the Propplug

pik33pik33 Posts: 2,366
edited 2014-08-20 02:45 in Propeller 1
Edit - 2014.08.20: Version 0.02 is ready. Now, as I have a PropPlug, this is PropPlug programmable.

There are 3 files uploaded:

- a Quartus project
- a Propeller program (wav and sid player). This has to be compiled by BST
- binary files: pof and sof to program the DE2-115 and bin file to program the Propeller

Please test if this works.

The Propeller works @ 130 MHz.


Let it start in its own topic.

What I have now is:

- a DE2-115 :)
- a modified Propeller code working up to 140 MHz, with dirb, outb and inb enabled as independent ports, which can be programmed via DE2-115 RS232 port. After I receive a propplug (thanks again) I will rewrite this to make the system programmable via Propplug too.
- vga output working, SD card working (at <120 MHz), PS2 input working. My Propplay 0.16 starts, displays the picture on the monitor, connects to the SD card and I think it can play if only I can connect P10,P11 to the amplifier.

- some - self made or reworked from Terasic sources - modules intended to work with nios2/qsys in different stage of code completion:

-- vga frame buffer, 800x600x24 using SRAM. Slow. :( Used this as a presentation machine at the university :)
-- vga text mode frame buffer, 1440x900, using Atari ST 8x16 font. A pasm code (Nostalgia VGA driver) was used as the source for rewritting in verilog.
-- sdhc (yes, sdhc only) controller which can init the card and read/write a sector into the buffer. It is sdhc only because it hasn't a code which detects older sd cards and address them in byte adressing mode. I haven't any card <4GB to test it.
-- sound chip controller
-- keyboard controller
-- sdram driver

- some Terasic code which can be easily adopted:

-- mouse controller - needs an Y-type PS2 cable
-- IRDA controller

What I want to have:

- a DE2-115 Propeller demo board, configurable with SWx, so we can (1) use a demoboard compatible programs with it (2) after switching some SW use extended possibilities of DE2-115 Propeller to have more fun.

What I am working now at is:

- to make a sound chip controller to work with the Propeller, so I can replace a sound output driver with this and hear the sound - done

What I want to do when I can hear the sound:

- connect a verilog sdhc controller to the Propeller to allow it run @140 MHz
- make a DE2-115 Propeller self bootable. Possible solutions are:
--- add an eeprom connected to GPIO
--- write an eeprom simulator which can use DE2-115 flash memory or will simply boot from something preloaded into fpga
--- modify the boot code so the Propeller will load its code from flash/sd card/something else

I don't know at this time which solution will be better.

The first complete project I want to put here will be a version with working sound and runnable Propplay so it can play SIDs and WAVs from SD.

Comments

  • pik33pik33 Posts: 2,366
    edited 2014-08-16 06:12
    First procedure which plays the sound from sd. with the fpga sound controller. Yes, it is that simple now but Spin is too slow :( Buffer underrun, pasm needed
    i:=fat.FATEngineStart(_SD_DO, _SD_CLK, _SD_DI, _SD_CS, _SD_WP, _SD_CD, -1, -1, -1)
    i:=fat.mountpartition(0)
    l:=fat.openfile(string("002.wav"),"R")
    
    repeat
      if inb[0]==1
        l:=fat.readdata(@buf,1024)
        repeat i from 0 to 127
          dirb:=i
          outb:=buf[i]
          dirb[8]:=1
      if inb[1]==1
        repeat i from 128 to 255
          dirb:=i
          outb:=buf[i]
          dirb[8]:=1
    until l<>1024
    fat.closefile
    
  • Cluso99Cluso99 Posts: 18,069
    edited 2014-08-16 07:33
    Were you aware that Ale has written a number of SIDCOG programs that simulate some of the old Commodore sound chips.
  • pik33pik33 Posts: 2,366
    edited 2014-08-16 07:53
    I have a player ready.

    http://forums.parallax.com/showthread.php/140767-A-new-topic-for-vga-(not-only)-sid-player?p=1113690&viewfull=1#post1113690

    This player contains a sidcog as an object and plays sids and wavs. It is made for the Propeller demo board. The keyboard, sd and vga is working now with a de2-115. All what was left to run it fully is to write a new sound driver and replace my existing ncowav with this Then we will have a sid/wav player running on de2-115. The sound hardware is working now, it only needs a procedure in pasm, spin is simply too slow to feed the samples @ 44100 Hz

    If you want to try this player with a real Propeller demo board, compile it with bst or remove a demo method from the vga driver, or it doesn't fit in 32k.
  • Cluso99Cluso99 Posts: 18,069
    edited 2014-08-16 08:57
    Nice job! I was not aware of what you have done with audio.
  • Bill HenningBill Henning Posts: 6,445
    edited 2014-08-16 09:09
    Looks great!
  • pik33pik33 Posts: 2,366
    edited 2014-08-17 03:48
    Wav play working. To do before 0.01 release: make a SID play.
  • pik33pik33 Posts: 2,366
    edited 2014-08-17 06:40
    And this is what the working sound driver for wav playing looks like. Using extended portb to communicate with 256x32 sample buffer.
    {{
    Sound driver for DE2-115 sound chip with the hardware controlled buffer
    v.0.01 - 20140817
    inb [1..0] - lower/upper half of the buffer is empty
    dirb[7..0] - buffer address
    dirb[8] - write strobe
    outb[31..0] - sample data
    }}
    
    
    VAR
    
      long cog
      long buf[512]
      long bufnum
    
    
    pub getbuf
    return @buf
    
    pub getbufnum
    return @bufnum
    
    
    PUB start
    
    longfill(@buf,0,512)
    bufptr:=@buf
    stop
    
    cog:=1+cognew(@init, @bufnum)
    return cog
    
    
    PUB stop
    
    if cog>0
      cogstop(cog-1)
    cog := 0
    
    
    DAT
                            org     0                         'initialization
    
    init
                            mov     bufptr2,par
    
    
    loop                    mov     a1,inb
                            and     a1,#1
                            cmp     a1,#1           wz
                  if_nz     jmp     #loop                   ' lower half of the buffer is empty
    
                            mov     a2,#0
    
    
    p101                    mov     ptr,bufptr               ' compute pointer to sample
                            add     ptr,bufcnt
                            rdlong  lsample,ptr
                            add     bufcnt,#4
                            and     bufcnt,bufmask
                            wrlong  bufcnt,bufptr2           ' write actual sample number for main program
    
                            mov     dirb,a2
                            mov     outb,lsample
                            or      dirb,#256
                            add     a2,#1
                            cmp     a2,#128         wz
                  if_nz     jmp     #p101
    
    p102                    mov     a1,inb
                            and     a1,#2
                            cmp     a1,#2           wz
                  if_nz     jmp     #p102                    ' upper half of the buffer is empty
    
                            mov     a2,#0
    
    p103                    mov     ptr,bufptr               ' compute pointer to sample
                            add     ptr,bufcnt
                            rdlong  lsample,ptr
                            add     bufcnt,#4
                            and     bufcnt,bufmask
                            wrlong  bufcnt,bufptr2           ' write actual sample number for main program
    
                            mov     a1,a2
                            add     a1,#128
                            mov     dirb,a1
                            mov     outb,lsample
                            or      dirb,#256
                            add     a2,#1
                            cmp     a2,#128         wz
                  if_nz     jmp     #p103
    
                            jmp     #loop
    
    
    bufmask                 long    00_0000_0000_0000_0000_0111_1111_1111
    bufptr                  long    0
    bufptr2                 long    0
    bufcnt                  long    0
    
    lsample                 res 1
    ptr                     res 1
    a1                      res 1
    a2                      res 1
    
                            fit     496
    
    {{
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //                                                  TERMS OF USE: MIT License
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
    // files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
    // modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
    // Software is furnished to do so, subject to the following conditions:
    //
    // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
    // Software.
    //
    // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
    // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
    // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
    // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    
  • pik33pik33 Posts: 2,366
    edited 2014-08-17 08:43
    0.01 works, so, as promised, I uploaded the project. As is now, without any cleaning. The files are attached to the first post.The bigger file is the Quartus project. The smaller is SID/WAV player.
  • pik33pik33 Posts: 2,366
    edited 2014-08-17 09:51
    Added some lowpass filtering to sidcog driver to reduce aliasing. Not sure if this helped. True 32->44.1 kHz resampling procedure is needed, but not now :)

    Edit: seems to be better without this filter...
    {{
    FPGA sound driver for sidcog v0.02-20140817
    Change from 0.01: some low pass filtering added
    Piotr Kardasz, pik33@o2.pl
    MIT license, see bottom
    }}
    
    
    
    VAR
    
    '  long bufnum
      long cog
      long bufnum
    
    
    pub getbufnum
    return @bufnum
    
    
    PUB start (addr)
    
    
    
    bufptr:=addr
    
    stop
    cog:=1+cognew(@init, @bufnum)
    return cog
      
    
    PUB stop
    
    if cog>0
      cogstop(cog-1)
    cog := 0
      
    
    DAT
                            org     0                         'initialization
    
    init                    mov     bufptr2,par
                            mov     a2,#128
    
    p102                    mov     a1,inb                 ' wait for upper buffer empty
                            and     a1,#2
                            cmp     a1,#2           wz
                  if_nz     jmp     #p102                  '
    
    p11                     mov     a1, inb                'wait for 0 on inb[2] - synchro
                            and     a1, #4
                            cmp     a1,#0           wz
                  if_nz     jmp     #p11
    
    p1                      mov     a1, inb                'wait for 1 on inb[2] - synchro
                            and     a1, #4
                            cmp     a1,#4           wz
                  if_nz     jmp     #p1
    
                            rdlong  lsample,bufptr
                            sar     lsample,#17
                            mov     rsample,lsample
                            add     lsample,filter
                            mov     filter,rsample
                            sar     filter,#1
                            mov     rsample, lsample
                            shl     rsample,#1
                            add     lsample, rsample
                            shl     rsample,#1
                            add     lsample, rsample
                            sar     lsample,#3
                            mov     rsample,lsample
                            shl     rsample, #16
                            add     lsample,rsample
    
                            mov     dirb,a2
                            mov     outb,lsample
                            or      dirb,#256
                            add     a2,#1
                            and     a2,#255
                            jmp     #p11
    
    bufptr                  long    0
    bufptr2                 long    0
    
    lsample                 res 1
    rsample                 res 1
    filter                  res 1
    
    a1                      res 1
    a2 res 1
                            fit     496
    
    {{
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //                                                  TERMS OF USE: MIT License
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
    // files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
    // modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
    // Software is furnished to do so, subject to the following conditions:
    //
    // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
    // Software.
    //
    // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
    // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
    // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
    // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    }}
    
  • pik33pik33 Posts: 2,366
    edited 2014-08-18 03:33
    It seems I need some more rest.
    What I published yesterday was one of earlyr version of the project. It cannot run with attached player. Maybe it cannot run at all.
    I will find and upload the proper quartus project as soon as I return home.
  • pik33pik33 Posts: 2,366
    edited 2014-08-20 02:45
    Version 0.02 is ready.

    Changes:
    - programmable via proplug instead rs232. The propplug has to be attached at the same pins as in the original Propeller DE2--115 design.
    - the Propeller run @ 130 MHz
    - the player now plays all files from the directory without any assistance
    - patched some bugs in the player


    I attached a bin archive with precompiled files.

    I hope there was proper and working version uploaded (i will test this now). Please try if this works. The files are attached to the first post.
Sign In or Register to comment.