Jack Gassett Posted February 8, 2013 Report Share Posted February 8, 2013 Ok, I'm going to start building a SOC for the LogicStart MegaWing, based on an existing VHDL design and sample code that Alvie put together. The goal is to do the whole thing with the schematic editor and make videos of the whole process. Here is step one, adding the 7 segment display. Part 1a - Screencast of synthesizing the design.http://youtu.be/PxIkU1qSjcw Part 1b - Video of the design running on the LogicStart MegaWing.http://youtu.be/1cB2HrO3RdE The SOC code is checked into Github. The Arduino sketch is:#define SEVENSEGBASE IO_SLOT(9)#define LS_LED0 14#define LS_LED1 15#define LS_LED2 16#define LS_LED3 17#define LS_LED4 18#define LS_LED5 19#define LS_LED6 20#define LS_LED7 21static inline void LS_setAllLeds(unsigned values){ values &= 0xFF; unsigned old = GPIODATA(0); old &= ~((0xFF)<<LS_LED0); old |= values<<LS_LED0; GPIODATA(0) = old;}void setup(){ LS_setAllLeds(0); Serial.begin(115200);}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];}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);}int cnt = 0;void loop(){ set_sevenseg_value(cnt,1); delay(100); cnt++;} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.