1*20b2b626SsinceforYypackage xiangshan.backend.fu.fpu 2*20b2b626SsinceforYy 3*20b2b626SsinceforYyimport chisel3._ 4*20b2b626SsinceforYyimport chisel3.util._ 5*20b2b626SsinceforYyimport chisel3.util.experimental.decode._ 6*20b2b626SsinceforYy 7*20b2b626SsinceforYyclass FliTable(table: Seq[Int]) extends Module { 8*20b2b626SsinceforYy val src = IO(Input(UInt(5.W))) 9*20b2b626SsinceforYy val out = IO(Output(UInt(16.W))) 10*20b2b626SsinceforYy 11*20b2b626SsinceforYy out := chisel3.util.experimental.decode.decoder(src, 12*20b2b626SsinceforYy TruthTable(table.zipWithIndex.map { case(data, in) => 13*20b2b626SsinceforYy (BitPat(in.U(5.W)), BitPat(data.U(16.W))) 14*20b2b626SsinceforYy }, 15*20b2b626SsinceforYy BitPat.N(16) 16*20b2b626SsinceforYy ) 17*20b2b626SsinceforYy ) 18*20b2b626SsinceforYy} 19*20b2b626SsinceforYy 20*20b2b626SsinceforYyclass FliHTable extends FliTable( 21*20b2b626SsinceforYy Seq( 22*20b2b626SsinceforYy 0xBC00, // -1.0 23*20b2b626SsinceforYy 0x0400, // minimum positive normal 24*20b2b626SsinceforYy 0x0100, // 1.0 * 2^-16 25*20b2b626SsinceforYy 0x0200, // 1.0 * 2^-15 26*20b2b626SsinceforYy 0x1C00, // 1.0 * 2^-8 27*20b2b626SsinceforYy 0x2000, // 1.0 * 2^-7 28*20b2b626SsinceforYy 0x2C00, // 1.0 * 2^-4 29*20b2b626SsinceforYy 0x3000, // 1.0 * 2^-3 30*20b2b626SsinceforYy 0x3400, // 0.25 31*20b2b626SsinceforYy 0x3500, // 0.3125 32*20b2b626SsinceforYy 0x3600, // 0.375 33*20b2b626SsinceforYy 0x3700, // 0.4375 34*20b2b626SsinceforYy 0x3800, // 0.5 35*20b2b626SsinceforYy 0x3900, // 0.625 36*20b2b626SsinceforYy 0x3A00, // 0.75 37*20b2b626SsinceforYy 0x3B00, // 0.875 38*20b2b626SsinceforYy 0x3C00, // 1.0 39*20b2b626SsinceforYy 0x3D00, // 1.25 40*20b2b626SsinceforYy 0x3E00, // 1.5 41*20b2b626SsinceforYy 0x3F00, // 1.75 42*20b2b626SsinceforYy 0x4000, // 2.0 43*20b2b626SsinceforYy 0x4100, // 2.5 44*20b2b626SsinceforYy 0x4200, // 3 45*20b2b626SsinceforYy 0x4400, // 4 46*20b2b626SsinceforYy 0x4800, // 8 47*20b2b626SsinceforYy 0x4C00, // 16 48*20b2b626SsinceforYy 0x5800, // 2^7 49*20b2b626SsinceforYy 0x5C00, // 2^8 50*20b2b626SsinceforYy 0x7800, // 2^15 51*20b2b626SsinceforYy 0x7C00, // +inf(2^16 is not expressible) 52*20b2b626SsinceforYy 0x7C00, // +inf 53*20b2b626SsinceforYy 0x7E00 // CNaN 54*20b2b626SsinceforYy ) 55*20b2b626SsinceforYy) 56*20b2b626SsinceforYy 57*20b2b626SsinceforYyclass FliSTable extends FliTable( 58*20b2b626SsinceforYy Seq( 59*20b2b626SsinceforYy 0xBF80, // -1.0 60*20b2b626SsinceforYy 0x0080, // minimum positive normal 61*20b2b626SsinceforYy 0x3780, // 1.0 * 2^-16 62*20b2b626SsinceforYy 0x3800, // 1.0 * 2^-15 63*20b2b626SsinceforYy 0x3B80, // 1.0 * 2^-8 64*20b2b626SsinceforYy 0x3C00, // 1.0 * 2^-7 65*20b2b626SsinceforYy 0x3D80, // 1.0 * 2^-4 66*20b2b626SsinceforYy 0x3E00, // 1.0 * 2^-3 67*20b2b626SsinceforYy 0x3E80, // 0.25 68*20b2b626SsinceforYy 0x3EA0, // 0.3125 69*20b2b626SsinceforYy 0x3EC0, // 0.375 70*20b2b626SsinceforYy 0x3EE0, // 0.4375 71*20b2b626SsinceforYy 0x3F00, // 0.5 72*20b2b626SsinceforYy 0x3F20, // 0.625 73*20b2b626SsinceforYy 0x3F40, // 0.75 74*20b2b626SsinceforYy 0x3F60, // 0.875 75*20b2b626SsinceforYy 0x3F80, // 1.0 76*20b2b626SsinceforYy 0x3FA0, // 1.25 77*20b2b626SsinceforYy 0x3FC0, // 1.5 78*20b2b626SsinceforYy 0x3FE0, // 1.75 79*20b2b626SsinceforYy 0x4000, // 2.0 80*20b2b626SsinceforYy 0x4020, // 2.5 81*20b2b626SsinceforYy 0x4040, // 3 82*20b2b626SsinceforYy 0x4080, // 4 83*20b2b626SsinceforYy 0x4100, // 8 84*20b2b626SsinceforYy 0x4180, // 16 85*20b2b626SsinceforYy 0x4300, // 2^7 86*20b2b626SsinceforYy 0x4380, // 2^8 87*20b2b626SsinceforYy 0x4700, // 2^15 88*20b2b626SsinceforYy 0x4780, // 2^16 89*20b2b626SsinceforYy 0x7F80, // +inf 90*20b2b626SsinceforYy 0x7FC0 // CNaN 91*20b2b626SsinceforYy ) 92*20b2b626SsinceforYy) 93*20b2b626SsinceforYy 94*20b2b626SsinceforYyclass FliDTable extends FliTable( 95*20b2b626SsinceforYy Seq( 96*20b2b626SsinceforYy 0xBFF0, // -1.0 97*20b2b626SsinceforYy 0x0010, // minimum positive normal 98*20b2b626SsinceforYy 0x3EF0, // 1.0 * 2^-16 99*20b2b626SsinceforYy 0x3F00, // 1.0 * 2^-15 100*20b2b626SsinceforYy 0x3F70, // 1.0 * 2^-8 101*20b2b626SsinceforYy 0x3F80, // 1.0 * 2^-7 102*20b2b626SsinceforYy 0x3FB0, // 1.0 * 2^-4 103*20b2b626SsinceforYy 0x3FC0, // 1.0 * 2^-3 104*20b2b626SsinceforYy 0x3FD0, // 0.25 105*20b2b626SsinceforYy 0x3FD4, // 0.3125 106*20b2b626SsinceforYy 0x3FD8, // 0.375 107*20b2b626SsinceforYy 0x3FDC, // 0.4375 108*20b2b626SsinceforYy 0x3FE0, // 0.5 109*20b2b626SsinceforYy 0x3FE4, // 0.625 110*20b2b626SsinceforYy 0x3FE8, // 0.75 111*20b2b626SsinceforYy 0x3FEC, // 0.875 112*20b2b626SsinceforYy 0x3FF0, // 1.0 113*20b2b626SsinceforYy 0x3FF4, // 1.25 114*20b2b626SsinceforYy 0x3FF8, // 1.5 115*20b2b626SsinceforYy 0x3FFC, // 1.75 116*20b2b626SsinceforYy 0x4000, // 2.0 117*20b2b626SsinceforYy 0x4004, // 2.5 118*20b2b626SsinceforYy 0x4008, // 3 119*20b2b626SsinceforYy 0x4010, // 4 120*20b2b626SsinceforYy 0x4020, // 8 121*20b2b626SsinceforYy 0x4030, // 16 122*20b2b626SsinceforYy 0x4060, // 2^7 123*20b2b626SsinceforYy 0x4070, // 2^8 124*20b2b626SsinceforYy 0x40E0, // 2^15 125*20b2b626SsinceforYy 0x40F0, // 2^16 126*20b2b626SsinceforYy 0x7FF0, // +inf 127*20b2b626SsinceforYy 0x7FF8 // CNaN 128*20b2b626SsinceforYy ) 129*20b2b626SsinceforYy)