from MAGIC import MAGIC import numpy as np import random as rand import matplotlib.pyplot as plt from functions import randrange_float ################################################## # running ADD1 function ################################################## # initiating simulation N = 18 #rand.randint(10,20) p = 9 #rand.randint(0,N-1) myMAGIC = MAGIC() myMAGIC.F_simulation_init(N, p) in1_arr = np.array([]) out_arr = np.array([]) exp_arr = np.array([]) lines = 1000 # writing some numbers to MAGIC. msb in 0 column for i in range(0, lines): val = randrange_float(start=-(2**(N - p - 2)), stop=(2**(N - p - 2)) - (2**(-p)), step=2**(-p)) in1_arr = np.r_[in1_arr, val] row_add = i msb_add = 0 myMAGIC.F_write_num(row_add, msb_add, val, N) #myMAGIC.F_write_num(row_add, N, 1)
import numpy as np import random as rand import matplotlib.pyplot as plt from functions import (randrange_float, print_equation) N_start = 8 N = 32 p = 0 N_Array = np.arange(N_start,N+1) end_mem_arr = np.array([]) max_mem_arr = np.array([]) cycles_arr = np.array([]) for n in range(N_start, N+1): myMAGIC = MAGIC() myMAGIC.F_simulation_init(n,p,print_=0) for i in range(2): val = randrange_float(start=-(2 ** (n - p - 1)) + 1, stop=(2 ** (n - p - 1)) - (2 ** (-p)), step=2 ** (-p)) myMAGIC.F_write_num(0, i*n, val) rows = np.arange(0,len(myMAGIC)) ################################################################# # choose a function by deleting the '#' from the wanted function # *** change the graph names accordingly ################################################################# #myMAGIC.F_2num_DIV_remain(rows, 0, n, 2*n, 3*n) myMAGIC.F_2num_DIV_approx(rows, 0, n, 2 * n, N=n, p=p)
from MAGIC import MAGIC import numpy as np from functions import randrange_float import matplotlib.pyplot as plt import random as rand ################################################## # running 2num logic functions ################################################## # initiating simulation N = rand.randint(1, 10) p = rand.randint(0, N - 1) myMAGIC = MAGIC() myMAGIC.F_simulation_init(N, p) lines = 1000 # writing some numbers to MAGIC. msb in 0 column for i in range(0, lines): val = i #randrange_float(start=-(2**(N-p-1)),stop= (2**(N-p-1)) - (2**(-p)),step=2**(-p)) row_add = i msb_add = 0 myMAGIC.F_write_num(row_add, msb_add, val) # writing some numbers to MAGIC. msb in Nth column for i in range(0, lines): val = randrange_float(start=-(2**(N - p - 1)), stop=(2**(N - p - 1)) - (2**(-p)), step=2**(-p)) row_add = i msb_add = N
from MAGIC import MAGIC import numpy as np from functions import randrange_float import matplotlib.pyplot as plt import random as rand ################################################## # running write and read functions ################################################## # initiating simulation N = rand.randint(1, 10) p = rand.randint(0, N - 1) myMAGIC = MAGIC() myMAGIC.F_simulation_init(N, p) in_arr = np.array([]) out_arr = np.array([]) # writing some numbers to MAGIC. msb in 0 column for i in range(0, 1000): val = randrange_float(start=-(2**(N - p - 1)), stop=(2**(N - p - 1)) - (2**(-p)), step=2**(-p)) in_arr = np.r_[in_arr, val] row_add = i msb_add = 0 myMAGIC.F_write_num(row_add, msb_add, val) # writing some numbers to MAGIC. msb in Nth column for i in range(0, 1000):
from MAGIC import MAGIC import numpy as np import random as rand import matplotlib.pyplot as plt from functions import randrange_float ################################################## # running DIV_approx function ################################################## # initiating simulation N_old = rand.randint(5, 10) p = rand.randint(3, N_old - 2) lines = 100 myMAGIC = MAGIC() myMAGIC.F_simulation_init(N_old, p) num_arr = np.array([]) div_arr = np.array([]) out_arr = np.array([]) exp_arr = np.array([]) # writing some numbers to MAGIC. msb in 0 column for i in range(0, lines): val = randrange_float(start=-(2**(N_old - p - 1)) + 1, stop=(2**(N_old - p - 1)) - (2**(-p)), step=2**(-p)) num_arr = np.r_[num_arr, val] row_add = i msb_add = 0 myMAGIC.F_write_num(row_add, msb_add, val)
from MAGIC import MAGIC import numpy as np import random as rand import matplotlib.pyplot as plt from functions import randrange_float ################################################## # running ADD1 function ################################################## # initiating simulation N = 18 #rand.randint(10,20) p = 9 #rand.randint(0,N-1) myMAGIC = MAGIC() myMAGIC.F_simulation_init(N, p) in1_arr = np.array([]) in2_arr = np.array([]) out_arr = np.array([]) exp_arr = np.array([]) lines = 100 # writing some numbers to MAGIC. msb in 0 column for i in range(0, lines): val = randrange_float(start=-(2**(N - p - 2)), stop=(2**(N - p - 2)) - (2**(-p)), step=2**(-p)) in1_arr = np.r_[in1_arr, val] in2_arr = np.r_[in2_arr, 1] row_add = i msb_add = 0
from MAGIC import MAGIC import numpy as np import random as rand import matplotlib.pyplot as plt from functions import randrange_float ################################################## # running FA functions ################################################## # initiating simulation N = 8#rand.randint(10,20) p = 0#rand.randint(0,N-1) myMAGIC = MAGIC() myMAGIC.F_simulation_init(N,p) in1_arr = np.array([]) in2_arr = np.array([]) out_arr = np.array([]) exp_arr = np.array([]) lines = 1 # writing some numbers to MAGIC. msb in 0 column for i in range (0,lines): val = randrange_float(start=-(2 ** (N - p - 2)), stop=(2 ** (N - p - 2)) - (2 ** (-p)), step=2 ** (-p)) in1_arr = np.r_[in1_arr, val] row_add = i msb_add = 0 myMAGIC.F_write_num(row_add, msb_add, -1)#val) # writing second set of numbers to MAGIC. msb in N column
from MAGIC import MAGIC import numpy as np import random as rand import matplotlib.pyplot as plt from functions import randrange_float ################################################## # running DIV_remain function ################################################## # initiating simulation N = rand.randint(10, 20) p = rand.randint(0, N - 1) lines = 20 myMAGIC = MAGIC() myMAGIC.F_simulation_init(N, p) num_arr = np.array([]) div_arr = np.array([]) out_arr = np.array([]) exp_arr = np.array([]) res_arr = np.array([]) rem_arr = np.array([]) # writing some numbers to MAGIC. msb in 0 column for i in range(0, lines): val = randrange_float(start=-(2**(N - p - 1)) + 1, stop=(2**(N - p - 1)) - (2**(-p)), step=2**(-p)) num_arr = np.r_[num_arr, val] row_add = i msb_add = 0
from MAGIC import MAGIC import numpy as np import random as rand import matplotlib.pyplot as plt from functions import randrange_float ################################################## # running MUL function ################################################## # initiating simulation N = rand.randint(10, 20) p = rand.randint(0, N - 1) lines = 100 myMAGIC = MAGIC() myMAGIC.F_simulation_init(N, p) in1_arr = np.array([]) in2_arr = np.array([]) out_arr = np.array([]) exp_arr = np.array([]) # writing some numbers to MAGIC. msb in 0 column for i in range(0, lines): val = randrange_float(start=-(2**((N - p - 1) / 2)) + 1, stop=(2**((N - p - 1) / 2)) - 1, step=(2**(-p / 2))) in1_arr = np.r_[in1_arr, val] row_add = i msb_add = 0 myMAGIC.F_write_num(row_add, msb_add, val)