Skip to content
Open

Lk1 #30

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions asm/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def write(token, value, bits):
elif kind == 'i20':
value = self.parse_int(20, token)
write(token, value, 20)
elif kind == 'p4':
write(token, 0, 4)
elif kind == 'p8':
write(token, 0, 8)
elif kind == 'p16':
Expand Down
8 changes: 5 additions & 3 deletions asm/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,14 @@ def read(bits):
result.append(read(16))
elif kind == 'i20':
result.append(read(20))
elif kind == 'p4':
read(4)
elif kind == 'p8':
pass
read(8)
elif kind == 'p16':
pass
read(16)
elif kind == 'p20':
pass
read(20)
else:
raise Exception(f'Illegal parameter type: {kind}')

Expand Down
14 changes: 10 additions & 4 deletions examples/with-load-store-vadd.bf16.asm
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ def finalize(host):

# Load 0x200000 into A
seti %a 0x20 # (128) / 4
seti %b 0x4000 # 0x200000 / 128
# seti %b 0x4000 # 0x200000 / 128
seti_low %b 0x4000 # 0x200000 / 128
seti_high %b 0x0000 # 0x200000 / 128
seti %c 1024 # (2048 * 2) / 4
load %a %b %c

# Load 0x201000 into B
seti %a 0x420 # (128 + 4096) / 4
seti %b 0x4020 # 0x201000 / 128
# seti %b 0x4020 # 0x201000 / 128
seti_low %b 0x4020 # 0x201000 / 128
seti_high %b 0x0000 # 0x201000 / 128
seti %c 1024 # (2048 * 2) / 4
load %a %b %c

Expand All @@ -48,8 +52,10 @@ seti %d 2048 # count is 2048

vadd.bf16 %c %a %b %d

# Store C to 0x202000
seti %a 0x4040 # 0x202000 / 128
# Store C to 0x202000 0x203000 0x204000 0x205000
# seti %a 0x4040 # 0x202000 / 128
seti_low %a 0x4040 # 0x202000 / 128 0x4040 0x4060 0x4080 0x40a0
seti_high %a 0x0000 # 0x202000 / 128
seti %b 0x820 # (128 + 4096 + 4096) / 4
seti %c 1024 # (2048 * 2) / 4
store %a %b %c
Expand Down
12 changes: 9 additions & 3 deletions examples/with-load-store-vdiv.bf16.asm
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ def finalize(host):

# Load 0x200000 into A
seti %a 0x20 # (128) / 4
seti %b 0x4000 # 0x200000 / 128
# seti %b 0x4000 # 0x200000 / 128
seti_low %b 0x4000 # 0x200000 / 128
seti_high %b 0x0000 # 0x200000 / 128
seti %c 1024 # (2048 * 2) / 4
load %a %b %c

# Load 0x201000 into B
seti %a 0x420 # (128 + 4096) / 4
seti %b 0x4020 # 0x201000 / 128
# seti %b 0x4020 # 0x201000 / 128
seti_low %b 0x4020 # 0x201000 / 128
seti_high %b 0x0000 # 0x201000 / 128
seti %c 1024 # (2048 * 2) / 4
load %a %b %c

Expand All @@ -49,7 +53,9 @@ seti %d 2048 # count is 2048
vdiv.bf16 %c %a %b %d

# Store C to 0x202000
seti %a 0x4040 # 0x202000 / 128
# seti %a 0x4040 # 0x202000 / 128
seti_low %a 0x4040 # 0x202000 / 128
seti_high %a 0x0000 # 0x202000 / 128
seti %b 0x820 # (128 + 4096 + 4096) / 4
seti %c 1024 # (2048 * 2) / 4
store %a %b %c
Expand Down
12 changes: 9 additions & 3 deletions examples/with-load-store-vmul.bf16.asm
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ def finalize(host):

# Load 0x200000 into A
seti %a 0x20 # (128) / 4
seti %b 0x4000 # 0x200000 / 128
# seti %b 0x4000 # 0x200000 / 128
seti_low %b 0x4000 # 0x200000 / 128
seti_high %b 0x0000 # 0x200000 / 128
seti %c 1024 # (2048 * 2) / 4
load %a %b %c

# Load 0x201000 into B
seti %a 0x420 # (128 + 4096) / 4
seti %b 0x4020 # 0x201000 / 128
# seti %b 0x4020 # 0x201000 / 128
seti_low %b 0x4020 # 0x201000 / 128
seti_high %b 0x0000 # 0x201000 / 128
seti %c 1024 # (2048 * 2) / 4
load %a %b %c

Expand All @@ -49,7 +53,9 @@ seti %d 2048 # count is 2048
vmul.bf16 %c %a %b %d

# Store C to 0x202000
seti %a 0x4040 # 0x202000 / 128
# seti %a 0x4040 # 0x202000 / 128
seti_low %a 0x4040 # 0x202000 / 128
seti_high %a 0x0000 # 0x202000 / 128
seti %b 0x820 # (128 + 4096 + 4096) / 4
seti %c 1024 # (2048 * 2) / 4
store %a %b %c
Expand Down
12 changes: 9 additions & 3 deletions examples/with-load-store-vsub.bf16.asm
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ def finalize(host):

# Load 0x200000 into A
seti %a 0x20 # (128) / 4
seti %b 0x4000 # 0x200000 / 128
# seti %b 0x4000 # 0x200000 / 128
seti_low %b 0x4000 # 0x200000 / 128
seti_high %b 0x0000 # 0x200000 / 128
seti %c 1024 # (2048 * 2) / 4
load %a %b %c

# Load 0x201000 into B
seti %a 0x420 # (128 + 4096) / 4
seti %b 0x4020 # 0x201000 / 128
# seti %b 0x4020 # 0x201000 / 128
seti_low %b 0x4020 # 0x201000 / 128
seti_high %b 0x0000 # 0x201000 / 128
seti %c 1024 # (2048 * 2) / 4
load %a %b %c

Expand All @@ -49,7 +53,9 @@ seti %d 2048 # count is 2048
vsub.bf16 %c %a %b %d

# Store C to 0x202000
seti %a 0x4040 # 0x202000 / 128
# seti %a 0x4040 # 0x202000 / 128
seti_low %a 0x4040 # 0x202000 / 128
seti_high %a 0x0000 # 0x202000 / 128
seti %b 0x820 # (128 + 4096 + 4096) / 4
seti %c 1024 # (2048 * 2) / 4
store %a %b %c
Expand Down
5 changes: 5 additions & 0 deletions examples/without-load-store-vadd.bf16.asm
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ seti %a 0x20 # 128 / 4 # A is stored at 128
seti %b 0x420 # (128 + 4096) / 4 # B is stored at 128 + 4096
seti %c 0x820 # (128 + 4096 *2) / 4 # C is stored at 128 + 4096 + 4096
seti %d 2048 # count is 2048
seti %e 0x400 # 1024
seti %f 0x0

vadd.bf16 %c %a %b %d
add.i32 %f %zero 0x1
#ifneq %e %f 0xc010
ifneq %e %f -8

# Interrupt to CPU
return
Loading