-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdata_Zp64.txt
49 lines (42 loc) · 2.53 KB
/
data_Zp64.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//for vX.Y of P
// low-order bit of Rd (7) is 0 to ensure even-numbered Rd
// bit 25 is used for crossing so -
I SMULx8 SMULx8 101010-----------000----01110111 pdpismul8 Zp64
I UMULx8 UMULx8 101110-----------000----01110111 pdpiumul8 Zp64
I SMULx16 SMULx16 101000-----------000----01110111 pdpismul16 Zp64
I UMULx16 UMULx16 101100-----------000----01110111 pdpiumul16 Zp64
// binary
S SMULx8 "fun_smulx8(input(SRC1), input(SRC2), input(INSTRUCTION)(25).asUInt)"
S UMULx8 "fun_umulx8(input(SRC1), input(SRC2), input(INSTRUCTION)(25).asUInt)"
S SMULx16 "fun_smulx16(input(SRC1), input(SRC2), input(INSTRUCTION)(25).asUInt)"
S UMULx16 "fun_umulx16(input(SRC1), input(SRC2), input(INSTRUCTION)(25).asUInt)"
P """
def fun_smulx8(rs1: Bits, rs2: Bits, cross: UInt) : Bits = {
val rs2x = ((cross === 0) ? (rs2) | (rs2(23 downto 16) ## rs2(31 downto 24) ## rs2(7 downto 0) ## rs2(15 downto 8)))
val h0 = (rs1( 7 downto 0).asSInt * rs2x( 7 downto 0).asSInt).asBits.resize(16)
val h1 = (rs1(15 downto 8).asSInt * rs2x(15 downto 8).asSInt).asBits.resize(16)
val h2 = (rs1(23 downto 16).asSInt * rs2x(23 downto 16).asSInt).asBits.resize(16)
val h3 = (rs1(31 downto 24).asSInt * rs2x(31 downto 24).asSInt).asBits.resize(16)
h3 ## h2 ## h1 ## h0 // return value
}
def fun_umulx8(rs1: Bits, rs2: Bits, cross: UInt) : Bits = {
val rs2x = ((cross === 0) ? (rs2) | (rs2(23 downto 16) ## rs2(31 downto 24) ## rs2(7 downto 0) ## rs2(15 downto 8)))
val h0 = (rs1( 7 downto 0).asUInt * rs2x( 7 downto 0).asUInt).asBits.resize(16)
val h1 = (rs1(15 downto 8).asUInt * rs2x(15 downto 8).asUInt).asBits.resize(16)
val h2 = (rs1(23 downto 16).asUInt * rs2x(23 downto 16).asUInt).asBits.resize(16)
val h3 = (rs1(31 downto 24).asUInt * rs2x(31 downto 24).asUInt).asBits.resize(16)
h3 ## h2 ## h1 ## h0 // return value
}
def fun_smulx16(rs1: Bits, rs2: Bits, cross: UInt) : Bits = {
val rs2x = ((cross === 0) ? (rs2) | (rs2(15 downto 0) ## rs2(31 downto 16)))
val w0 = (rs1(15 downto 0).asSInt * rs2x(15 downto 0).asSInt).asBits.resize(32)
val w1 = (rs1(31 downto 16).asSInt * rs2x(31 downto 16).asSInt).asBits.resize(32)
w1 ## w0 // return value
}
def fun_umulx16(rs1: Bits, rs2: Bits, cross: UInt) : Bits = {
val rs2x = ((cross === 0) ? (rs2) | (rs2(15 downto 0) ## rs2(31 downto 16)))
val w0 = (rs1(15 downto 0).asUInt * rs2x(15 downto 0).asUInt).asBits.resize(32)
val w1 = (rs1(31 downto 16).asUInt * rs2x(31 downto 16).asUInt).asBits.resize(32)
w1 ## w0 // return value
}
"""