please ignore the title.
what i am trying to code is a program counter which keeps the address and increment to the next instruction which is in instruction memory, now the instruction is in segments of different byte but from the instruction memory two values should come out named as rs1 and rs2 which goes in the register and from there it goes into the ALU for add and sub operation. ia mvery new to c++ please help me. There are only two instruction in the insturction memory and registerfile is 32 bit wide.
#include<ap_int.h>
//ProgramCounter increment next instruction and stores address
int Increment *pProgramcounter = &Instructionadress;
//Instruction Memory
Union TypeofInsturct
{
struct rInst
{ap_int<7> func7; //MSB
int rs1;
int rs2;
ap_int<3> func3;
int rd;
ap_int<7> opcode }; //LSB
}TypeofInstrct;
int main ()
{
rInst Add = {0000000,00101,01111,000,10000,0110011};
rInst Sub = {0000000,00101,01111,000,10000,0110100};
};
};
pProgramcounter++;
//Regfile
GReg_Values [10] = {
/* X1 JALR useage addr*/ 0,
/* X2*/ 0,
/* X3*/ 0,
/* X4*/ 0,
/* X5*/ 0,
/* X6*/ 0,
/* X7*/ 0,
/* X8*/ 0,
/* X9*/ 0,
/* X10*/ 0,
} ;
//ALU
void ALU (rInst (Add)){
switch (opcode) {
case Add
result1= rs1+rs2;
break;
case sub
result2 = rs1-rs2;
break;
default:
// generate error
}
Aucun commentaire:
Enregistrer un commentaire