2021-04-04 18:09:13 +00:00
|
|
|
//performs the fsgnj/fsgnjn/fsgnjx RISCV instructions
|
|
|
|
|
2021-07-14 21:56:49 +00:00
|
|
|
module fsgn (
|
|
|
|
input logic XSgnE, YSgnE,
|
|
|
|
input logic [10:0] XExpE,
|
|
|
|
input logic [51:0] XFracE,
|
|
|
|
input logic XExpMaxE,
|
|
|
|
input logic FmtE,
|
2021-07-02 16:40:58 +00:00
|
|
|
input logic [1:0] SgnOpCodeE,
|
|
|
|
output logic [63:0] SgnResE,
|
|
|
|
output logic SgnNVE);
|
2021-04-04 18:09:13 +00:00
|
|
|
|
2021-07-02 16:40:58 +00:00
|
|
|
logic AonesExp;
|
2021-07-14 21:56:49 +00:00
|
|
|
logic ResSgn;
|
2021-04-04 18:09:13 +00:00
|
|
|
|
|
|
|
//op code designation:
|
|
|
|
//
|
2021-07-14 21:56:49 +00:00
|
|
|
//00 - fsgnj - directly copy over sign value of FSrcYE
|
|
|
|
//01 - fsgnjn - negate sign value of FSrcYE
|
|
|
|
//10 - fsgnjx - XOR sign values of FSrcXE & FSrcYE
|
2021-04-04 18:09:13 +00:00
|
|
|
//
|
|
|
|
|
2021-07-14 21:56:49 +00:00
|
|
|
assign ResSgn = SgnOpCodeE[1] ? (XSgnE ^ YSgnE) : (YSgnE ^ SgnOpCodeE[0]);
|
|
|
|
assign SgnResE = FmtE ? {ResSgn, XExpE, XFracE} : {{32{1'b1}}, ResSgn, XExpE[7:0], XFracE[51:29]};
|
2021-04-04 18:09:13 +00:00
|
|
|
|
|
|
|
//If the exponent is all ones, then the value is either Inf or NaN,
|
|
|
|
//both of which will produce a QNaN/SNaN value of some sort. This will
|
|
|
|
//set the invalid flag high.
|
|
|
|
|
|
|
|
//the only flag that can occur during this operation is invalid
|
|
|
|
//due to changing sign on already existing NaN
|
2021-07-14 21:56:49 +00:00
|
|
|
assign SgnNVE = XExpMaxE & SgnResE[63];
|
2021-04-04 18:09:13 +00:00
|
|
|
|
|
|
|
endmodule
|