// -----------
// This file was generated by riscv_ctg (https://gitlab.com/incoresemi/riscv-compliance/riscv_ctg)
// version   : 0.5.1
// timestamp : Mon Aug  2 08:58:53 2021 GMT
// usage     : riscv_ctg \
//                  --cgf /home/bilalsakhawat/riscv-ctg/sample_cgfs/dataset.cgf \
//                  --cgf /home/bilalsakhawat/riscv-ctg/sample_cgfs/rv32e.cgf \
//                  --base-isa rv32e \
//                  --randomize
// -----------
//
// -----------
// Copyright (c) 2020. RISC-V International. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
// -----------
//
// This assembly file tests the lh instruction of the RISC-V E extension for the lh-align covergroup.
// 
#include "model_test.h"
#include "arch_test.h"
RVTEST_ISA("RV32E")

.section .text.init
.globl rvtest_entry_point
rvtest_entry_point:
RVMODEL_BOOT
RVTEST_CODE_BEGIN

#ifdef TEST_CASE_1

RVTEST_CASE(0,"//check ISA:=regex(.*32.*);check ISA:=regex(.*E.*) ;def RVTEST_E = True;def TEST_CASE_1=True;",lh-align)

RVTEST_SIGBASE( x4,signature_x4_1)

inst_0:
// rs1 != rd, rs1==x3, rd==x2, ea_align == 0 and (imm_val % 4) == 0, imm_val == 0
// opcode:lh op1:x3; dest:x2; immval:0x0; align:0
TEST_LOAD(x4,x5,0,x3,x2,0x0,0,lh,0)

inst_1:
// rs1 == rd, rs1==x15, rd==x15, ea_align == 0 and (imm_val % 4) == 1, imm_val > 0
// opcode:lh op1:x15; dest:x15; immval:0x5; align:0
TEST_LOAD(x4,x5,0,x15,x15,0x5,4,lh,0)

inst_2:
// rs1==x12, rd==x14, ea_align == 0 and (imm_val % 4) == 2, imm_val < 0
// opcode:lh op1:x12; dest:x14; immval:-0x556; align:0
TEST_LOAD(x4,x5,0,x12,x14,-0x556,8,lh,0)

inst_3:
// rs1==x14, rd==x8, ea_align == 0 and (imm_val % 4) == 3, 
// opcode:lh op1:x14; dest:x8; immval:0x3ff; align:0
TEST_LOAD(x4,x5,0,x14,x8,0x3ff,12,lh,0)

inst_4:
// rs1==x10, rd==x3, ea_align == 2 and (imm_val % 4) == 0, 
// opcode:lh op1:x10; dest:x3; immval:-0x8; align:2
TEST_LOAD(x4,x5,0,x10,x3,-0x8,16,lh,2)

inst_5:
// rs1==x6, rd==x1, ea_align == 2 and (imm_val % 4) == 1, 
// opcode:lh op1:x6; dest:x1; immval:0x555; align:2
TEST_LOAD(x4,x5,0,x6,x1,0x555,20,lh,2)

inst_6:
// rs1==x13, rd==x6, ea_align == 2 and (imm_val % 4) == 2, 
// opcode:lh op1:x13; dest:x6; immval:-0x6; align:2
TEST_LOAD(x4,x5,0,x13,x6,-0x6,24,lh,2)

inst_7:
// rs1==x1, rd==x9, ea_align == 2 and (imm_val % 4) == 3, 
// opcode:lh op1:x1; dest:x9; immval:0x7ff; align:2
TEST_LOAD(x4,x5,0,x1,x9,0x7ff,28,lh,2)

inst_8:
// rs1==x9, rd==x0, 
// opcode:lh op1:x9; dest:x0; immval:-0x800; align:0
TEST_LOAD(x4,x3,0,x9,x0,-0x800,32,lh,0)

inst_9:
// rs1==x5, rd==x12, 
// opcode:lh op1:x5; dest:x12; immval:-0x800; align:0
TEST_LOAD(x4,x3,0,x5,x12,-0x800,36,lh,0)
RVTEST_SIGBASE( x1,signature_x1_0)

inst_10:
// rs1==x8, rd==x11, 
// opcode:lh op1:x8; dest:x11; immval:-0x800; align:0
TEST_LOAD(x1,x3,0,x8,x11,-0x800,0,lh,0)

inst_11:
// rs1==x11, rd==x4, 
// opcode:lh op1:x11; dest:x4; immval:-0x800; align:0
TEST_LOAD(x1,x3,0,x11,x4,-0x800,4,lh,0)

inst_12:
// rs1==x2, rd==x7, 
// opcode:lh op1:x2; dest:x7; immval:-0x800; align:0
TEST_LOAD(x1,x3,0,x2,x7,-0x800,8,lh,0)

inst_13:
// rs1==x4, rd==x10, 
// opcode:lh op1:x4; dest:x10; immval:-0x800; align:0
TEST_LOAD(x1,x3,0,x4,x10,-0x800,12,lh,0)

inst_14:
// rs1==x7, rd==x5, 
// opcode:lh op1:x7; dest:x5; immval:-0x800; align:0
TEST_LOAD(x1,x3,0,x7,x5,-0x800,16,lh,0)

inst_15:
// rd==x13, 
// opcode:lh op1:x12; dest:x13; immval:-0x800; align:0
TEST_LOAD(x1,x3,0,x12,x13,-0x800,20,lh,0)
#endif


RVTEST_CODE_END
RVMODEL_HALT

RVTEST_DATA_BEGIN
.align 4

rvtest_data:
.word 0xbabecafe
.word 0xbabecafe
.word 0xbabecafe
.word 0xbabecafe
RVTEST_DATA_END


RVMODEL_DATA_BEGIN
rvtest_sig_begin:
sig_begin_canary:
CANARY;


signature_x4_0:
    .fill 0*(XLEN/32),4,0xdeadbeef


signature_x4_1:
    .fill 10*(XLEN/32),4,0xdeadbeef


signature_x1_0:
    .fill 6*(XLEN/32),4,0xdeadbeef

#ifdef rvtest_mtrap_routine

tsig_begin_canary:
CANARY;
mtrap_sigptr:
    .fill 64*(XLEN/32),4,0xdeadbeef
tsig_end_canary:
CANARY;

#endif

#ifdef rvtest_gpr_save

gpr_save:
    .fill 32*(XLEN/32),4,0xdeadbeef

#endif

sig_end_canary:
CANARY;
rvtest_sig_end:
RVMODEL_DATA_END
