Created by Vikas N Kumar / Selective Intellect
Follow us on Twitter at @_vicash_ / @selectintellect
© 2014-2015. Selective Intellect LLC. All Rights Reserved.
VIC™ is an easy to use domain specific language to develop firmware for Microchip's PIC® microcontroller units (MCU).
If you ...
... then VIC™ is for you !
Press the space bar to navigate if using the keyboard.
As we did more PIC® microcontroller projects, we found that ...
... so we decided to automate all of these problems away !
To automate our problems away we wanted a DSL that did the following for us:
We wanted a capability to auto-generate the DSL from higher level languages like Perl or Python or from flowcharts
Press the space bar to navigate if using the keyboard.
VIC™ is dual-licensed under the
Let's say we want to light up an LED.
Let's use the P16F690 PIC® microcontroller chip.
Let's assume the pin RC0
is connected to an
LED.
$ vic --chip-pinout P16F690
+======__======+
Vdd ---|1 20|--- Vss
| |
RA5/T1CKI/OSC1/CLKIN ---|2 19|--- RA0/AN0/C1N+/ICSPDAT/ULPWU
| |
RA4/AN3/T1G/OSC2/CLKOUT ---|3 18|--- RA1/AN1/C12IN0-/Vref/ICSPCLK
| |
RA3/MCLR/Vpp ---|4 17|--- RA2/AN2/T0CKI/INT/C1OUT
| |
RC5/CCP1/P1A ---|5 16|--- RC0/AN4/C2IN+
| |
| P16F690 |
| |
RC4/C2OUT/P1B ---|6 15|--- RC1/AN5/C12IN1-
| |
RC3/AN7/C12IN3-/P1C ---|7 14|--- RC2/AN6/C12IN2-/P1D
| |
RC6/AN8/SS ---|8 13|--- RB4/AN10/SDI/SDA
| |
RC7/AN9/SDO ---|9 12|--- RB5/AN11/RX/DT
| |
RB7/TX/CK ---|10 11|--- RB6/SCK/SCL
| |
+==============+
PIC P16F690;
Main {
digital_output RC0; # mark pin RC0 as output
write RC0, 0x1; # write the value 1 to RC0
}
#include <p16f690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF
& _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
org 0
_start:
;; turn on pin RC0 as output
banksel TRISC
bcf TRISC, TRISC0
banksel ANSEL
bcf ANSEL, ANS4
banksel PORTC
bcf PORTC, 0
;; write 1 to RC0
bsf PORTC, 0
goto $
end
Using gpsim
as default simulator
PIC P16F690;
Main {
digital_output RC0; # mark pin RC0 as output
write RC0, 0x1; # write the value 1 to RC0
}
Simulator {
attach_led RC0; # attach an LED to the pin RC0
stop_after 1s; # stop the simulation after 1 second
}
PIC P16F690;
Main {
digital_output RC0; # mark pin RC0 as output
Loop {
write RC0, 1; # turn the LED on
delay 1s; # wait 1 second
write RC0, 0; # turn the LED off
delay 1s; # wait 1 second
}
}
Simulator {
attach_led RC0; # attach an LED to the pin RC0
stop_after 5s; # stop the simulation after 5 seconds
}
PIC pic_name; #required
pragma pragma_type pragma_values; # optional
Main {
# user invokes functions
function_name argument, argument, argument, ..., argument;
...
## optional loops
Loop {
function_name argument, argument, ..., argument;
...
}
}
## optional simulator block
Simulator {
# special simulator functions
function_name argument, argument, argument, ..., argument;
function_name argument, argument, argument, ..., argument;
}
;
Main
block is required#
Loop {}
if-else, while
Simulator
block is optional.Action
blocks (callbacks)$
signSimulator
block
$my_timer = 1s; # 1 second
$my_timer = 100ms; # 100 milliseconds
$frequency = 4kHz; # 4000 Hz
$dutycycle = 10%; # 0.01
function_name argument, ..., Action {
# .. do something here ...
};
debounce RA3, Action {
# .. do something here ..
}
timer_enable TMR0, 4kHz, ISR {
# .. do something ..
};
+
, -
, *
, /
, %
=
, +=
, -=
, *=
, /=
, %=
, ^=
, |=
, &=
, <<=
, >>=
>>
, <<
, ^
, &
, |
!
, ~
<
, >
, <=
, >=
, !=
, ==
, &&
, ||
++
, --
.hex
digital_output
digital_input
analog_input
write
debounce
timer_enable
timer_disable
delay
delay_s
delay_ms
delay_us
sqrt, ror, rol
gpsim
is the defaultgpsim
supports 100+ chipsgpsim
language
PIC P16F690;
Main {
delay 100ms;
sim_assert "*** EARLY STOP ***";
}
Simulator {
stopwatch 100ms;
}