#ifndef _instq_fs
#define _instq_fs
/******************************************************************************
** FILE: instq.fs
** Datatypes and queues to implement an out-of-order execution engine.
*/

#include "param.h"
#include "rename_types.fs"

//
// InstOp: translated instruction data.

type InstOp = struct {
    pc : stream,		// instruction address
    npc : stream,		// next instruction address
    srcq : SrcRef queue,	// source data description
    destq : DestRef queue,	// destination register description
    op : ushort,		// internal instruction operator tag
    ftype : uchar,		// function unit type to use
    ftime : uchar,		// time left in function unit
    taken : bool,		// branch is taken
    delta : char,		// change CWP0 by this delta on retire
    trap : bool,		// trap to OS
    done : bool,		// flag to trigger exit from main
    align : uchar		// log2 width of mem accesses (for alignment)
};

// Out-of-order instruction queue. [RT_STAT]
val instq : InstOp queue = queue(OOLIMIT){};

fun init_inst(var inst : InstOp, pc, npc)
{
    inst.pc = pc;
    inst.npc = npc;
    inst.srcq?clear();
    inst.destq?clear();
    inst.op = 0?cvt(ushort);
    inst.ftype = 0?cvt(uchar);
    inst.ftime = 0?cvt(uchar);
    inst.taken = false;
    inst.delta = 0?cvt(char);
    inst.trap = false;
    inst.done = false;
    inst.align = 0?cvt(uchar);
}

#endif