dadamachines / doppler

Arduino compatible – Cortex M4F & FPGA Development Board
81 stars 9 forks source link

Feature request: enable Arduino sketch to select which bitstream to load #3

Open pdp7 opened 5 years ago

pdp7 commented 5 years ago

I think it would be nice to make this code more flexible so that it is not hard coded to a single bitstream: https://github.com/dadamachines/ArduinoCore-samd/blob/master/variants/doppler/ICEClass.h

It would be useful to have different classes for different bitstreams so that the desired functionality can be chosen in the Arduino sketch without have to modify header files in the library. https://github.com/dadamachines/ArduinoCore-samd/blob/master/variants/doppler/ICEClass.h#L12

#include <doppler_simple_io.h>

which seems to reference: https://github.com/dadamachines/doppler-FPGA-firmware/blob/master/doppler_simple_io/doppler_simple_io.h

pdp7 commented 5 years ago

Note: I am confused how doppler-FPGA-firmware/doppler_simple_io/doppler_simple_io.h ends up on my computer. Maybe that happens when I add the Doppler in the Arduino board manager?

pdp7 commented 5 years ago

Here is an example of how I think it would be nice to be able to configure the FPGA from an Arduino sketch. I am assuming this example would be in https://github.com/dadamachines/doppler-software/blob/master/examples/

FPGA configuration to make all the FPGA pins PWM outputs:

#include <ICEClass.h>
PWM_ICEClass ice40pwm;
void setup() { // put your setup code here, to run once:
  ice40pwm.upload(); // Upload BitStream Firmware to FPGA -> see variant.h
  delay(100);
  ice40pwm.initSPI();  // start SPI runtime Link to FPGA

}

void loop() {  // put your main code here, to run repeatedly:
      // code that allows the user to then choose an FPGA pin and set a PWM duty cycle for it
      // maybe something like
      ice40pwm.pinMode(F0, OUTPUT)
      ice40pwm.analogWrite(F0, 255)
  }
}

Maybe the doppler library could come with a set of ICEClass subclasses that would load bitstreams for different functionality. This would let users comfortable with Arduino sketches experiment before diving into Verilog: