-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitBrickCommands.py
31 lines (26 loc) · 1.42 KB
/
bitBrickCommands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy as np
class bitBrickCommands():
#def __init__(self):
#def load8(self, arguments):
#load8 <mem location to read from> <#bytes to read>
def mul2(self, arguments):
#mul2 <dst reg> <src1> <src2>
assert type(arguments) == list, 'mul2 - arguments not of type list'
assert len(np.array(arguments)) == 2, 'mul2 - need 2 arguments'
assert abs(arguments[0]) <= 3, 'mul2 - arguments[0] greater than 2 bits'
assert abs(arguments[1]) <= 3, 'mul2 - arguments[1] greater than 2 bits'
return arguments[0]*arguments[1]
def mul4(self, arguments):
#mul2 <dst reg> <src1> <src2>
assert type(arguments) == list, 'mul2 - arguments not of type list'
assert len(np.array(arguments)) == 2, 'mul2 - more than 2 arguments passed'
assert abs(arguments[0]) <= 3, 'mul2 - arguments[0] greater than 2 bits'
assert abs(arguments[1]) <= 3, 'mul2 - arguments[1] greater than 2 bits'
return arguments[0]*arguments[1]
def mul8(self, arguments):
#mul2 <dst reg> <src1> <src2>
assert type(arguments) == list, 'mul2 - arguments not of type list'
assert len(np.array(arguments)) == 2, 'mul2 - more than 2 arguments passed'
assert abs(arguments[0]) <= 3, 'mul2 - arguments[0] greater than 2 bits'
assert abs(arguments[1]) <= 3, 'mul2 - arguments[1] greater than 2 bits'
return arguments[0]*arguments[1]