RISC-V SOC on an ICE FPGA: what peripherals are available? - Page 1
Forum section: electronics / general

author: cdwijs
author_rank: Regular Contributor
timestamp: May 15, 2019, 08:57:47 am
content: Hi All,I routinely use Arduino's based on AtMega microcontrollers to measure and control stuff. It's a nice platform, but it has it's limitations:-Not enough instances of a peripheral. For some project I need more than one i2c port, to read out multiple sensors that are not available with unique addresses. For other projects, I would like to have more than one serial port.-Missing peripheral. I would like to have a module that handles the timing and buffering for sending and receiving Manchester encoded data.-Flexibility. Hardware peripherals are tied to specific pins, designing the PCB would be easier when pins can be moved around,Therefore I would like to use a FPGA, so I can define the CPU and the peripherals I need, and have more flexibility.For the FPGA:There's the open source toolchain "IceStorm" that can be used to program Lattice ICE FPGA's.https://en.wikipedia.org/wiki/ICE_(FPGA)#Open_sourcehttps://web.archive.org/web/20160304202757/http://www.clifford.at/icestorm/For the CPU:there's an implementation of an RISC-V CPU called "picorv32" running in an ICE FPGA:https://github.com/cliffordwolf/picorv32And here the picorv32 is running on the tinyFPGA BX board:https://gojimmypi.blogspot.com/2019/01/risc-v-on-fpga-tinyfpga-via-wsl.htmlFor the peripherals:Picosoc provides an UART, RAM and SPI controller:https://github.com/cliffordwolf/picorv32/tree/master/picosocThis projects adds a driver for the WS2812 RGB LED (neopixel):https://blog.adacore.com/ada-on-fpgas-with-picorv32Do you know more projects that have made peripherals?Cheers,Cedric

author: JPortici
author_rank: Super Contributor
timestamp: May 15, 2019, 09:26:03 am
content: How about using a microcontroller that's not from the stone ages?-a dsPIC33CK has three hardware I2C-There is extensive remapping capability (not all pins, but plenty of pins)-The CLC can help you with manchester encoding and decoding (there are app notes for that)-The CLC can help you create a DMA-Enabled driver for WS2412 LEDs that needs very little CPU time (https://www.microchip.com/forums/m1091899.aspx) no idea how different it is to WS2812 but you get the idea-FAST core-FAST PWM and ADC, the 12bit ADC is 11.something effective bits-doesn't cost too muchStill can't find a really fgood reason to go with FPGA

author: ataradov
author_rank: Super Contributor
timestamp: May 15, 2019, 05:16:15 pm
content: I agree. All of the things you list are addressed in almost any modern MCU.FPGA thing is much bigger step. So if you are afraid of complexity of the newer MCUs, then you should be REALLY afraid of going with FPGAs.Also, those ICE40 FPGAa are very slow.

author: iMo
author_rank: Super Contributor
timestamp: May 15, 2019, 06:14:57 pm
content: There is only one reason to go with the FPGA I would consider pretty important and challenging - to become an FPGA expert. Long way to go, however..

author: woofy
author_rank: Frequent Contributor
timestamp: May 16, 2019, 09:05:34 am
content: Quote from: ataradov on May 15, 2019, 05:16:15 pmRelative to other FPGA's, yes I agree.However to put some perspective on that, the HX can run RISC V at 50MHz and my own 16-bit processor at 100MIPs.

author: ataradov
author_rank: Super Contributor
timestamp: May 16, 2019, 09:48:42 pm
content: Quote from: woofy on May 16, 2019, 09:05:34 amYes, I stand corrected. I mentally blocked HX series, since high density devices are only available in BGA and WLCSP packages.

author: MorgothCreator
author_rank: Contributor
timestamp: August 31, 2019, 11:24:00 am
content: Hey, I have developed an parametrized risc-five micro core with a parametrized interrupt controller, i have done twi, spi, uart, rtc, pio, paralel lcd, paralel lcd to hdmi adapter and a little gfx 2d accelerator.The example projects are for xilinx and lattice.The core eat around 850 lut’s on both platforms, the speed is about 100 mhz on xilinx artix and around 40 mhz on MachXO3LF, but may vary with implementation.The instruction pen mhz is around 0.8 M instructions per mhzThis core is a very very simple to wire in to the system.Is open source at:https://git.morgothdisk.com/VERILOG

author: Morgan127
author_rank: Contributor
timestamp: August 31, 2019, 02:15:14 pm
content: Instant SoCnow supports Lattice FPGAs.So for instance if you want three I2C you just add three I2C object in the C++ code and the compiler builds a system withRISC-V processor, memories and the peripherals you added.An example using three I2C and 2 UART Tx:Code:#include "fc_io.h"#include "fc_system.h"int main(){//% hw_beginFC_IO_Clk clk(100); // 100 MHzFC_IO_I2C iic_1(400000); // 400 kHzFC_IO_I2C iic_2(400000);FC_IO_I2C iic_3(400000);FC_IO_UART_TX uart_tx_1(115200);FC_IO_UART_TX uart_tx_2(9600);//% hw_enduart_tx_1 << "Hello world using UART 1";uart_tx_2 << "Hello world using UART 2";for(;;){// Add some c++ code...}}This will result in a VHDL file with the following port:Code:entity test isport(clk : in std_logic;iic_1_SCL : inout std_logic;iic_1_SDA : inout std_logic;iic_2_SCL : inout std_logic;iic_2_SDA : inout std_logic;iic_3_SCL : inout std_logic;iic_3_SDA : inout std_logic;uart_tx_1 : out std_logic;uart_tx_2 : out std_logic);end entity;

author: laugensalm
author_rank: Regular Contributor
timestamp: August 31, 2019, 03:24:41 pm
content: If you're looking for standard peripherals like minimal UART, SPI, I2C etc. and building or simulating a uC/SoC in VHDL (only!), you might check out this one:https://hub.docker.com/r/hackfin/masocist/Currently, only neo430 (msp430 clone) and ZPU/ZPUng is supported, they tend to fit well into small FPGAs like the ICE40.RISC-V-Support for the potato (https://github.com/skordal/potato) is on the way to be released in the next weeks. With the RISC-V you might run into code size issues though...

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 31, 2019, 03:31:24 pm
content: Quote from: ataradov on May 15, 2019, 05:16:15 pmDitto. Considering switching to a pure FPGA platform before even considering the existing MCUs is mind-boggling actually. Not willing to start yet another war, but it just looks like some Atmega/Arduino users think no other MCU even exists on the market.Crazy.Anyway, if you're going for a RISC-V core on FPGAs, do it for a good reason, not just to get features you can easily find in tons of existing current MCUs.

author: brucehoult
author_rank: Super Contributor
timestamp: September 01, 2019, 12:50:14 am
content: Quote from: MorgothCreator on August 31, 2019, 11:24:00 amVery cool! Congratulations!The interrupt handling via x0 instead of the official CSRs is a bit .. weird.

author: brucehoult
author_rank: Super Contributor
timestamp: September 01, 2019, 01:09:03 am
content: Quote from: Morgan127 on August 31, 2019, 02:15:14 pmDamn, that looks slick!Peripherals needed extracted from the actual program that will be executed. And only instructions actually used by the program are included in the generated RISC-V core? Nice. Although I'd bet not many are left out in practice -- maybe LH or LHU or something like that. There's not a lot of fat in RV32I.

author: MorgothCreator
author_rank: Contributor
timestamp: September 01, 2019, 09:42:46 am
content: Quote from: brucehoult on September 01, 2019, 12:50:14 amYeah, I wanted to do something very simple for me at the time, some ideas and the IO's are ported from previous Xmega core project.I implemented even compressed instruction set to eat even less resources, off course that the processor need an application to run, and that eat resources.I will try to implement the interrupt controller via CSR's to see how much resources will eat.Quote from: SiliconWizard on August 31, 2019, 03:31:24 pmSome people are more comfortable to use FPGA's for everything, now that they discovered them, FPGA's are more hardware flexible.For example me...When I started with FPGA's, I create two cores, one for Xmega and one Risc-V 32 CI and the principal peripherals and even some more complex.Now everything I do, first I think for using a FPGA (except projects with power constraints and space constraints), are some FPGA's cheaper than a MCU's now, why notThe MCU's will slowly be deprecated, I think, or will have some fabric inside them, look at IOT's that are hungry for such fabrics that work at very low frequencies and power and do some things without MCU interventions and push data inside a FIFO.So developers need to familiarize with FPGA logic thinking, to work with both methodologiesSo, do the job done how you think you are more comfortable

author: legacy
author_rank: Super Contributor
timestamp: September 01, 2019, 09:46:31 am
content: Quote from: MorgothCreator on August 31, 2019, 11:24:00 amLVDS lcds?Quote from: MorgothCreator on August 31, 2019, 11:24:00 amcan you tell me more about this?

author: MorgothCreator
author_rank: Contributor
timestamp: September 01, 2019, 10:18:47 am
content: paralel lcd: 8:8:8 or 5:6:5 RGB, like old 16/24 bit interfaces with H and V sync wires, signals that can bee feed directly to DVI, HDMI and other serializer IP's.little gfx 2d accelerator: is an IP that accept commends to paint pixel, draw horizontal and vertical lines, and fill rectangles, at core clock speed (not LCD bus speed).

author: rstofer
author_rank: Super Contributor
timestamp: September 01, 2019, 10:03:12 pm
content: The Teensy 4 has two I2C ports and 4 UARTs but one collides with one of the I2C ports. So, minimum, 2 I2C and 3 UART.The board is supported on the Arduino IDE and uses the Arduino library definitions (download Teensyduino to make things work). It also runs at 600 MHz and has a Floating Point Unit (FPU).https://www.pjrc.com/store/teensy40.html

author: tolpe
author_rank: Newbie
timestamp: September 05, 2019, 06:55:22 am
content: Quote from: MorgothCreator on September 01, 2019, 09:42:46 amThere's one more aspect: Full cycle accurate tracing/debugging of a software program down to the interface I/O. I would very much not mind having a hard core whose HDL is open for simulation with the possibility to select a set of peripherals. Like the PSoC family from cypress, but less proprietary and coming with the full opensource model. The only reason for going "hard" is that some deep sleep logic can't just be implemented in a soft core that easy (apart from the power saving aspects in general). It's probably not much a matter of taped out hardware, the paradigm shift will be required in software for everyone to use it (many coders are just not HDL affine).I like the InstantSoc approach BTW, from the looks of it (haven't tried). Question is of course: how do you debug it when things go wrong.

author: NorthGuy
author_rank: Super Contributor
timestamp: September 05, 2019, 08:29:01 pm
content: Quote from: MorgothCreator on September 01, 2019, 09:42:46 amIt is certainly easier to do stuff in FPGA. The simple peripgerals in MCUs are getting increasingly complex. In FPGA, you can make your project much simple by using simple custom peripherals which do exactly what you need them to do, leaving out most of the extra stuff. Simpler projects will mean less bugs and more efficiency.The only problem is the cost, and perhaps board complexity - for a good FPGA you will need several power rails etc. If you can do your project using $3 PIC without any external elements except for LDO, it's hard to justify FPGA,

author: rstofer
author_rank: Super Contributor
timestamp: September 05, 2019, 08:32:24 pm
content: This PSOC6 chip as 13 Serial Communicaions Blocks which can each be configured as SPI, I2C or UART.https://www.cypress.com/file/460816/downloadUnless there was some compelling reason, I might rather use an MCU than an FPGA. I like FPGAs and I think the LC3 RISC core is very useful even though it is nearly a minimal CPU. It has an interrupt structure, DMA could be added, and you could define as many IO ports as you want. But it's an advanced topic and there is quite a steep learning curve. The project includes an assembler and C compiler so it is very useful. You can buy the book "Introduction to Computing Systems" by Patt and Patel, new or used. You can also find a lot of information in the Internet. There is a newer project, LC3B, which adds byte addressing and operations. A really fun project! If you like hardware design...PSOC programming has to be experienced to be appreciated. Being able to plunk peripherals on a drawing and have the infrastructure create most of the code is simply awesome. There are MANY videos about the PSOC 6 and they are worth watching. It is a truly amazing MCU.

author: rstofer
author_rank: Super Contributor
timestamp: September 05, 2019, 08:44:22 pm
content: Quote from: NorthGuy on September 05, 2019, 08:29:01 pmOr maybe plunk down a 'stamp' format board onto a custom daughter card:https://store.digilentinc.com/cmod-a7-breadboardable-artix-7-fpga-module/I would definitely go for the 35T variant.There are other manufacturers of 'stamp' format FPGAs. Maybe something like this:https://www.ztex.de/usb-fpga-2/usb-fpga-2.01.e.html