├── README.md └── blink ├── .gitignore ├── Makefile ├── blink.v ├── chip.v ├── readme.md └── upduino_v2.pcf /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Upduino Notes 3 | 4 | * Lattice ICE40UP5K 5 | 6 | * [Datasheet](http://www.latticesemi.com/-/media/LatticeSemi/Documents/DataSheets/iCE/iCE40-UltraPlus-Family-Data-Sheet.ashx) 7 | 8 | * [Cell Library](http://www.latticesemi.com/~/media/LatticeSemi/Documents/TechnicalBriefs/SBTICETechnologyLibrary201608.pdf) 9 | 10 | * Built-in I2C and SPI controllers (2 each) 11 | 12 | * [iCE40 SPI/I2C Hardened IP Usage Guide](http://www.latticesemi.com/view_document?document_id=50480) 13 | * [Advanced iCE40 SPI/I2C Hardened IP Usage Guide](http://www.latticesemi.com/view_document?document_id=50117) 14 | 15 | * SPI Flash N25Q032A13ESC40F-ND 16 | 17 | * [Datasheet](https://www.micron.com/products/nor-flash/serial-nor-flash/part-catalog/n25q032a13esc40f) 18 | * 32Mb (4MB), 3v, 4B sector erase, 108 MHz 19 | * 104090 bytes used for bitstream, the rest can be used for applications 20 | 21 | * 12MHz OSC_OUT (generated by FT232HQ) goes to JP8. Can be used as reference accurate reference by FPGA. 22 | 23 | 24 | 25 | # Experiments with an Upduino v2 26 | 27 | See ./blink director for a minimal design with a blinking LED. 28 | 29 | 30 | -------------------------------------------------------------------------------- /blink/.gitignore: -------------------------------------------------------------------------------- 1 | *.asc 2 | *.bin 3 | *.json 4 | -------------------------------------------------------------------------------- /blink/Makefile: -------------------------------------------------------------------------------- 1 | 2 | chip.bin: chip.asc 3 | icepack chip.asc chip.bin 4 | 5 | chip.asc: chip.json upduino_v2.pcf 6 | nextpnr-ice40 --up5k --package sg48 --json chip.json --pcf upduino_v2.pcf --asc chip.asc # run place and route 7 | 8 | chip.json: chip.v blink.v 9 | yosys -q -p "synth_ice40 -json chip.json" chip.v blink.v 10 | 11 | .PHONY: flash 12 | flash: 13 | iceprog chip.bin 14 | 15 | .PHONY: clean 16 | clean: 17 | $(RM) -f chip.json chip.asc chip.bin 18 | -------------------------------------------------------------------------------- /blink/blink.v: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * * 3 | * Copyright 2016 myStorm Copyright and related * 4 | * rights are licensed under the Solderpad Hardware License, Version 0.51 * 5 | * (the “License”); you may not use this file except in compliance with * 6 | * the License. You may obtain a copy of the License at * 7 | * http://solderpad.org/licenses/SHL-0.51. Unless required by applicable * 8 | * law or agreed to in writing, software, hardware and materials * 9 | * distributed under this License is distributed on an “AS IS” BASIS, * 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * 11 | * implied. See the License for the specific language governing * 12 | * permissions and limitations under the License. * 13 | * * 14 | ******************************************************************************/ 15 | 16 | module blink(input clk, input rst, output led); 17 | 18 | reg [24:0] count; 19 | 20 | assign led = count[24]; 21 | 22 | always @(posedge clk) 23 | if(rst) 24 | count = 0; 25 | else 26 | count <= count + 1; 27 | 28 | endmodule 29 | -------------------------------------------------------------------------------- /blink/chip.v: -------------------------------------------------------------------------------- 1 | 2 | module chip ( 3 | output LED_R_, 4 | output LED_G_, 5 | output LED_B_ 6 | ); 7 | 8 | wire clk, led; 9 | 10 | SB_HFOSC u_hfosc ( 11 | .CLKHFPU(1'b1), 12 | .CLKHFEN(1'b1), 13 | .CLKHF(clk) 14 | ); 15 | 16 | blink my_blink ( 17 | .clk(clk), 18 | .rst(0), 19 | .led(led) 20 | ); 21 | 22 | assign LED_R_ = ~led; 23 | assign LED_G_ = ~led; 24 | assign LED_B_ = ~led; 25 | 26 | endmodule 27 | -------------------------------------------------------------------------------- /blink/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Blink 3 | 4 | This 'Hello World' equivalent simply blinks the RGB LED. They're high intensity LEDs that will almost 5 | burn your eyeballs if you stare at it long enough. 6 | 7 | *Check out the code in [this issue](https://github.com/tomverbeure/upduino/issues/3). It shows how you 8 | can reduce the current of the LED drivers.* 9 | 10 | # Requirements 11 | 12 | * Project IceStorm 13 | 14 | Install this first. 15 | 16 | * Yosys 17 | 18 | Synthesis tool. 19 | 20 | * nextpnr 21 | 22 | Place & Route tool 23 | 24 | # Usage 25 | 26 | * ```make``` 27 | 28 | Builds ```chip.bin``` bitstream 29 | 30 | * ```sudo make flash``` 31 | 32 | Program the bitstream to the device. 33 | 34 | Expected output during flashing: 35 | 36 | ``` 37 | ubuntu@ubuntu-xenial:~/projects/upduino$ sudo make flash 38 | iceprog chip.bin 39 | init.. 40 | cdone: high 41 | reset.. 42 | cdone: high 43 | flash ID: 0xEF 0x40 0x16 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 44 | file size: 104090 45 | erase 64kB sector at 0x000000.. 46 | erase 64kB sector at 0x010000.. 47 | programming.. 48 | reading.. 49 | VERIFY OK 50 | cdone: high 51 | Bye. 52 | ``` 53 | 54 | -------------------------------------------------------------------------------- /blink/upduino_v2.pcf: -------------------------------------------------------------------------------- 1 | set_io LED_R_ 41 2 | set_io LED_B_ 40 3 | set_io LED_G_ 39 4 | 5 | --------------------------------------------------------------------------------