Using the ArchC ARMv7 platform simulator


Background

ArchC is a framework to create single process virtual machines by describing the modeled architecture using a high level description language. Number and size of registers, instruction encoding, memory devices and several other architectural details can be described using ArchC.

Nevertheless, ArchC was limited to describe the processor core and a few other things, and wasn't capable of generating more complex platform virtual machines, capable of executing a full operating system, for example.

In this project, we used an ARMv7 core modeled in ArchC and implemented several other peripherals and SoC components required to fully simulate a Freescale iMX53 Quick Start Board. These include functional modules such as Memory Management Units, UARTs, Storage devices, and buses and also some modules to improve the simulator performance, such as simulated TLBs and cache for instructions already decoded. Our goal was to boot a full GNU/Linux under the simulated environment.

The simulator is used since 2013 to teach computer architecture and Assembly language for undergraduate students at UNICAMP. In this course, students are required to implement several parts of the operating system, such as device drivers, schedulers, syscall handlers, and some userland programs in ARM Assembly. All their code is run on the simulator, allowing them to collect information and data about their programs that could not be available otherwise.

The development of this first platform simulator based on ArchC allowed us to identify some deficiencies in ArchC in describing complex models. As a result several modules where included in the ArchC framework, such as a new Decoder Unit and a cache for decoded instructions with support for self-modifying code.

All of the simulator code, the ROM code to perform bootstrapping and the small operating System we created for use in the classroom, are available under a GPLv3 license at my Gitweb page.

ARMv7

The ARMv7 Simulator is written in ArchC and C++, and models several devices other than the core, itself. Currently, the following devices are modeled:

  • ARMv7 Cortex A8 Core
  • Coprocessors
  • Buses
  • Memory Management UNit
  • SD controllers
  • UARTs
  • General Purpose Timers
  • Memories
  • ...

The Figure below shows an schematics of the implemented modules.

armv7_model_architectural_overview.png

Publications

BERTAZI, G. ; AULER, R. ; BORIN, E. . Uma plataforma para o ensino de organização de computadores e linguagem de montagem. International Journal of Computer Architecture Education , v. 3, p. 13, 2014.1 Paper, Presentation

Installation

ArchC

git clone git://git.krisman.be/archc.git

Just do

./configure
make
make install

Simulator and some utilities.

git clone git://git.krisman.be/armv7.git

Installation steps:

./configure
make
make install

Dumboot

This is loaded to ROM during the simulator start up and is responsible for detecting the boot device and loading the next step of the boot chain. It follows the specification for iMX53, and can boot any compatible image, such as U-boot bootloader with some operating system payload.

git clone git://git.krisman.be/dumboot.git

Obviously, you are going to need a cross-compiler to build this. But once you have it all set up, just do

make CROSS_COMPILER=<prefix to cross>

DummyOS

TODO! :-)

Generating a SD image

In the simulator repository there are some tools to generate compatible images. Assuming you want to generate an image for your own small OS, one can simply do:

mksd.sh --os=<path_to_os> -o card.img

Running the simulator

Boot from a SD card

arm-sim --rom=dumboot.img --sd=card.img

Make simulator wait for a GDB connection

arm-sim --rom=dumboot.img --sd=card.img --gdb --gdb-port 5000

Enable debug information for some units.

arm-sim --rom=dumboot.img --sd=card.img --debug=core,mmu,uart

For further documentation, check the manual in the source or invoke arm-sim --help

Contribute

If you think you have found a bug or you want to contribute with this project, you can send your comments and patches to <archc@googlegroups.com>. If your patch is related to the ARM model, ArchC platform stuff or to Dumboot/DummyOS, please Cc: me directly, as well.

Boot Sequence

bootprocess.png

Footnotes:

1

This was presented at the "Workshop de Ensino em Arquiteturas de Computadores" during the "XV Simpósio em Sistemas Computacionais de Alto Desempenho". S. José dos Campos. Brazil. 2013.