Averest


Abacus Module

This module implements functions for simulating Abacus assembler programs. The core is thereby the definition of the computer system's state, and the instruction set semantics in terms of operationally changing the system's state when executing an instruction.

Types

Type Description

AbacusState

AbacusState holds the information of the memory contents of an Abacus system after executing an instruction, i.e.,

  • instr is the instruction that has generated this state
  • prgCounter is the value of the program counter
  • overflwReg is the content of the overflow register of Abacus
  • sclRegs[i] holds the content of the scalar register i, which has type byte[] whose length is DataWidth/8
  • dataCache is an array of cacheblocks
  • mainMem is the main memory, i.e., an array of blocks (since the memory transfer to the data cache is done in blocks)
  • branchTaken indicates whether the instruction that generated this state was a conditional branch and whether it was taken or not (None:no branch; Some true: branch that was taken; Some false branch that was not taken)
  • wasCacheHit indicates whether the instruction that generated this state was a cache hit (Some true), a cache miss (Some false), or no memory instruction (None).
  • cacheHits counts the number of cache hits so far including this instruction
  • cacheMisses counts the number of cache misses so far including this instruction
  • writeBacks counts the number of write backs so far including this instruction (this is the number of replaced dirty blocks)

SimulationRun

a SimulationRun holds the result of a complete simulation of an Abacus program, i.e.,

  • error indicates whether the simulation has been aborted due to an exception like an access to an invalid memory address.
  • trace is the sequence of AbacusStates that were obtained after executing the single instructions of the program
  • instrCount[l] is the number of executions of the instruction in line l in total
  • nopCount[l] is the number of nop instructions that had to be inserted before instruction in line l i total
  • branchTaken[l] is only different to zero if the instruction at line l is a conditional branch instruction. In this case, this is the number of how often the branch has been taken, and thus, the difference of instrCount[l] and branchTaken[l] tells us how often the branch has not been taken.

address

block

cacheBlock

a cache block consists of the following components:

  • valid indicates that the block is used (i.e. holds data)
  • dirty indicates that the block in cache has been modified, i.e., it is no longer consistent with the main memory and must therefore be written back before another block is replacing it
  • tag is the tag of the cache block to reconstruct its address
  • data holds the bytes of the cache block (its size is param.BlockSize)

Functions and values

Function or value Description

AbacusConflictAnalysis p

Full Usage: AbacusConflictAnalysis p

Parameters:
Returns: AbacusInstr[] * Set<int * int> * Set<int * int * int>

compute the control flow graph with RAW conflicts of an Abacus program

p : AbacusInstr[]
Returns: AbacusInstr[] * Set<int * int> * Set<int * int * int>

AbacusConflicts2Dot ostr (p, nextInstr, rawConfl)

Full Usage: AbacusConflicts2Dot ostr (p, nextInstr, rawConfl)

Parameters:

write control flow graph with conflicts to a dot file

ostr : TextWriter
p : AbacusInstr[]
nextInstr : seq<int * int>
rawConfl : seq<int * int * int>

ExecuteInstr instr st

Full Usage: ExecuteInstr instr st

Parameters:

ExecuteInstr implements the semantics of the Abacus instruction set in that it updates the given AbacusState with the changes made by executing the Abacus instruction instr. Note that it changes the contents of the given AbacusState directly, and therefore, there is no return value.

instr : AbacusInstr
st : AbacusState

ExecuteProgram maxSteps p

Full Usage: ExecuteProgram maxSteps p

Parameters:
Returns: SimulationRun

ExecuteProgram repeatedly applies function ExecuteInstr to run a Abacus program p. If maxSteps is negative, the program is run until it finally terminates (which is the case when the program counter is outside the the range of the program's indices), and otherwise, the number of execution steps is limited to maxSteps. The result is a SimulationRun. In case of pipeline conflicts, a nop instruction is inserted instead of the next instruction where AbcJ(1) is used as nop instruction.

maxSteps : int
p : AbacusInstr[]
Returns: SimulationRun

PrintAbacusState ostr st

Full Usage: PrintAbacusState ostr st

Parameters:

PrintAbacusState prints the contents of memory, cache and registers to the output stream ostr in a tabular notation.

ostr : TextWriter
st : AbacusState

PrintSimResult ostr p simResult

Full Usage: PrintSimResult ostr p simResult

Parameters:

PrintSimResult prints a SimulationRun generated for the Abacus program p to output stream ostr. Additional information like the instruction counts (with taken branches) and data conflicts that need stalling in a pipelined execution are printed first, and then the AbacusStates of the SimulationRun follow.

ostr : TextWriter
p : AbacusInstr[]
simResult : SimulationRun

RandomAbacusProg rand (aluP, memP, brcP, jmpP) pLen

Full Usage: RandomAbacusProg rand (aluP, memP, brcP, jmpP) pLen

Parameters:
    rand : Random
    aluP : float
    memP : float
    brcP : float
    jmpP : 'a
    pLen : int

Returns: AbacusInstr[]

generate a random Abacus program with random number generator rand and probabilities aluP,memP,brcP,jmpP for ALU, memory,branch, and jump instructions, respectively with pLen many instructions in total.

rand : Random
aluP : float
memP : float
brcP : float
jmpP : 'a
pLen : int
Returns: AbacusInstr[]

SimulFile toLogFile maxSteps progfile saveXmlTrace

Full Usage: SimulFile toLogFile maxSteps progfile saveXmlTrace

Parameters:
    toLogFile : bool
    maxSteps : int
    progfile : string
    saveXmlTrace : bool

SimulFile first parses an Abacus program from the file progfile, then simulates it using function ExecuteProgram and the parameter maxSteps as explained there. After this, the obtained SimulationRun is either printed to Console.Out or alternatively to a log-file with the same name as progfile (just with suffix log instead). If saveXmlTrace is true, then the SimulationRun is additionally written to an xml file (again with the same name and suffix xml).

toLogFile : bool
maxSteps : int
progfile : string
saveXmlTrace : bool

getSvgGraph dotExe dotGraphWriter

Full Usage: getSvgGraph dotExe dotGraphWriter

Parameters:
Returns: string

getSvgGraph converts dot graphs to a svg graphic which is returned as a string. Expected arguments are dotExe which is the path of the executable of dot like "/usr/bin/dot" and dotGraphWriter which is a function that will write a dot graph to a stream.

dotExe : string
dotGraphWriter : StreamWriter -> unit
Returns: string

param

Full Usage: param

Returns: AbcParamsType

The global variable param holds all parameters of the Abacus system, and is initialized with default values by the parser if no parameters were listed in the Abacus file.

Returns: AbcParamsType

printLatexTable allPipeStages sim

Full Usage: printLatexTable allPipeStages sim

Parameters:

print a simulation run in form of a Latex table where the pipeline stages are shown in each step

allPipeStages : bool
sim : SimulationRun