2017-08-27 12:10:38 +02:00
|
|
|
import "RV32IBase.core_desc"
|
|
|
|
|
|
|
|
InsructionSet RV32A extends RV32IBase{
|
2018-04-30 19:22:00 +02:00
|
|
|
|
|
|
|
instructions{
|
|
|
|
LR.W {
|
|
|
|
encoding: b00010 | aq[0:0] | rl[0:0] | b00000 | rs1[4:0] | b010 | rd[4:0] | b0101111;
|
2018-11-24 20:29:24 +01:00
|
|
|
args_disass: "{name(rd)}, {name(rs1)}";
|
2018-04-30 19:22:00 +02:00
|
|
|
if(rd!=0){
|
|
|
|
val offs[XLEN] <= X[rs1];
|
|
|
|
X[rd]<= sext(MEM[offs]{32}, XLEN);
|
|
|
|
RES[offs]{32}<=sext(-1, 32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SC.W {
|
|
|
|
encoding: b00011 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
|
2018-11-24 20:29:24 +01:00
|
|
|
args_disass: "{name(rd)}, {name(rs1)}, {name(rs2)}";
|
2018-04-30 19:22:00 +02:00
|
|
|
val offs[XLEN] <= X[rs1];
|
|
|
|
val res1[32] <= RES[offs]{32};
|
|
|
|
if(res1!=0)
|
|
|
|
MEM[offs]{32} <= X[rs2];
|
2019-01-10 11:35:20 +01:00
|
|
|
if(rd!=0) X[rd]<= choose(res1!=zext(0, 32), 0, 1);
|
2018-04-30 19:22:00 +02:00
|
|
|
}
|
|
|
|
AMOSWAP.W{
|
|
|
|
encoding: b00001 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
|
2018-11-24 20:29:24 +01:00
|
|
|
args_disass: "{name(rd)}, {name(rs1)}, {name(rs2)} (aqu={aq},rel={rl})";
|
2018-04-30 19:22:00 +02:00
|
|
|
val offs[XLEN]<=X[rs1];
|
|
|
|
if(rd!=0) X[rd]<=sext(MEM[offs]{32});
|
|
|
|
MEM[offs]{32}<=X[rs2];
|
|
|
|
}
|
|
|
|
AMOADD.W{
|
|
|
|
encoding: b00000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
|
2018-11-24 20:29:24 +01:00
|
|
|
args_disass: "{name(rd)}, {name(rs1)}, {name(rs2)} (aqu={aq},rel={rl})";
|
2018-04-30 19:22:00 +02:00
|
|
|
val offs[XLEN]<=X[rs1];
|
|
|
|
val res1[XLEN] <= sext(MEM[offs]{32});
|
|
|
|
if(rd!=0) X[rd]<=res1;
|
|
|
|
val res2[XLEN]<=res1 + X[rs2];
|
|
|
|
MEM[offs]{32}<=res2;
|
|
|
|
}
|
|
|
|
AMOXOR.W{
|
|
|
|
encoding: b00100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
|
2018-11-24 20:29:24 +01:00
|
|
|
args_disass: "{name(rd)}, {name(rs1)}, {name(rs2)} (aqu={aq},rel={rl})";
|
2018-04-30 19:22:00 +02:00
|
|
|
val offs[XLEN]<=X[rs1];
|
|
|
|
val res1[XLEN] <= sext(MEM[offs]{32});
|
|
|
|
if(rd!=0) X[rd]<=res1;
|
|
|
|
val res2[XLEN]<=res1 ^ X[rs2];
|
|
|
|
MEM[offs]{32}<=res2;
|
|
|
|
}
|
|
|
|
AMOAND.W{
|
|
|
|
encoding: b01100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
|
2018-11-24 20:29:24 +01:00
|
|
|
args_disass: "{name(rd)}, {name(rs1)}, {name(rs2)} (aqu={aq},rel={rl})";
|
2018-04-30 19:22:00 +02:00
|
|
|
val offs[XLEN]<=X[rs1];
|
|
|
|
val res1[XLEN] <= sext(MEM[offs]{32});
|
|
|
|
if(rd!=0) X[rd]<=res1;
|
|
|
|
val res2[XLEN] <=res1 & X[rs2];
|
|
|
|
MEM[offs]{32}<=res2;
|
|
|
|
}
|
|
|
|
AMOOR.W {
|
|
|
|
encoding: b01000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
|
2018-11-24 20:29:24 +01:00
|
|
|
args_disass: "{name(rd)}, {name(rs1)}, {name(rs2)} (aqu={aq},rel={rl})";
|
2018-04-30 19:22:00 +02:00
|
|
|
val offs[XLEN]<=X[rs1];
|
|
|
|
val res1[XLEN] <= sext(MEM[offs]{32});
|
|
|
|
if(rd!=0) X[rd]<=res1;
|
|
|
|
val res2[XLEN]<=res1 | X[rs2];
|
|
|
|
MEM[offs]{32}<=res2;
|
|
|
|
}
|
|
|
|
AMOMIN.W{
|
|
|
|
encoding: b10000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
|
2018-11-24 20:29:24 +01:00
|
|
|
args_disass: "{name(rd)}, {name(rs1)}, {name(rs2)} (aqu={aq},rel={rl})";
|
2018-04-30 19:22:00 +02:00
|
|
|
val offs[XLEN]<=X[rs1];
|
|
|
|
val res1[XLEN] <= sext(MEM[offs]{32});
|
2019-01-10 11:35:20 +01:00
|
|
|
if(rd!=0) X[rd] <= res1;
|
|
|
|
val res2[XLEN] <= choose(res1's > X[rs2]s, X[rs2], res1);
|
|
|
|
MEM[offs]{32} <= res2;
|
2018-04-30 19:22:00 +02:00
|
|
|
}
|
|
|
|
AMOMAX.W{
|
|
|
|
encoding: b10100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
|
2018-11-24 20:29:24 +01:00
|
|
|
args_disass: "{name(rd)}, {name(rs1)}, {name(rs2)} (aqu={aq},rel={rl})";
|
2018-04-30 19:22:00 +02:00
|
|
|
val offs[XLEN]<=X[rs1];
|
|
|
|
val res1[XLEN] <= sext(MEM[offs]{32});
|
|
|
|
if(rd!=0) X[rd]<=res1;
|
|
|
|
val res2[XLEN]<= choose(res1's<X[rs2]s, X[rs2], res1);
|
|
|
|
MEM[offs]{32}<=res2;
|
|
|
|
}
|
|
|
|
AMOMINU.W{
|
|
|
|
encoding: b11000 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
|
2018-11-24 20:29:24 +01:00
|
|
|
args_disass: "{name(rd)}, {name(rs1)}, {name(rs2)} (aqu={aq},rel={rl})";
|
2018-04-30 19:22:00 +02:00
|
|
|
val offs[XLEN]<=X[rs1];
|
2019-01-10 11:35:20 +01:00
|
|
|
val res1[XLEN] <= sext(MEM[offs]{32});
|
2018-04-30 19:22:00 +02:00
|
|
|
if(rd!=0) X[rd]<=res1;
|
|
|
|
val res2[XLEN]<= choose(res1>X[rs2], X[rs2], res1);
|
|
|
|
MEM[offs]{32}<=res2;
|
|
|
|
}
|
|
|
|
AMOMAXU.W{
|
|
|
|
encoding: b11100 | aq[0:0] | rl[0:0] | rs2[4:0] | rs1[4:0] | b010 | rd[4:0] | b0101111;
|
2018-11-24 20:29:24 +01:00
|
|
|
args_disass: "{name(rd)}, {name(rs1)}, {name(rs2)} (aqu={aq},rel={rl})";
|
2018-04-30 19:22:00 +02:00
|
|
|
val offs[XLEN]<=X[rs1];
|
2019-01-10 11:35:20 +01:00
|
|
|
val res1[XLEN] <= sext(MEM[offs]{32});
|
|
|
|
if(rd!=0) X[rd] <= res1;
|
|
|
|
val res2[XLEN] <= choose(res1 < X[rs2], X[rs2], res1);
|
|
|
|
MEM[offs]{32} <= res2;
|
2018-04-30 19:22:00 +02:00
|
|
|
}
|
|
|
|
}
|
2017-08-27 12:10:38 +02:00
|
|
|
}
|