Our software architecture will attempt to roughly imitate the functional architecture of a real core.
At this stage of development, we content ourselves with modeling the processor core alone.
A processor core possesses four components:
- registers
- an instruction pipeline: three-stage for the Cortex-M0 (fetch-decode-execute)
- an arithmetic and logic unit (ALU)
- a clock, driving its operation
We choose to model the clock as a standalone component. Right now, its sole purpose will be to "instruct" the processor core so as to advance its operation. The processor core fetches instructions from memory, decodes them, and executes them.
We define a single generic ArmCore struct, which contain fields corresponding to the registers, a reset function pointer, and an advance function pointer. The reset function performs operations to be executed on reset prior to execution of the reset handler. The advance function is the one called by the clock; under the hood, it will be the one to advance the instruction pipeline.