-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccbfff6
commit ccd7ac4
Showing
8 changed files
with
115 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.text | ||
.globl main | ||
main: | ||
li t0, 0 | ||
fcvt.s.w ft0, t0 | ||
li t0, 1 | ||
fcvt.s.w ft1, t0 | ||
|
||
printf "ft0 = {}, ft1 = {}", ft0, ft1 | ||
// repeat 100 times | ||
li t0, 99 | ||
frep.i t0, 1, 0, 0 | ||
fadd.s ft0, ft0, ft1 // add one | ||
printf "100 * 1 = {}", ft1 | ||
|
||
li a0, 0 | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// RUN: python3 -m snitch %s -o libc | filecheck %s | ||
|
||
.data | ||
|
||
vec0: | ||
.word 0x0, 0x3f800000, 0x40000000, 0x40400000, 0x40800000, 0x40a00000, 0x40c00000, 0x40e00000, 0x41000000, 0x41100000 | ||
vec1: | ||
.word 0x0, 0x3f800000, 0x40000000, 0x40400000, 0x40800000, 0x40a00000, 0x40c00000, 0x40e00000, 0x41000000, 0x41100000 | ||
dest: | ||
.space 40 | ||
|
||
.text | ||
.globl main | ||
|
||
main: | ||
// ssr config | ||
ssr.configure 0, 10, 4 | ||
ssr.configure 1, 10, 4 | ||
ssr.configure 2, 10, 4 | ||
|
||
la a0, vec0 | ||
ssr.read a0, 0, 0 | ||
|
||
la a0, vec1 | ||
ssr.read a0, 1, 0 | ||
|
||
la a0, dest | ||
ssr.write a0, 2, 0 | ||
|
||
ssr.enable | ||
|
||
// set up loop | ||
li a0, 10 | ||
loop: | ||
fadd.s ft2, ft0, ft1 | ||
|
||
addi a0, a0, -1 | ||
bne a0, zero, loop | ||
|
||
// end of loop: | ||
ssr.disable | ||
|
||
// check values were written correctly: | ||
la t0, vec0 | ||
la t1, vec1 | ||
li a0, 40 | ||
loop2: | ||
add s0, t0, a0 | ||
add s1, t1, a0 | ||
// load vec0 element | ||
flw ft0, 0(s0) | ||
// load vec1 element | ||
flw ft1, 0(s1) | ||
// assert ft1 - ft0 == ft0 | ||
fsub.s ft2, ft1, ft0 | ||
feq.s s0, ft2, ft0 | ||
beq zero, s0, fail | ||
|
||
addi a0, a0, -4 | ||
bne a0, zero, loop2 | ||
|
||
ret | ||
|
||
fail: | ||
printf "failed {} != {} (at {})", ft0, ft1, a0 | ||
li a0, -1 | ||
ret | ||
|
||
// CHECK: [CPU] Program exited with code 0 |
This file was deleted.
Oops, something went wrong.