Newbie starting using FPGA - Page 1
Forum section: electronics / general

author: greenstrike
author_rank: Contributor
timestamp: March 10, 2023, 05:38:58 pm
content: Hi to all users!I am newbie using FPGA due last time I used FPGA was more than 20 years ago....I am using MachXO2 (256 and 1200) with Diamond and I can't get running simple led blinking....Board I am using is AX1 from TinyFPGA.On Diamond I have these two files:.lpfCode:BLOCK RESETPATHS;BLOCK ASYNCPATHS;LOCATE COMP "pin1"SITE "13" ;LOCATE COMP "pin2"SITE "14" ;LOCATE COMP "pin3_sn"SITE "16" ;LOCATE COMP "pin4_mosi"SITE "17" ;LOCATE COMP "pin5"SITE "20" ;LOCATE COMP "pin6"SITE "21" ;LOCATE COMP "pin7_done"SITE "23" ;LOCATE COMP "pin8_pgmn"SITE "25" ;LOCATE COMP "pin9_jtgnb"SITE "26" ;LOCATE COMP "pin10_sda"SITE "27" ;LOCATE COMP "pin11_scl"SITE "28" ;LOCATE COMP "pin16"SITE "4" ;LOCATE COMP "pin17"SITE "5" ;LOCATE COMP "pin18_cs"SITE "8" ;LOCATE COMP "pin19_sclk"SITE "9" ;LOCATE COMP "pin20_miso"SITE "10" ;LOCATE COMP "pin21"SITE "11" ;LOCATE COMP "pin22"SITE "12" ;And .v:Code:module TinyFPGA_A1 (inout pin1,inout pin2,inout pin3_sn,inout pin4_mosi,inout pin5,inout pin6,inout pin7_done,inout pin8_pgmn,inout pin9_jtgnb,inout pin10_sda,inout pin11_scl,//inout pin12_tdo,//inout pin13_tdi,//inout pin14_tck,//inout pin15_tms,inout pin16,inout pin17,inout pin18_cs,inout pin19_sclk,inout pin20_miso,inout pin21,inout pin22);// left side of boardassign pin1 = 1'bz;assign pin2 = 1'bz;assign pin3_sn = 1'bz;assign pin4_mosi = 1'bz;assign pin5 = 1'bz;assign pin6 = 1'bz;assign pin7_done = 1'bz;assign pin8_pgmn = 1'bz;assign pin9_jtgnb = 1'bz;assign pin10_sda = 1'bz;assign pin11_scl = 1'bz;// right side of board (terminali usati per programmazione JTAG)//assign pin12_tdo = 1'bz;//assign pin13_tdi = 1'bz;//assign pin14_tck = 1'bz;//assign pin15_tms = 1'bz;assign pin16 = 1'bz;assign pin17 = 1'bz;assign pin18_cs = 1'bz;assign pin19_sclk = 1'bz;assign pin20_miso = 1'bz;assign pin21 = 1'bz;assign pin22 = 1'bz;/************************************//*Clock Generation*//************************************/// prima di tutto devo inizializzare la sorgente del clock: imposto il clock interno a 2.08MHz (il valore più basso disponibile)wire clk;//Crystal Oscillator//assignxout = ~xin;//On-Chip Oscillator (utilizzo l'oscillatore interno con frequenza minima a partire da 2.08 MHz//defparam OSCH_inst.NOM_FREQ = "2.08";//OSCH OSCH_inst (.OSC(clk), .SEDSTDBY(), .STDBY(1'b0));OSCH #(.NOM_FREQ("2.08")//.NOM_FREQ("38.00")// 38 MHz) internal_oscillator_inst (.STDBY(1'b0),.OSC(clk));reg [23:0] led_timer=0;// registro a 24 bitalways @(posedge clk) beginled_timer <= led_timer + 1;endassign pin1 = led_timer;assign pin9_jtgnb = led_timer;assign pin10_sda = led_timer;assign pin11_scl = led_timer;endmoduleI don't know why not working even if I don't get errors from Diamond....Just another doubt: timer is declared as 24 bit register, can I set it up to 64 bits or are there some limits?Thanks.

author: ataradov
author_rank: Super Contributor
timestamp: March 11, 2023, 01:51:42 am
content: Diamond generates a ton of messages in the logs. They are not necessarily errors, but you need to read them and see if something looks suspicious or does not sound right.One thing I see that may be a problem is that you are not specifying IOBUFs for the pins. I don't know if it will add some default ones, or just ignore them. Here is how it typically looks in the LPF file:Code:LOCATE COMP "ifclk_i" SITE "88";IOBUF PORT "ifclk_i" IO_TYPE=LVCMOS33;The next step is to use external clock just to eliminate internal oscillator from guessing. Or output the clock on the pin and see if you get anything.The only limit to the counter size is device resources and maximum operating frequency. And you also need to add clock constant to the LPF file.

author: SiliconWizard
author_rank: Super Contributor
timestamp: March 11, 2023, 01:59:32 am
content: If all your IOs are the same type, you can just use:Code:IOBUF ALLPORTS IO_TYPE=LVCMOS33;No need to declare one for each IO.Dunno if that's strictly required though, it's likely the default, but worth a try.Certainly I would look at warnings to see if there's anything fishy.