|
| 1 | +/*=======================================================================================*/ |
| 2 | +/* This Sail RISC-V architecture model, comprising all files and */ |
| 3 | +/* directories except where otherwise noted is subject the BSD */ |
| 4 | +/* two-clause license in the LICENSE file. */ |
| 5 | +/* */ |
| 6 | +/* SPDX-License-Identifier: BSD-2-Clause */ |
| 7 | +/*=======================================================================================*/ |
| 8 | + |
| 9 | +function clause currentlyEnabled(Ext_Zclsd) = hartSupports(Ext_Zilsd) & currentlyEnabled(Ext_Zca) & not(currentlyEnabled(Ext_Zcf)) & xlen == 32 |
| 10 | + |
| 11 | +// RV32Zclsd requires even register pairs |
| 12 | +function validZclsdReg(reg : regidx) -> bool = { |
| 13 | + if encdec_reg(reg)[0] == 0b1 |
| 14 | + then match rv32load_store_pair_odd_register_reserved_behavior { |
| 15 | + LoadStorePair_Fatal => reserved_behavior("Zclsd used odd-numbered register " ^ dec_str(unsigned(encdec_reg(reg)))), |
| 16 | + LoadStorePair_Illegal => return false, |
| 17 | + }; |
| 18 | + true |
| 19 | +} |
| 20 | +function validZclsdCReg(reg : cregidx) -> bool = { |
| 21 | + if encdec_creg(reg)[0] == 0b1 |
| 22 | + then match rv32load_store_pair_odd_register_reserved_behavior { |
| 23 | + LoadStorePair_Fatal => reserved_behavior("Zclsd used odd-numbered register " ^ dec_str(unsigned(encdec_creg(reg)))), |
| 24 | + LoadStorePair_Illegal => return false, |
| 25 | + }; |
| 26 | + true |
| 27 | +} |
| 28 | + |
| 29 | +/* ****************************************************************** */ |
| 30 | +union clause instruction = ZCLSD_C_LDSP : (bits(9), regidx) |
| 31 | + |
| 32 | +$[wavedrom "C.LDSP offset[5] dest offset[4:3|8:6] C2"] |
| 33 | +mapping clause encdec_compressed = ZCLSD_C_LDSP(ui86 @ ui5 @ ui43 @ 0b000, rd) |
| 34 | + <-> 0b011 @ ui5 : bits(1) @ encdec_reg(rd) @ ui43 : bits(2) @ ui86 : bits(3) @ 0b10 |
| 35 | + when currentlyEnabled(Ext_Zclsd) & validZclsdReg(rd) & rd != zreg |
| 36 | + |
| 37 | +function clause execute (ZCLSD_C_LDSP(imm, rd)) = { |
| 38 | + ExecuteAs(ZILSD_LD(zero_extend(imm), sp, rd)) |
| 39 | +} |
| 40 | + |
| 41 | +mapping clause assembly = ZCLSD_C_LDSP(uimm, rd) |
| 42 | + <-> "c.ldsp" ^ spc() ^ reg_name(rd) ^ sep() ^ hex_bits_9(uimm) |
| 43 | + when rd != zreg |
| 44 | + |
| 45 | +/* ****************************************************************** */ |
| 46 | +union clause instruction = ZCLSD_C_SDSP : (bits(9), regidx) |
| 47 | + |
| 48 | +$[wavedrom "C.SDSP offset[5:3|8:6] src C2"] |
| 49 | +mapping clause encdec_compressed = ZCLSD_C_SDSP(ui86 @ ui53 @ 0b000, rs2) |
| 50 | + <-> 0b111 @ ui53 : bits(3) @ ui86 : bits(3) @ encdec_reg(rs2) @ 0b10 |
| 51 | + when currentlyEnabled(Ext_Zclsd) & validZclsdReg(rs2) |
| 52 | + |
| 53 | +function clause execute (ZCLSD_C_SDSP(uimm, rs2)) = { |
| 54 | + ExecuteAs(ZILSD_SD(zero_extend(uimm), rs2, sp)) |
| 55 | +} |
| 56 | + |
| 57 | +mapping clause assembly = ZCLSD_C_SDSP(uimm, rs2) |
| 58 | + <-> "c.sdsp" ^ spc() ^ reg_name(rs2) ^ sep() ^ hex_bits_9(uimm) |
| 59 | + |
| 60 | +/* ****************************************************************** */ |
| 61 | +union clause instruction = ZCLSD_C_LD : (bits(8), cregidx, cregidx) |
| 62 | + |
| 63 | +$[wavedrom "C.LD offset[5:3] base offset[7:6] dest C0"] |
| 64 | +mapping clause encdec_compressed = ZCLSD_C_LD(ui76 @ ui53 @ 0b000, rs1, rd) |
| 65 | + <-> 0b011 @ ui53 : bits(3) @ encdec_creg(rs1) @ ui76 : bits(2) @ encdec_creg(rd) @ 0b00 |
| 66 | + when currentlyEnabled(Ext_Zclsd) & validZclsdCReg(rd) |
| 67 | + |
| 68 | +function clause execute (ZCLSD_C_LD(uimm, rsc, rdc)) = { |
| 69 | + let rd = creg2reg_idx(rdc); |
| 70 | + let rs = creg2reg_idx(rsc); |
| 71 | + ExecuteAs(ZILSD_LD(zero_extend(uimm), rs, rd)) |
| 72 | +} |
| 73 | + |
| 74 | +mapping clause assembly = ZCLSD_C_LD(uimm, rsc, rdc) |
| 75 | + <-> "c.ld" ^ spc() ^ creg_name(rdc) ^ sep() ^ creg_name(rsc) ^ sep() ^ hex_bits_8(uimm) |
| 76 | + |
| 77 | +/* ****************************************************************** */ |
| 78 | +union clause instruction = ZCLSD_C_SD : (bits(8), cregidx, cregidx) |
| 79 | + |
| 80 | +$[wavedrom "C.SD offset[5:3] base offset[7:6] src C0"] |
| 81 | +mapping clause encdec_compressed = ZCLSD_C_SD(ui76 @ ui53 @ 0b000, rs1, rs2) |
| 82 | + <-> 0b111 @ ui53 : bits(3) @ encdec_creg(rs1) @ ui76 : bits(2) @ encdec_creg(rs2) @ 0b00 |
| 83 | + when currentlyEnabled(Ext_Zclsd) & validZclsdCReg(rs2) |
| 84 | + |
| 85 | +function clause execute (ZCLSD_C_SD(uimm, rsc1, rsc2)) = { |
| 86 | + let rs1 = creg2reg_idx(rsc1); |
| 87 | + let rs2 = creg2reg_idx(rsc2); |
| 88 | + ExecuteAs(ZILSD_SD(zero_extend(uimm), rs2, rs1)) |
| 89 | +} |
| 90 | + |
| 91 | +mapping clause assembly = ZCLSD_C_SD(uimm, rsc1, rsc2) |
| 92 | + <-> "c.sd" ^ spc() ^ creg_name(rsc1) ^ sep() ^ creg_name(rsc2) ^ sep() ^ hex_bits_8(uimm) |
0 commit comments