Zpduino Arduino
Zpduino Arduino
Alvaro Lopes
1 Version 4
2 ZPUino 5
2.0.1 What is inside ZPUino . . . . . . . . . . . . . . . . . . . . . . . . 5
2.0.2 Where does it run . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.0.3 IO Device features . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.0.4 Hardware support . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 Peripheral Pin Select 9
3.1 Redirecting output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2 Redirecting input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4 IO Modules 11
4.1 GPIO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.1.1 HDL sources and modules . . . . . . . . . . . . . . . . . . . . . . 12
4.1.2 Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.1.3 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.1.4 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.2 Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.2.1 HDL sources and modules . . . . . . . . . . . . . . . . . . . . . . 15
4.2.2 Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.2.3 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.2.4 PWM registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.2.5 Timer prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2.6 Timer PWM update policy . . . . . . . . . . . . . . . . . . . . . 19
4.2.7 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.3 UART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3.1 HDL sources and modules . . . . . . . . . . . . . . . . . . . . . . 22
4.3.2 Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3.3 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3.4 UART Prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.3.5 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2
4.4 CRC16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.4.1 HDL sources and modules . . . . . . . . . . . . . . . . . . . . . . 26
4.4.2 Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.4.3 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.4.4 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.5 Interrupt Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.5.1 HDL sources and modules . . . . . . . . . . . . . . . . . . . . . . 30
4.5.2 Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.5.3 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.5.4 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.6 SigmaDelta DAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.6.1 HDL sources and modules . . . . . . . . . . . . . . . . . . . . . . 32
4.6.2 Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.6.3 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.6.4 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.7 SPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.7.1 HDL sources and modules . . . . . . . . . . . . . . . . . . . . . . 35
4.7.2 Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.7.3 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.7.4 SPI clock prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.7.5 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5 Libraries 38
5.1 SmallFS library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.1.1 What is SmallFS ? . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.1.2 Advantages and disadvantages . . . . . . . . . . . . . . . . . . . . 39
5.1.3 Technical details . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.1.4 The library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.1.5 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.1.6 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
6 Boards 42
6.1 Interpreting board information . . . . . . . . . . . . . . . . . . . . . . . . 42
6.1.1 Pin mappings and PPS . . . . . . . . . . . . . . . . . . . . . . . . 42
6.2 Gadget Factory Papilio One 250 . . . . . . . . . . . . . . . . . . . . . . . 44
6.3 Gadget Factory Papilio One 500 . . . . . . . . . . . . . . . . . . . . . . . 47
6.4 Spartan3E Starter Kit (S3E500) . . . . . . . . . . . . . . . . . . . . . . . 51
7 Legal information 55
7.1 Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
7.2 Disclaimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3
1 Version
This is version 0.9 of the document.
4
2 ZPUino
ZPUino is a SoC (System-on-a-Chip) based on Zylin's ZPU 32-bit processor core.
5
2.0.3 IO Device features
UART features:
• 16-bit prescaler
• 2048-byte deep receive FIFO. (16 byte in reduced implementations)
SPI features:
• Two independent SPI master controllers
• Programmable prescaler
• Congurable CPOL
• Congurable SRE (Sample on Rising Edge)
• 8, 16, 24 and 32-bit transmission modes, 4 byte (32 bit) receive register.
• Congurable blocking operation
Timer features:
• Two independent timers
• 10-bit prescaler
• 16-bit and 24-bit counter
• Count-up and Count-down mode
• 16-bit Compare register
• Clear on Compare match support
• Interrupt support on Compare Match
• Output compare Registers to GPIO pin (allows PWM)
GPIO features:
• Up to 128 GPIO entries
• Bi-directional (tristate) conguration
SigmaDelta features:
• Two 16-bit channel
• Runs at system clock speed
• Congurable endianness
PPS (Peripheral pin select) features:
• Map every device pin to any GPIO pin
• Fully congurable in run-time
6
VGA features:
• HQVGA (160x120), using 800x600@75Hz output.
• 8-bit color (3 bits red, 3 bits green, 2 bits blue).
• Integrated programable character ram (8x8)
ZPUino programmer:
• 1Mbps programming speed
• Supports programming both sketches and FPGA bitle [if ZPUino bootloader
already loaded]
• Support for upload-to-ram
7
2.1 Overview
8
3 Peripheral Pin Select
This information relates to ZPUino 1.0 release. Other releases might have dierent specs.
ZPUino includes a feature which is called Peripheral Pin Select (in short, PPS). PPS
allows you to map every device input or output pin (such as SPI clock and SPI data
lines) to each individual pin (GPIO), thus not requiring you to perform synthesis and
P&R each time you want to use a device on a dierent IO pin.
To simplify things, three methods are supplied to manipulate PPS:
void pinModePPS ( int pin , int value );
void outputPinForFunction ( unsigned int pin , unsigned int function );
void inputPinForFunction ( unsigned int pin , unsigned int function );
Three register blocks exist to congure how pin selection is done. These are called
GP IOP P SIN , GP IOP P SOU T and GP IOP P SM AP . The above functions manipu-
late these registers.
In order to direct any peripheral output to a GPIO pin, you have to:
• Congure the GPIO pin as output;
• Enable PPS on selected GPIO pin;
• Congure GP IOP P SOU T (outputPinForFunction) to the peripheral signal
3.1.1 Examples
The following example maps Sigma Delta 1st channel into GPIO pin number 30:
void setup ( void )
{
// Configure pin as output
pinMode (30 , OUTPUT );
// enable PPS on this pin
pinModePPS (30 , HIGH );
// Map SigmaDelta channel 1 to pin 30
outputPinForFunction (30 , IOPIN_SIGMADELTA1 );
}
9
Note that you can use GPIO aliases for your board instead of GPIO number. See your
board specic documentation.
In order to direct GPIO input into any peripheral, you have to:
• Congure the GPIO pin as input;
• Congure GP IOP P SIN (inputPinForFunction) to the peripheral signal;
Note that for input you don't need to enable PPS on the pin using pinM odeP P S .
3.2.1 Examples
The following example maps USPI MISO signal (Master-In Slave-out) to GPIO pin
number 10:
void setup ( void )
{
// Configure pin as input
pinMode (10 , INPUT );
// Map pin 30 to USPI MISO
inputPinForFunction (10 , IOPIN_USPI_MISO );
}
10
4 IO Modules
ZPUino comes with a few IO modules you can use. You can also add other modules,
since ZPUino is Wishbone compliant.
IO accesses in ZPUino are done using MMIO (Memory Mapped IO).
In ZPUino IO devices are connected to the IO module in slots, and can be accessed
using the "C" macro IO_SLOT (x), where x depicts the slot ID for the module.
Registers in each IO slot can be accessed using the "C" REGIST ER(base, x) macro,
where base depicts the MMIO address, and x depicts the register index.
For example, to write to the 3rd register of IO slot 9, you can do it the following way:
void writetodevice ( unsigned int value ) {
// Write to 3 rd register on IO slot 9
REGISTER ( IO_SLOT (9) ,3) = value ;
}
11
4.1 GPIO
Compliance
The GPIO module is wishbone compatible, in non-pipelined mode.
Generics
gpio_count
Number of GPIO (1 to 128)
Source les
All GPIO system is implemented in zpuino_gpio.vhd.
12
PPS capability
Some pins can have their PPS capability disabled in order to reduce complexity in some
designs. The two inputs spp_cap_in and spp_cap_out can be manipulated so that
some pins have or not in/out PPS capabilities.
4.1.2 Location
GPIO are located in IOSLOT 2.
4.1.3 Registers
Two bits can be manipulated for each GPIO pin, a tristate bit and an output bit. GPIO
uses up to 4 32-bit individual registers in order to map all 128-bits. Note that the actual
number of GPIO available is board dependant.
GPIODATA register
GPIODATA is actually a 4-word register. Each bit maps a single GPIO input/output.
If the GPIO is congured as an output (see GP IOT RIS register for input/output
selection) writing a 0 or 1 to a specic bit will cause the underlying pin to become 0 or
1 (except if pin is currently mapped to a peripheral - see PPS for more details). When
read it will depict the values at an input (if the pin is congured as an input) or the
current output value if it's congured as an output.
31 0
GPIODATA [31:0]
63 32
GPIODATA [63:32]
95 64
GPIODATA [95:64]
127 96
GPIODATA [127:96]
13
GPIOTRIS register
GP IOT RIS is actually a 4-word register. When a bit is set to one, the GPIO becomes
an input (it will be tristated).
31 0
GPIOTRIS [31:0]
63 32
GPIOTRIS [63:32]
95 64
GPIOTRIS [95:64]
127 96
GPIOTRIS [127:96]
4.1.4 Software
GPIO pins should be manipulated using the Arduino-like functions digitalW rite(),
digitalRead() and pinM ode(). Additionaly GPIO can be bound to devices using PPS
(Peripheral Pin Select).
You can also use the following "C" macros if needed. Each pin block is 32-bit wide:
GPIODATA(x)
GPIODATA for pin block x
GPIOTRIS(x)
GPIOTRIS for pin block x
14
4.2 Timers
ZPUino includes two generic timers, which are able to generate PWM signals. The
default implementation includes a 16-bit timer with prescaler and TSC, and a second
24-bit timer with no prescaler nor TSC. The PWM controls of the 2nd timer are double
buered.
port (
wb_clk_i : in std_logic ;
wb_rst_i : in std_logic ;
wb_dat_o : out std_logic_vector ( wordSize -1 downto 0);
wb_dat_i : in std_logic_vector ( wordSize -1 downto 0);
wb_adr_i : in std_logic_vector ( maxIObit downto minIObit );
wb_we_i : in std_logic ;
wb_cyc_i : in std_logic ;
wb_stb_i : in std_logic ;
wb_ack_o : out std_logic ;
wb_inta_o : out std_logic ;
wb_intb_o : out std_logic ;
Compliance
The Timer module is wishbone compatible, in non-pipelined mode.
15
Generics
There are two sets of generics, one for each timer (timer A and B)
TSCENABLED
Set if TSC (TimeStamp Counter) is enabled on timer A/B(default: false)
PWMCOUNT
Number of PWM outputs for timer A/B (default: 2)
WIDTH
Timer A/B width, in bits (default: 16)
PRESCALER_ENABLED
Set if prescaler is enabled for timer A/B (default: true for timer A, false for timer
B)
BUFFERS
Set if double-buering of PWM registers is enabled on this timer (default: false
for timer A, true for timer B)
Source les
ZPUino Timers are composed of the following source modules:
zpuino_timers.vhd Top level Timers module
timer.vhd Timer module
prescaler.vhd Prescaler module
4.2.2 Location
Timer registers are usualy located in IOSLOT 3.
4.2.3 Registers
TMRxCTL register
TMRxCTL is located at oset 0 for the rst timer, and oset 64 for the second timer.
16
31 11 10 9 8 7 6 4 3 2 1 0
rsvd TMRUPDP rsvd1 TMRINTR TMRPRES TMRIEN TMRDIR TMRCCM TMREN
0 - TMREN [RW]
Timer Enable. When set to '1', timer will count either up or down, depending on
T M RDIR value.
1 - TMRCCM [RW]
Timer Clear on Compare Match. If this bit is set, whenever T M RCN T matches
T M RCM P the current value of T M RCN T will be set to zero.
2 - TMRDIR [RW]
Timer count direction. If this bit is set, then at every timer tick the value of
T M RCN T will be incremented. If this bit is not set, then T M RCN T value will
be decremented instead.
3 - TMRIEN [RW]
Timer Interrupt Enable. When this bit is set and T M RIN T R is not set, an inter-
rupt is generated whenever T M RCN T matches T M RCM P . To rearm interrupt
T M RIN T R must be cleared before exiting the ISR routine.
[6-4] TMRPRES [RW]
Timer prescaler. The timer prescale has 3 bits. See table 4.6 for more details on
the prescaler value.
7 - TMRINTR [RW]
Timer Interrupt. This bit is set whenever an interrupt occurs. It needs to be
cleared in software to re-enable this interrupt source.
8 - Reserved
Reserved.
[10:9] - TMRUPDP [RW]
Timer PWM update policy. See table 4.7 for details.
TMRxCNT
TMRxCNT is located at oset 1 for the rst timer, and oset 65 for the second timer.
Current timer counter value. This is a read/write register.
17
TMRxCMP
TMRxCMP is located at oset 2 for the rst timer, and oset 66 for the second timer.
Current timer compare value. This is a read-write register.
TMRxTSC
TMRxCMP is located at oset 3 for the rst timer, and oset 67 for the second timer.
Timestamp Counter. This register is only available in the rst timer (by omission). It's
also known as T IM ERT SC . This register is incremented at each clock cycle, and is
32-bit wide. It's a read-only register.
Use the provided "C" macros whenever possible. See section 4.2.7 for more details.
TMRxPWMLOW
TMPxPWMLOW is located at oset 0 from TMRxPWMBASE.
Low PWM compare value. If T M RxCN T is higher or equal this value, the PWM will
output 0. It's a write-only register.
TMRxPWMHIGH
TMPxPWMLOW is located at oset 1 from TMRxPWMBASE.
High PWM compare value. If T M RxCN T is lower than this value, the PWM will
output 1. It's a write-only register.
TMRxPWMCTL
TMPxPWMLOW is located at oset 2 from TMRxPWMBASE.
PWM control bits. It's a write-only register.
18
31 1 0
Reserved PWMxEN
Table 4.5: TMRxPWMCTL register
0 - PWMxEN
PWM enable
UPDATE NOW
Update PWM values as you write them.
19
UPDATE ON ZERO SYNC
Update PWM values when the timer counter reaches 0. Until then the new PWM
values will stay on the double buer.
UPDATE LATER
Don't update PWM values, just update the double buer.
For precise PWM synchronization, do:
• Set update policy to UPDATE LATER.
• Change the PWM parameters at will.
• Set update policy to UPDATE ON ZERO SYNC. When timer counter reaches 0
(or overows), all PWM will be set synchronously.
4.2.7 Software
As of ZPUino 1.0, no software classes are implemented to manipulate the timer, meaning
you have to write directly to its registers.
void setup ()
{
unsigned frequency = 100000;
20
}
PWM
A few macros are provided to ease PWM register access:
TMR0PWMLOW(x)
PWMLOW register on timer 0, for PWM output x
TMR0PWMHIGH(x)
PWMHIGH register on timer 0, for PWM output x
TMR0PWMCTL(x)
PWMCTL register on timer 0, for PWM output x
TMR1PWMLOW(x)
PWMLOW register on timer 1, for PWM output x
TMR1PWMHIGH(x)
PWMHIGH register on timer 1, for PWM output x
TMR1PWMCTL(x)
PWMCTL register on timer 1, for PWM output x
21
4.3 UART
ZPUino UART is a generic UART implementation, with a 16x oversampling lter. Only
8n1 data format is supported (1 start bit, 8 data bits, 1 stop bit, no parity). With a
96M hz clock, baud rates up to 3M bit can be used with perfect timing alignment.
Compliance
The UART module is wishbone compatible, in non-pipelined mode.
Generics
bits
Number of RX FIFO address bits
UART FIFO size will be 2bits bytes wide. Default FIFO address size is 11 bits (211 = 2048
bytes)
22
Source les
ZPUino UART is composed of the following source modules:
zpuino_uart.vhd Top level UART module
zpuino_uart_rx.vhd UART RX module
uart_brgen.vhd Baud rate generator
zpuino_uart_mv_lter.vhd RX Majority voting lter
tx_unit.vhd UART TX module
fo.vhd UART FIFO module
4.3.2 Location
UART registers are usualy located in IOSLOT 1.
4.3.3 Registers
UART operation is controlled by three registers, U ART CT L, U ART DAT A and
U ART ST AT U S .
UARTCTL register
The U ART CT L register controls the transmit and receive operation of the UART.
31 17 16 15 0
Reserved UARTEN UARTPRES
Table 4.9: UARTCTL register
16 - UARTEN
UARTEN bit controls whether UART is enabled or not. When set to 1, UART
input and output will be mapped to appropriate pins. When set to 0 TX and RX
will be disconnected.
[15:0] - UARTPRES
UART prescaler (16 bits). See 4.3.4 for details.
23
UARTDATA register
The U ART DAT A register is used for tranmission and reception of UART data. Recep-
tion includes a congurable (synthesis time) FIFO. Only the lower 8 bits of this register
are used.
31 8 7 0
Reserved TXRXD
Table 4.10: UARTDATA register
[7:0] - TXRXD
8-bit UART data transmit and receive register.
UARTSTATUS register
The U ART ST AT U S register contains the current status of UART.
31 2 1 0
Reserved UARTTXR UARTRXR
Table 4.11: UARTSTATUS register
1 - UARTTXR
UART TX Ready bit. Reads as 1 when there's space in TX FIFO for transmission,
0 otherwise. This bit should be checked before attempting transmission over the
UART.
0 - UARTRXR
UART RX Ready bit. Reads as 1 when there's received data in FIFO, 0 otherwise.
fOSC
P rescale = −1
baudrate × 16
24
4.3.5 Software
Acessing the UART in software can be done using the HardwareSerial class. The
default UART module is already instantiated as Serial.
Examples
The following example uses the default Serial object.
void setup ()
{
Serial . begin (115200); /* Set up serial at 115200 baud */
Serial . println ( " Hello world ! " ); /* Write Hello World ! to serial */
}
void loop ()
{
if ( Serial . available ()) { /* If there is data on the UART ... */
Serial . write ( Serial . read () ); /* ... write it back ! */
}
}
void setup ()
{
mySerial . begin (115200); /* Set up serial at 115200 baud */
mySerial . println ( " Hello world ! " ); /* Write Hello World ! to serial */
}
void loop ()
{
if ( mySerial . available ()) { /* If there is data on the UART ... */
mySerial . write ( Serial . read () ); /* ... write it back ! */
}
}
25
4.4 CRC16
Compliance
The CRC16 is wishbone compatible, in non-pipelined mode.
Source les
All CRC16 system is implemented in zpuino_crc16.vhd.
4.4.2 Location
4.4.3 Registers
CRCACC
The CRCACC register contains the accumulated CRC16 value. It's a read-write regis-
ter.
26
31 16 15 0
Reserved CRC16ACC
Table 4.12: CRC16ACC register
CRCPOLY
The CRCAP P register contains the polynomial for the CRC16 operation. It's a read-
write register.
31 16 15 0
Reserved CRC16POLY
Table 4.13: CRC16POLY register
CRCAPP
The CRCAP P register, when written, appends the value to the current CRC16 engine.
It's a write-only register. Note that CRC16 computation takes 8 clock cycles. Note that
the append register is 8-bit wide.
31 8 7 0
Reserved CRC16APP
Table 4.14: CRC16APP register
CRCAM1
The CRCAM 1 register is a read-only register, and depicts the previous value of CRCACC
when CRC16AP P register is written.
31 16 15 0
Reserved CRC16AM1
Table 4.15: CRC16AM1 register
27
CRCAM2
The CRCAM 2 register is a read-only register, and depicts the previous value of CRCAM 1
when CRC16AP P register is written. This register is of great importance, because if
you're processing a stream and the last two bytes of that stream are the CRC value, the
2-value-old CRC value can be compared without need for software intervention.
31 16 15 0
Reserved CRC16AM2
Table 4.16: CRC16AM2 register
4.4.4 Software
There are no classes provided to interact with the CRC16 engine. However it's rather
easy to use the registers directly, as in the following examples.
28
}
29
4.5 Interrupt Controller
4.5.2 Location
The interrupt controller is located in IOSLOT 4. This slot cannot be used on top-level
module.
4.5.3 Registers
INTRCTL
Interrupt control register.
31 1 0
Reserved INTREN
Table 4.17: INTRCTL register
INTREN
Interrupt Enable bit
INTRMASK
Interrupt mask register. Set to '1' to enable a specic interrupt line.
31 0
IMASK
Table 4.18: INTRMASK register
IMASK
Interrupt Mask. See board-specic design for detail on the interrupt lines.
30
4.5.4 Software
The following example shows how to use interrupts with Timer 0. Timer is set up for a
10KHz operation with interrupts enabled.
void _zpu_interrupt ()
{
if ( TMR0CRL & _BV ( TCTLIF )) { /* Interrupt comes from timer 0 */
void setup ()
{
unsigned frequency = 10000;
31
4.6 SigmaDelta DAC
sync_in : in std_logic ;
Compliance
The Sigma Delta DAC is wishbone compatible, in non-pipelined mode.
Source les
All Sigma Delta system is implemented in zpuino_sigmadelta.vhd.
4.6.2 Location
The Sigma Delta module is usually located in IOSLOT 5.
32
4.6.3 Registers
SIGMADELTACTL
Sigma Delta DAC control register.
31 4 3 2 1 0
Reserved SDEXTTRIG SDLE SDENA1 SDENA0
Table 4.19: SIGMADELTACTL register
SDENA0
SigmaDelta Channel 0 enable
SDENA1
SigmaDelta Channel 1 enable
SDLE
Sigma-Delta Little Endian support. If set to 1 input is assumed to be little endian,
otherwise the native format (big endian) is used.
SDEXTTRIG
Sigma-Delta external trigger support. If set to 1, then an external signal (Timer0
compare match) is used to transfer previously written data into the output. This
is useful if you require a constant sigma delta update, but you have jitter in the
code that do not allow for a precise output timing.
SIGMADELTADATA
Sigma Delta DAC data register.
31 16 15 0
SDCH1 SDCH0
Table 4.20: SIGMADELTADATA register
SDCH0
SigmaDelta Channel 0 data
SDCH1
SigmaDelta Channel 1 data
33
4.6.4 Software
34
4.7 SPI
Compliance
The SPI module is wishbone compatible, in non-pipelined mode.
Source les
4.7.2 Location
4.7.3 Registers
SPICTL
SPI control register.
31 10 9 8 7 6 5 4 3 1 0
Reserved SPITS 2 SPIBLOCK SPIEN SPISRE SPICPOL SPICP SPIREADY
35
0 - SPIREADY [RW]
SPI Ready bit. Reads as 1 when transfer has been completed or module is idle, 0
otherwise. If you use blocking operation then you don't have to check this bit.
[3:1] - SPICP [RW]
SPI clock prescaler. The prescaler has 3 bits.
4 - SPICPOL [RW]
SPI clock polarity.
5 - SPISRE [RW]
SPI capture edge. If set to 1, then input is latched on rising clock edge, otherwise
it's latched on falling edge.
6 - SPIEN [RW]
SPI enable bit. Must be set to 1 for SPI operation.
7 - SPIBLOCK [RW]
SPI blocking operation. If this bit is set to 1, all reads and writes to SPI module
will cause CPU to wait if transmission is still in progress. This allows for fast
transfers because you don't have to check for SPIREADY bit.3
[9:8] - SPITS [RW]
SPI Transfer size. Will be deprecated in a next release.
SPIDATA
SPI data register.
31 0
SPIDATA
Table 4.22: SPIDATA register
interrupt jitter.
36
Prescaler value Clock divider
000 1
001 2
010 4
011 8
100 16
101 64
110 256
111 1024
Table 4.23: SPI prescaler values
4.7.5 Software
37
5 Libraries
38
5.1 SmallFS library
SmallFS header
39
# define SMALLFS_MAGIC 0 x50411F50
struct smallfs_header {
uint32_t magic ;
uint32_t numfiles ;
};
SmallFS header is 8-bytes long and includes the lesystem magic and the number of les
packed in the lesystem.
The directory
Each directory entry is variable sized, and includes the header plus the le name. The
le name is not NULL terminated.
struct smallfs_entry {
uint32_t offset ;
uint32_t size ;
uint8_t namesize ;
char name [0];
};
The of f set eld depicts the le contents oset relative to the start of the lesystem.
Following the header, the le name will be stored, with size given by the namesize eld.
These two methods are the only one you need to use on the base class.
The SmallF S.begin() method returns 0 on success, or -1 otherwise. It only fails if no
lesystem is found.
40
bool SmallFSFile :: valid ();
int SmallFSFile :: read ( void * buf , int size );
void SmallFSFile :: seek ( int pos , int whence );
int SmallFSFile :: size () const ;
int SmallFSFile :: readCallback ( int s , void (* callback )( unsigned char , void *) , void * dat
5.1.5 Tools
A set of tools are provided to create the lesystem, and to extract and/or dump its
contents.
5.1.6 Integration
The current IDE (Alpha5+ and beyond) can detect SmallFS and generate automatically
its contents and program it after the sketch binary.
All you have to do is to create a directory in your sketch folder with name smallf s, put
your les in it, and the IDE will recognise it and program the ash accordingly.
41
6 Boards
On this chapter we decribe the current boards ocially supported.
In addition to the baseline board conguration some variants are oered.
For each board a few information is shown. The overall features and conguration are
shown rst, followed by the PPS (Peripheral Pin Select) interconnections, the board
pinout information, and the IO slot mappings.
42
N/A
The pin cannot be used for PPS.
43
6.2 Gadget Factory Papilio One 250
44
Number Name Function PPS Alias
0 FPGA_PIN_P18 GPIO I/O WING_A_0
1 FPGA_PIN_P23 GPIO I/O WING_A_1
2 FPGA_PIN_P26 GPIO I/O WING_A_2
3 FPGA_PIN_P33 GPIO I/O WING_A_3
4 FPGA_PIN_P35 GPIO I/O WING_A_4
5 FPGA_PIN_P40 GPIO I/O WING_A_5
6 FPGA_PIN_P53 GPIO I/O WING_A_6
7 FPGA_PIN_P57 GPIO I/O WING_A_7
8 FPGA_PIN_P60 GPIO I/O WING_A_8
9 FPGA_PIN_P62 GPIO I/O WING_A_9
10 FPGA_PIN_P65 GPIO I/O WING_A_10
11 FPGA_PIN_P67 GPIO I/O WING_A_11
12 FPGA_PIN_P70 GPIO I/O WING_A_12
13 FPGA_PIN_P79 GPIO I/O WING_A_13
14 FPGA_PIN_P84 GPIO I/O WING_A_14
15 FPGA_PIN_P86 GPIO I/O WING_A_15
Table 6.3: GF Papilio One 250 pin mappings
45
Number Name Function PPS Alias
32 FPGA_PIN_P91 GPIO I/O WING_C_0
33 FPGA_PIN_P92 GPIO I/O WING_C_1
34 FPGA_PIN_P94 GPIO I/O WING_C_2
35 FPGA_PIN_P95 GPIO I/O WING_C_3
36 FPGA_PIN_P98 GPIO I/O WING_C_4
37 FPGA_PIN_P2 GPIO I/O WING_C_5
38 FPGA_PIN_P3 GPIO I/O WING_C_6
39 FPGA_PIN_P4 GPIO I/O WING_C_7
40 FPGA_PIN_P5 GPIO I/O WING_C_8
41 FPGA_PIN_P9 GPIO I/O WING_C_9
42 FPGA_PIN_P10 GPIO I/O WING_C_10
43 FPGA_PIN_P11 GPIO I/O WING_C_11
44 FPGA_PIN_P12 GPIO I/O WING_C_12
45 FPGA_PIN_P15 GPIO I/O WING_C_13
46 FPGA_PIN_P16 GPIO I/O WING_C_14
47 FPGA_PIN_P17 GPIO I/O WING_C_15
Table 6.5: GF Papilio One 250 pin mappings (cont.)
46
6.3 Gadget Factory Papilio One 500
47
Number Name Function PPS Alias
0 FPGA_PIN_P18 GPIO I/O WING_A_0
1 FPGA_PIN_P23 GPIO I/O WING_A_1
2 FPGA_PIN_P26 GPIO I/O WING_A_2
3 FPGA_PIN_P33 GPIO I/O WING_A_3
4 FPGA_PIN_P35 GPIO I/O WING_A_4
5 FPGA_PIN_P40 GPIO I/O WING_A_5
6 FPGA_PIN_P53 GPIO I/O WING_A_6
7 FPGA_PIN_P57 GPIO I/O WING_A_7
8 FPGA_PIN_P60 GPIO I/O WING_A_8
9 FPGA_PIN_P62 GPIO I/O WING_A_9
10 FPGA_PIN_P65 GPIO I/O WING_A_10
11 FPGA_PIN_P67 GPIO I/O WING_A_11
12 FPGA_PIN_P70 GPIO I/O WING_A_12
13 FPGA_PIN_P79 GPIO I/O WING_A_13
14 FPGA_PIN_P84 GPIO I/O WING_A_14
15 FPGA_PIN_P86 GPIO I/O WING_A_15
Table 6.10: GF Papilio One 500 pin mappings
48
Number Name Function PPS Alias
32 FPGA_PIN_P91 GPIO I/O WING_C_0
33 FPGA_PIN_P92 GPIO I/O WING_C_1
34 FPGA_PIN_P94 GPIO I/O WING_C_2
35 FPGA_PIN_P95 GPIO I/O WING_C_3
36 FPGA_PIN_P98 GPIO I/O WING_C_4
37 FPGA_PIN_P2 GPIO I/O WING_C_5
38 FPGA_PIN_P3 GPIO I/O WING_C_6
39 FPGA_PIN_P4 GPIO I/O WING_C_7
40 FPGA_PIN_P5 GPIO I/O WING_C_8
41 FPGA_PIN_P9 GPIO I/O WING_C_9
42 FPGA_PIN_P10 GPIO I/O WING_C_10
43 FPGA_PIN_P11 GPIO I/O WING_C_11
44 FPGA_PIN_P12 GPIO I/O WING_C_12
45 FPGA_PIN_P15 GPIO I/O WING_C_13
46 FPGA_PIN_P16 GPIO I/O WING_C_14
47 FPGA_PIN_P17 GPIO I/O WING_C_15
Table 6.12: GF Papilio One 500 pin mappings (cont.)
49
IO Slot Device Notes
0 SPI Connected to SPI ash
1 UART Connected to FT2232
2 GPIO
3 Timers 1×16 bit (one PWM), 1×24 bit (one PWM)
4 Interrupt Hardcoded
5 SigmaDelta Mapped to PPS
6 SPI Mapped to PPS
7 CRC16
8-10 empty
11 UART Mapped to PPS
12-15 empty
50
6.4 Spartan3E Starter Kit (S3E500)
51
Number Name Function PPS Alias
0 FPGA_PIN_B4 GPIO I/O FPGA_J1_0
1 FPGA_PIN_A4 GPIO I/O FPGA_J1_1
2 FPGA_PIN_D5 GPIO I/O FPGA_J1_2
3 FPGA_PIN_C5 GPIO I/O FPGA_J1_3
4 FPGA_PIN_A6 GPIO I/O FPGA_J2_0
5 FPGA_PIN_B6 GPIO I/O FPGA_J2_1
6 FPGA_PIN_E7 GPIO I/O FPGA_J2_2
7 FPGA_PIN_F7 GPIO I/O FPGA_J2_3
8 FPGA_PIN_D7 GPIO I/O FPGA_J4_0
9 FPGA_PIN_C7 GPIO I/O FPGA_J4_1
10 FPGA_PIN_F8 GPIO I/O FPGA_J4_2
11 FPGA_PIN_E8 GPIO I/O FPGA_J4_3
12 FPGA_PIN_L13 GPI N/A FPGA_SW_0
13 FPGA_PIN_L14 GPI N/A FPGA_SW_1
14 FPGA_PIN_H18 GPI N/A FPGA_SW_2
15 FPGA_PIN_N17 GPI N/A FPGA_SW_3
Table 6.17: Spartan3E Starter Kit (S3E500) pin mappings
52
Number Name Function PPS Alias
32 FPGA_PIN_F12 GPO N/A FPGA_LED_0
33 FPGA_PIN_E12 GPO N/A FPGA_LED_1
34 FPGA_PIN_E11 GPO N/A FPGA_LED_2
35 FPGA_PIN_F11 GPO N/A FPGA_LED_3
36 FPGA_PIN_C11 GPO N/A FPGA_LED_4
37 FPGA_PIN_D11 GPO N/A FPGA_LED_5
38 FPGA_PIN_E9 GPO N/A FPGA_LED_6
39 FPGA_PIN_F9 GPO N/A FPGA_LED_7
40 FPGA_PIN_R15 GPIO N/A FPGA_LCD_D4
41 FPGA_PIN_R16 GPIO N/A FPGA_LCD_D5
42 FPGA_PIN_P17 GPIO N/A FPGA_LCD_D6
43 FPGA_PIN_M15 GPIO N/A FPGA_LCD_D7
44 FPGA_PIN_L18 GPO N/A FPGA_LCD_RS
45 FPGA_PIN_L17 GPO N/A FPGA_LCD_RW
46 FPGA_PIN_M18 GPO N/A FPGA_LCD_E
47 FPGA_PIN_P7 GPO N/A FPGA_AMP_SHDN
Table 6.19: Spartan3E Starter Kit (S3E500) pin mappings (cont.)
53
IO Slot Device Notes
0 SPI Connected to board SPI bus
1 UART Connected to RS232
2 GPIO
3 Timers 1×16 bit (one PWM), 1×24 bit (one PWM)
4 Interrupt Hardcoded
5 SigmaDelta Mapped to PPS
6 SPI Mapped to PPS
7 CRC16
8-15 empty
54
7 Legal information
7.1 Licensing
See individual parts for licensing information. Most HDL code is released under BSD
license, some parts using GNU GPL license.
The Arduino IDE (and its modications) are licensed under GPLv2 license.
The ZPU toolchain components (binutils, gcc and gdb) have their own licensing infor-
mation.
This document and the web site are released under Creative Commons Attribution
Share-Alike (cc by-sa).
7.2 Disclaimer
55