Skip to content

Commit

Permalink
added testfiles for pipeline hazards
Browse files Browse the repository at this point in the history
  • Loading branch information
AngeloJacobo committed Jun 23, 2022
1 parent f6b7f0b commit 7e5f31b
Show file tree
Hide file tree
Showing 3 changed files with 270 additions and 0 deletions.
90 changes: 90 additions & 0 deletions test/extra/branch_hazard.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#
# TEST CODE FOR ADD
#
# -----------------------------------------
# Program section (known as text)
# -----------------------------------------
.text

# Start symbol (must be present), exported as a global symbol.
_start: .global _start

# Export main as a global symbol
.global main

# Label for entry point of test code
main:
### TEST CODE STARTS HERE ###

# 100 + 150 = 250 (positive answer)
li x1, 100 # set x1 to 100 (0x00000064)
nop
nop
nop
nop
nop
nop
li x2, 150 # set x2 to 150 (0x00000096)
nop
nop
nop
nop
nop
nop
add x3, x1, x2 # add x1(100) to x2(150), x3=250 (0x000000FA)
nop
nop
nop
nop
nop
nop
j pass
### END OF TEST CODE ###

# Exit test using RISC-V International's riscv-tests pass/fail criteria

fail:
li a0, 2 # set a0 (x10) to 0 to indicate a pass code
nop
nop
nop
nop
nop
nop
li a7, 93 # set a7 (x17) to 93 (5dh) to indicate reached the end of the test
nop
nop
nop
nop
nop
nop
ebreak
pass:
li a0, 0 # set a0 (x10) to 0 to indicate a pass code
nop
nop
nop
nop
nop
nop
li a7, 93 # set a7 (x17) to 93 (5dh) to indicate reached the end of the test
nop
nop
nop
nop
nop
nop
ebreak




# -----------------------------------------
# Data section. Note starts at 0x1000, as
# set by DATAADDR variable in rv_asm.bat.
# -----------------------------------------
.data

# Data section
data:

112 changes: 112 additions & 0 deletions test/extra/data_hazard.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#
# TEST CODE FOR ADD
#
# -----------------------------------------
# Program section (known as text)
# -----------------------------------------
.text

# Start symbol (must be present), exported as a global symbol.
_start: .global _start

# Export main as a global symbol
.global main

# Label for entry point of test code
main:
### TEST CODE STARTS HERE ###

# 1 NOP margin between dependent instructions

li x1, 100 # set x1 to 100 (0x00000064)
li x2, 150 # set x2 to 150 (0x00000096)
add x3, x1, x2 # add x1(100) to x2(150), x3=250 (0x000000FA)
nop
nop
nop
nop
nop
nop
li x4, 0xFA # set x4 to 0xFA (expected value for x3)
nop
nop
nop
nop
nop
nop
beqz x4, fail0 # make sure x4 has value
nop
nop
nop
nop
nop
nop
bne x3, x4, fail1 # branch to fail if not equal to expected value

# 2 NOP margin between dependent instructions
li x1, 100 # set x1 to 100 (0x00000064)
li x2, 150 # set x2 to 150 (0x00000096)
nop
nop
add x3, x1, x2 # add x1(100) to x2(150), x3=250 (0x000000FA)
nop
nop
nop
nop
nop
nop
bne x3, x4, fail2 # branch to fail if not equal to expected value

# 3 NOP margin between dependent instructions
li x1, 100 # set x1 to 100 (0x00000064)
li x2, 150 # set x2 to 150 (0x00000096)
nop
nop
nop
add x3, x1, x2 # add x1(100) to x2(150), x3=250 (0x000000FA)
nop
nop
nop
nop
nop
nop
bne x3, x4, fail3 # branch to fail if not equal to expected value

### END OF TEST CODE ###
pass:
li a0, 0 # set a0 (x10) to 0 to indicate a pass code
li a7, 93 # set a7 (x17) to 93 (5dh) to indicate reached the end of the test
ebreak

fail0:
li a0, 1 # fail code
li a7, 93 # reached end of code
ebreak

fail1:
li a0, 2 # fail code
li a7, 93 # reached end of code
ebreak

fail2:
li a0, 4 # fail code
li a7, 93 # reached end of code
ebreak

fail3:
li a0, 6 # fail code
li a7, 93 # reached end of code
ebreak




# -----------------------------------------
# Data section. Note starts at 0x1000, as
# set by DATAADDR variable in rv_asm.bat.
# -----------------------------------------
.data

# Data section
data:

68 changes: 68 additions & 0 deletions test/extra/no_hazard.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#
# TEST CODE FOR ADD
#
# -----------------------------------------
# Program section (known as text)
# -----------------------------------------
.text

# Start symbol (must be present), exported as a global symbol.
_start: .global _start

# Export main as a global symbol
.global main

# Label for entry point of test code
main:
### TEST CODE STARTS HERE ###

# 100 + 150 = 250 (positive answer)
li x1, 100 # set x1 to 100 (0x00000064)
nop
nop
nop
nop
nop
nop
li x2, 150 # set x2 to 150 (0x00000096)
nop
nop
nop
nop
nop
nop
add x3, x1, x2 # add x1(100) to x2(150), x3=250 (0x000000FA)
nop
nop
nop
nop
nop
nop
### END OF TEST CODE ###

# Exit test using RISC-V International's riscv-tests pass/fail criteria
li a0, 0 # set a0 (x10) to 0 to indicate a pass code
nop
nop
nop
nop
nop
nop
li a7, 93 # set a7 (x17) to 93 (5dh) to indicate reached the end of the test
nop
nop
nop
nop
nop
nop
ebreak

# -----------------------------------------
# Data section. Note starts at 0x1000, as
# set by DATAADDR variable in rv_asm.bat.
# -----------------------------------------
.data

# Data section
data:

0 comments on commit 7e5f31b

Please sign in to comment.