Add support for configuring VCD traces from the commandline.
use READ_SREG_INTO rather than g->avr->data[R_SREG] to get current sreg status for export to gdb
elf: Bit of cleanup
Going to clean this piece of code a little
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: Added support for PC overflow
Added a special opcode at the end of flash to catch PC overflow, and
'wrap it'. Also log the condition.
This allow that case to be handled without having to add a
modulo/division for each instruction.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Clean up that CLOCK mess
Generalized getting a time stamp related to the simulation. Make it
really portable.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Correct x8 ADC mux modes
In all of the datasheets for ATmega44/88/168/328 devices that I've
seen, there are 8 channels of ADC selected with MUX modes 0000-0111,
and the temperature sensor is selected with MUX mode 1000.
modify avr_callback_sleep_raw() to mitigate sim time and wall clock time divergence
To avoid simulated time and wall clock time to diverge over time
this implementation tries to keep them in sync (roughly) by sleeping
for the time required to match the expected sleep deadline
in wall clock time.
The simulation will burst as fast as the host CPU will allow
until the simulated MCU sleeps, at which point avr_callback_sleep_raw()
sleeps for the time required to sync wall clock time with simulated MCU
time.
Fix a bug which causes no cores to be compiled
On some systems, including some Mac and some Linux computers, the
sim_core_config.h file will not have any cores compiled on it.
Here is the patch from #20.
I have tested this on Linux, and there are many people on #20 reporting
that it works perfectly on Mac.
Fix timer mode 14 for timers 1, 3, 4 and 5 on Atmega2560
Make sure sim_core_declare.h is included *after* avr includes, as currently dependant ifdefs never succeed
use only 12 bits for ubrr (#257)
* use only 12 bits for ubrr
* use bitmask for ubrr
* remove r_ubrr_h and r_ubrr_l
Add support for framing error in uart (#258)
* uart: Add support for a framing error. Useful for detecting breaks
* Fix spacing for "if"
ssd1306: move display vertical and horizontal mirroring to OpenGL scene setup
The idea is that the display orientation related code belongs in the
board's implementation. Prior to this commit boards which mount the
display with a different orientation would end up mirroring the pixels
twice: once when reading them from the framebuffer and again in the
OpenGL scene rendering. As a sideeffect now reading pixels from the
vram array is simplified.
ssd1306: fix pixel size constant in demo
ssd1306: fix background painting
- Take pixel size into account.
- Fix swapped coordinates passed to glVertex2f().
ssd1306: remove stray glBegin(GL_QUADS) call
ssd1306_virt: add SSD1306_VIRT_CHARGE_PUMP command (ignored)
Without this change receiving SSD1306_VIRT_CHARGE_PUMP will
make the command parser get out of sync.
extint: support cores with non-contiguous extint numbers like atmega32u4
avr_extint_exists() is used to establish if an extint index is valid
and avr_extint_count() is removed because it is not used any longer.
parts: ssd1306: SET_COLUMN_*_NIBBLE commands are ignored in page mode
parts/ssd1306: add twi interface
parts/ssd1306: Add dummy handlers for various commands
in particular, commands used by adafruit driver. Since some
commands are multibyte, this prevents us getting out of sync
or misinterpreting commands.
parts/ssd1306: support horizontal addressing mode
In particular, it's used by the adafruit driver for arduino
timer: Removed round()
That drags libm in, and we don't need that.
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: atmega32u4: Fix indentation
Use hard tabs and assume a tab width of 4 spaces.
Add atmega32u4 core by Michel Pollet <buserror@gmail.com>
fix timer is not triggered at ocr==0
irq: Standardized some names
Made all the names more or less standard. Might still change...
Signed-off-by: Michel Pollet <buserror@gmail.com>
Added a define "FALLTHROUGH" to suppress 'this statement may fallthrough' messages
Since avr-gcc version 7 the flag -Wimplicit-fallthrough is set, so that
a missing "break;" inside a switch-case statement will throw an error in
the compiling process.
The missing breaks are replaced by the FALLTHROUGH define and no errors
occours.
FALLTHROUGH is simply an "__attribute__((fallthrough));" - if it is
supported by the compiler.
make: Factored library making
Removed duplicate make commands for libraries
Signed-off-by: Michel Pollet <buserror@gmail.com>
make parallel builds succeed
Change arduino library path so it works on mac
changed EEARL to EEAR inside AVR_EEPROM_DECLARE_8BIT
(some iotnxx.h files have only a EEAR declaration)
added corefiles for attiny2313a and attiny4313
make: Remove -Werror
Can't fight multiple compiler, versions, and OS and expect everyone to
agree while breaking the build for normal people.
Signed-off-by: Michel Pollet <buserror@gmail.com>
ioend implemented in core declaration
parts: Build a simavr virtual parts library
An external project using simavr can link against libsimavr.
However, there is no support for using virtual parts from the
examples folder in the external project.
This commit adds support for building a parts library, which the
external project can link against. Presently this library is fairly
small, but as the number of parts grows this approach may need
to be changed. A longer term solution could be to provide an API as
part of the simavr library which can manage the parts. Simavr could
dynamically load and provide parts as required by the external
project.
Like libsimavr, this patch makes no attempt to make the version easy
to set. That can be covered under a different PR.
Merge branch 'wip/avrlib-headers'
m324: Fix core
Now uses the new header
Signed-off-by: Michel Pollet <buserror@gmail.com>
make: Change build to use our copy of avrlibc
Now uses our own copy, this should help build simavr with support for
all cores, on all hosts
Signed-off-by: Michel Pollet <buserror@gmail.com>
Add a stub sfr_defs.h
Some avrlibc cores include that file, that define macros and so on. We
don't need/want that as we already have macros for stuff
Signed-off-by: Michel Pollet <buserror@gmail.com>
Add avrlibc headers to simavr
This was planned to remove the dependency on the hosts avrlibc that is
often very out of date, or borken.
I copied their licence, and added a readme. I removed also most of the
headers we don't need.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge branch 'ttyridal-misc_fixes'
whitespace: remove eol-spaces
Rename 90usb162 core file
or it will be excluded by the magic in Makefile
Update extra_board_usb
changing special* init/deinit to avr->custom
make: Enable more warnings
Merge branch 'franciscod-hd44780_not_hd77480'
Merge branch 'hd44780_not_hd77480' of https://github.com/franciscod/simavr into franciscod-hd44780_not_hd77480
Conflicts:
examples/board_hd44780/font.h
examples/board_hd77480/font.h
examples/parts/hd44780_font.h
Add missing header file to 'sim_hex.h'
'size_t' is not defined in any of the header files included in
'sim_hex.h', even though it is used in there.
You can see a list of all headers that define 'size_t' here
http://en.cppreference.com/w/c/types/size_t
parts: Move font.h for hd44780 display to parts directory
This file is referenced only by hd44780_glut.c in the parts folder,
so move it there and give it a prefix.
misc: Strip off tag prefix from the pkg-config version
For example, before this change the version would
be set as 'tag:v1.5'. After this change it will be
'v1.5'.
cores: Add support for Analog Comparator
timer: Added an IRQ for input capture trigger (ICP)
Merge pull request #223 from kostic2000/feature/add_reset_sources
Add reset flags and set power-on reset as a default when avr is initialised
Add reset flags and set power-on reset as a default when avr is initialised
vcd: Decrease the VCD resolution
From about 1GHz to 100MHz. Shouldn't have an impact on simavr proper,
but might help with Pulseview
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge pull request #216 from Premik/x4Aref
Tinyx4 core, avcc->aref
board_hd77480: rename to board_hd44780 (typo?)
https://en.wikipedia.org/wiki/Hitachi_HD44780_LCD_controller
vcd: Removed GNU dependency
Why isn't this in the standard C library, I wonder.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge pull request #203 from kostic2000/timer_prescaler_reset_fix
Set prescaler divisor (cs_div_value) to zero when prescaler is reset,…
vcd: Added 'floating' support
Also, fixed a bug int he input file reading code.
Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr: Wiggled the log levels.
Added a new LOG_OUTPUT, and a new LOG_DEBUG. Hopefully this will allow
running run_avr without -v to get the expected output.
Signed-off-by: Michel Pollet <buserror@gmail.com>
elf: Disabled some noisy traces
Not necessary, and they can't be filtered as the AVR is not populated
Signed-off-by: Michel Pollet <buserror@gmail.com>
uart: Gratuitous reformatting
New fashion!
Signed-off-by: Michel Pollet <buserror@gmail.com>
IRQs: Trace the pending vectors
Trace pending vectors, and use the new 'float' option when nothing is
pending
Signed-off-by: Michel Pollet <buserror@gmail.com>
sim_avr: Gratuitous reformatting
No functional changes
Signed-off-by: Michel Pollet <buserror@gmail.com>
irq: Added a flag for a 'floating' value
When this flag is set, the value is to be ignored.
Signed-off-by: Michel Pollet <buserror@gmail.com>
mmcu: Added tag for tracing pending IRQs
This was missing from the header.
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: Cleaned up trace code.
Also fix a potential crash when using it.
Signed-off-by: Michel Pollet <buserror@gmail.com>
run_avr: Added support for --input <vcd>
Still need the backend code, let's not get overexcited here ;-)
Signed-off-by: Michel Pollet <buserror@gmail.com>
run_avr: A bit of cosmetic Also, standardize '--' for all long options
This had to be done at some point
Signed-off-by: Michel Pollet <buserror@gmail.com>
vcd: Extensive update; added support for VCD Input
Massive update here. Now allow reading from a VCD file, as long as the
traces are named in a way that allows us to connect an IRQ. Typically,
you can send pin values to for example PORTB5 by naming the trace
'iogB_5' -- you can use sigrock for example to capture traces from
real hardware, and 'replay' it in simavr.
Also since I was there, reworked the whole module to use a 'proper' FIFO
and simplified the output generation too.
There are a few 'TODO' left, but it's functional.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Added sim_utils.c/h
Contains my string stripper utility. Used by the VCD input module
Signed-off-by: Michel Pollet <buserror@gmail.com>
irq: Small cleanup
Also, try to find an empty slot in the pool when adding an IRQ
Signed-off-by: Michel Pollet <buserror@gmail.com>
Set prescaler divisor (cs_div_value) to zero when prescaler is reset, i.e. timer is stopped. Otherwise when OCR is set, the tomer gets reconfigured with the old prescaler
Fix for travis build on antique ubugtu
Doesn't have proper defs for mega2560 !
Signed-off-by: Michel Pollet <buserror@gmail.com>
Updated some tests to use the new VCD macros
No functional changes
Signed-off-by: Michel Pollet <buserror@gmail.com>
Changed the port/pin trace macros to use the generic one
Simplifed the whole operation
Signed-off-by: Michel Pollet <buserror@gmail.com>
Added new VCD tags for IRQ vector tracing
Now allow cool stuff, like tracking pending IRQs, their exact execution
time, and also a global one that shows which ones are running and when
Signed-off-by: Michel Pollet <buserror@gmail.com>
mmcu: Added VCD_PORT_PIN support
Allows specing VCD traces for PORT/PIN directly in the firmware using a
MMCU macro.
Also did a bit of housekeeping in sim_elf since I was there...
Signed-off-by: Michel Pollet <buserror@gmail.com>
mmcu ELF section fixes
Fix the problem with newer gcc, annoyingly enough this is a clear
regression in the compiler to prevent that syntax; it worked for yeards
uppon years and you can /still/ do it for singleton strings anyway!
Signed-off-by: Michel Pollet <buserror@gmail.com>
Fixed typos in comments
Been there a loooong time.
Signed-off-by: Michel Pollet <buserror@gmail.com>
irq: Updated the tracing
Nothing functional there, apart from tweaking traces
Signed-off-by: Michel Pollet <buserror@gmail.com>
Added sanity check for the .mmcu section handlers
Manage to bite myself on this one.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge pull request #194 from hovercraft-github/used_with_simutron
When UART is driven by interrupts, the reception never starts
UART: separate TX/RX pumps, sticky UDRC and RXC interrupt flags.
Fixes #104, #193 and others.
doc: Updated callgraph
Much, much more involved than in used to be. Also shows some functions
problably should be relocated.
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: Removed UTF8 sequences from comments
Makes the documentation ruby script choke.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge pull request #197 from hovercraft-github/eeprom_boundaries
Add EEPROM address boundary checks for read/write operations
Fixes #196 : Add EEPROM address boundary checks for read/write operations
Merge pull request #198 from rlpipkin/master
adc control register write