Jack Gassett

Building complete Papilio SOC for LogicStart MegaWing

Recommended Posts

Ok,

 

So I reworked the Papilio SOC library so we could build an entire SOC for the LogicStart MegaWing. I ran into a roadblock with getting GPIO to work with modified ucf files, it was really cumbersome and put a lot of burden on someone who is just starting out with FPGA's. I thought about it a couple days and came up with a way where you can just swap out a symbol for whatever type of hardware you have connected to the Papilio. Here is a video of the reworked system in action!

 

 

I think this is all coming together nicely and the next steps are to come up with an appropriate name and start writing Arduino libraries and writing an ebook. I'm thinking I will start the ebook and work on one chapter at a time, each chapter will correspond to a peripheral core and I will work on the library for that core as I write the chapter.

 

I can use some feedback for what to call this. Initially I thought it would be Papilio SOC but I worry that casual users, who are the target for this system, won't be familiar with the term System on Chip. So I'm thinking along the lines of:

  • DrawDuino
  • Draw-a-duino
  • DrawADuino

 

Any thoughts or better names?

 

 

The code for the system as it stands is on github.

 

Sketch:

#include "LogicStart.h"#include <SmallFS.h>#include "VGAZX.h"#include "fixedpoint.h"#include "cbuffer.h"#include "ptplay.h"#define USPIDATA16 *((&USPIDATA)+2)#define SEVENSEGBASE IO_SLOT(9)#define SIGMADELTABASE IO_SLOT(5)static SmallFSFile modfile;static char buf[128];static pt_mod_s * mod;static CircularBuffer<unsigned,7> audioBuffer;extern pt_mod_s *pt_init_smallfs(SmallFSFile &file);static int timeout=0;int ledPins[] = {   40, 41, 42, 43, 44, 45, 45, 47  };       // an array of pin numbers to which LEDs are attachedint ledCount = 8;           // the number of pins (i.e. the length of the array)int buttonPins[] = {   32, 33, 34, 35, 36, 37, 38, 39 };       // an array of pin numbers to which Buttons are attachedint buttonCount = 24;           // the number of pins (i.e. the length of the array)            int buttonState = 0;         // variable for reading the pushbutton statusint thisPin;int ledState = LOW;   void setup(){        // initialize the LED pins as an output:        for (int thisPin = 0; thisPin < ledCount; thisPin++)  {          pinMode(ledPins[thisPin], OUTPUT);          }              // initialize the pushbutton pin as an input:        for (int thisPin = 0; thisPin < ledCount; thisPin++)  {          pinMode(buttonPins[thisPin], INPUT);              }            	VGAZX.begin(15);	SmallFS.begin();	SmallFSFile f = SmallFS.open("scr1");	if (f.valid())		VGAZX.loadscr(f);	Serial.begin(115200);	modfile = SmallFS.open("music.mod");	mod = pt_init_smallfs(modfile);	SIGMADELTACTL=0x3;	TMR0CTL = 0;	TMR0CNT = 0;	TMR0CMP = ((CLK_FREQ/2) / FREQ )- 1;	TMR0CTL = _BV(TCTLENA)|_BV(TCTLCCM)|_BV(TCTLDIR)|		_BV(TCTLCP0) | _BV(TCTLIEN);	INTRMASK = BIT(INTRLINE_TIMER0); // Enable Timer0 interrupt	USPICTL=BIT(SPICPOL)|BIT(SPISRE)|BIT(SPIEN)|BIT(SPIBLOCK)|BIT(SPICP2)|BIT(SPICP0);	INTRCTL=1;}static unsigned char table7seg[16] ={	0x3F, //00111111, 0	0x06, //00000110, 1	0x5B, //01011011  2	0x4F, //01001111  3	0x66, //01100110  4	0x6D, //01101101  5	0x7D, //01111101  6	0x07, //00000111  7	0x7F, //01111111  8	0x6F, //01101111  9	0x00,	0x00,	0x00,	0x00,	0x00,	0x00};static int int_to_7seg(int v){	return table7seg[v%16];}int cnt = 0;int ledcnt = 0;int extcnt = 0;int mode = 0;unsigned channel=0;static void set_sevenseg_value(int v, unsigned bindots){	REGISTER( SEVENSEGBASE, 7 ) = int_to_7seg(v%10) | (bindots&8 ? 0x80:0x00);	REGISTER( SEVENSEGBASE, 6 ) = int_to_7seg((v/10)%10) | (bindots&4 ? 0x80:0x00);	REGISTER( SEVENSEGBASE, 5 ) = int_to_7seg((v/100)%10) | (bindots&2 ? 0x80:0x00);	REGISTER( SEVENSEGBASE, 4 ) = int_to_7seg((v/1000)%10) | (bindots&1 ? 0x80:0x00);}static void test(){	REGISTER( SEVENSEGBASE, 7 ) = int_to_7seg(channel);	REGISTER( SEVENSEGBASE, 6 ) = 0;	REGISTER( SEVENSEGBASE, 5 ) = SEGF|SEGE|SEGB|SEGC|SEGG;	REGISTER( SEVENSEGBASE, 4 ) = SEGA|SEGF|SEGE|SEGD;}static void hello(){	REGISTER( SEVENSEGBASE, 7 ) = SEGA|SEGF|SEGB|SEGE|SEGC|SEGD;	REGISTER( SEVENSEGBASE, 6 ) = SEGF|SEGE|SEGD;	REGISTER( SEVENSEGBASE, 5 ) = SEGA|SEGF|SEGE|SEGD|SEGG;	REGISTER( SEVENSEGBASE, 4 ) = SEGF|SEGE|SEGB|SEGC|SEGG;}void loop(){               if (extcnt == 100) {        //ledState = !ledState;          for (int thisPin = 0; thisPin < buttonCount; thisPin++)  {          digitalWrite(ledPins[thisPin], digitalRead(buttonPins[thisPin]));         }                     set_sevenseg_value(cnt,1);           cnt++;             extcnt = 0;               }        extcnt++;	int i;	pt_render(modfile, mod, buf, NULL, 2, 16 /* Samples */, 1, 16, 1);	for (i=0;i<32;i+=2) {		unsigned v = buf[i];		v += buf[i+1]<<8;		//v += buf[i]<<16;		//v += buf[i+1]<<24;		v+=0x8000;		while (audioBuffer.isFull());		audioBuffer.push(v);	}}void _zpu_interrupt(){	// Play	if (audioBuffer.hasData()) {		unsigned v = audioBuffer.pop();		SIGMADELTADATA = v;	}	if (timeout!=0)		timeout--;	TMR0CTL &= ~(BIT(TCTLIF));  }

Share this post


Link to post
Share on other sites

Stick with the butterfly metaphor / brand. It works.

 

Papilio Chrysalis

-----------------------------------

Engineer your own custom CPU

 

Or something equally dramatic :-)

Share this post


Link to post
Share on other sites

+1 for Papilio blocks.

 

This name actually tells you something about the function of the tool, rather than tacking the "duino" moniker on yet another product.  

Share this post


Link to post
Share on other sites

I have downloaded the SoC project, was able to modify the schematic and add uart to wb slot 5.  Created a bit file loaded it to the Papilio One(500).

 

Using Zpuino Arduino 0100-Z-windows created simple blink test sketch. Select the correct com port, Board=ZPUnio on Papilio One(500), click on upload.

 

Get initial message: Binary sketch size: 732 bytes (of a 27648 byte maximum). And Hangs.... let it sit there for 15 minutes. 

 

So I take a step back and started to replicate the example here and I pull the header files from github and I get these errors when verifying the sketch

 

 

SoCLogicWingTest.cpp:120: warning: 'void test()' defined but not used
SoCLogicWingTest.cpp:128: warning: 'void hello()' defined but not used
SoCLogicWingTest.o(.text._Z5setupv+0x4a): In function `.L17':
: undefined reference to `VGAZX'
SoCLogicWingTest.o(.text._Z5setupv+0x50): In function `.L9':
: undefined reference to `VGAZX_class::begin(unsigned int)'
SoCLogicWingTest.o(.text._Z5setupv+0xa2): In function `.L19':
: undefined reference to `pt_init_smallfs(SmallFSFile&)'
SoCLogicWingTest.o(.text._Z5setupv+0xea): In function `.L19':
: undefined reference to `VGAZX_class::loadscr(SmallFSFile&)'
SoCLogicWingTest.o(.text._Z5setupv+0x11b): In function `.L19':
: undefined reference to `pt_init_smallfs(SmallFSFile&)'
SoCLogicWingTest.o(.text._Z4loopv+0x2b): In function `loop()':
: undefined reference to `pt_render'
SoCLogicWingTest.o(.text._Z4loopv+0x167): In function `.L63':
: undefined reference to `pt_render'
collect2: ld returned 1 exit status
make: *** [soCLogicWingTest.elf] Error 1
C:\projects\Tools\arduino-0100-Z-windows\arduino-0100-Z\hardware\tools\zpu\bin\make returned 2
 
Any thoughts?
 

Share this post


Link to post
Share on other sites

Jack,

No worries, that compiled... I have tried several things here, and I ultimately think this is a problem with the zpuino ide... I downloaded the zpuino bit file and loaded it to the board, and tried uploading a blink test and same issue the ide just hangs. Reading some other posts I even tried arduino-0102-windows same issue. 

 

this is all that happens

arduino.jpg

 

The settings I have:

Board=ZPUino on PapilioOne(500)

Com=Com7(USB Serial Converter A)

Share this post


Link to post
Share on other sites

Ah, this is an indication that the ZPUino is not responding properly.

 

Have you loaded the ZPUino bit file you created to SPI Flash? That is the most likely culprit here...

 

If that does not do the trick then start with a known good bit file. Attached is one that I had in my folder for the base Papilio SOC system.

 

Jack.

papilio_soc_base-working.bit

Share this post


Link to post
Share on other sites

Jack, 

I did write to SPI Flash. So I downloaded your bit file, loaded it and tried to load the sketch and still the same result. 

 

 

JTAG chainpos: 0 Device IDCODE = 0x41c22093 Desc: XC3S500E
Using devlist.txt
JTAG chainpos: 0 Device IDCODE = 0x41c22093 Desc: XC3S500E
 
Uploading "C:\Program Files (x86)\Gadget Factory\Papilio Loader\programmer\bscan_spi_xc3s500e.bit". Done.
Programming time 183.0 ms
 
Programming External Flash Memory with "C:\Downloads\papilio_soc_base-working.bit".
Found SST Flash (Pages=2048, Page Size=264 bytes, 4325376 bits).
Erasing    :
Ok
Verifying  :
.....Pass
Programming :
..............Finished Programming
Ok
Verifying  :
.....Pass
Using devlist.txt
Done.
SPI execution time 5948.3 ms
USB transactions: Write 2881 read 2164 retries 0
JTAG chainpos: 0 Device IDCODE = 0x41c22093 Desc: XC3S500E
 
Using devlist.txt
ISC_Done       = 0
ISC_Enabled    = 0
House Cleaning = 1
DONE           = 0

Share this post


Link to post
Share on other sites

Ahhhhh, I should have noticed this before, you are using the first serial port which is used for JTAG programming of the FPGA:

Com=Com7(USB Serial Converter A)

 

The ZPUino uses the second serial port in order to upload its code. So change to the second com port:

Com=Com8(USB Serial Converter B )

 

I think that will solve your problem.

 

Jack.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now