PASSING ALL TEST CASES

This commit is contained in:
felsabbagh3 2019-02-11 01:02:09 -05:00
parent 2c1f61196a
commit 3ac246ae6a
3 changed files with 29 additions and 13 deletions

View file

@ -313,12 +313,13 @@ Instruction *WordDecoder::decode(const std::vector<Byte> &v, Size &idx) {
case InstType::I_TYPE:
inst.setDestReg((code>>shift_rd) & reg_mask);
inst.setSrcReg((code>>shift_rs1) & reg_mask);
inst.setFunc7 ((code>>shift_func7) & func7_mask);
func3 = (code>>shift_func3) & func3_mask;
inst.setFunc3 (func3);
if ((func3 == 5) && (op != L_INST))
{
// std::cout << "func7: " << func7 << "\n";
inst.setSrcImm(signExt(((code>>shift_rs2)&reg_mask), 5, reg_mask));
}
else

View file

@ -292,18 +292,33 @@ void Instruction::executeOn(Warp &c) {
reg[rdest].trunc(wordSz);
break;
case 5:
if (!func7)
if ((func7 == 0))
{
// SRAI
op1 = reg[rsrc[0]];
op2 = immsrc;
reg[rdest] = op1 >> op2;
// SRLI
// std::cout << "WTF\n";
bool isNeg = ((0x80000000 & reg[rsrc[0]])) > 0;
Word result = Word_u(reg[rsrc[0]]) >> Word_u(immsrc);
// if (isNeg)
// {
// Word mask = 0x80000000;
// for (int i = 32; i < Word_u(immsrc); i++)
// {
// result |= mask;
// mask = mask >> 1;
// }
// }
reg[rdest] = result;
reg[rdest].trunc(wordSz);
}
else
{
// SRLI
reg[rdest] = Word_u(reg[rsrc[0]]) >> Word_u(immsrc);
// SRAI
// std::cout << "WOHOOOOO\n";
op1 = reg[rsrc[0]];
op2 = immsrc;
reg[rdest] = op1 >> op2;
reg[rdest].trunc(wordSz);
}
break;

View file

@ -342,14 +342,14 @@ GRADE: PASSED
./riscv_tests/rv32ui-p-srai.hex
INTERRUPT ECALL/EBREAK
Total steps: 41
Total insts: 41
Total steps: 244
Total insts: 244
=== Warp 0 ===
Steps : 41
Insts : 41
Steps : 244
Insts : 244
Loads : 0
Stores: 0
GRADE: FAILED 3
GRADE: PASSED
./riscv_tests/rv32ui-p-srl.hex
INTERRUPT ECALL/EBREAK