import numpy as np

high          = 1
low           = 0
mask_elements = 64
bounds        = np.empty(shape=[high+1, mask_elements],  dtype=np.int32)

for i in range(mask_elements):
  bounds[high,i] = (i + 1) * 4 - 1
  bounds[low,i] = i * 4
    
print(" i | High  Low \n---|-----------")
for i in range(mask_elements):
  print("{:2} | {:4} {:4}".format(i, bounds[high,i], bounds[low,i]))

"""
Explanation: VectorAccessors
Masks
jetmapping_mask.vhd masking o_mask 1->4 bit
End of explanation
"""


import numpy as np
channels     = 4
elements     = 320
mask_address = np.empty(shape=[channels, elements],  dtype=np.int32)

for i in range(elements):
  mask_address[0,i] = (319-i) * 4 + 0
  mask_address[1,i] =      i  * 4 + 2
  mask_address[2,i] = (319-i) * 4 + 1
  mask_address[3,i] =      i  * 4 + 3

print("  i |    A    B    C    D \n----|---------------------")
for i in range(elements):
  print("{:3} | {:4} {:4} {:4} {:4}".format(i,mask_address[0,i],mask_address[1,i],mask_address[2,i],mask_address[3,i]))

"""
Explanation: Ricoh GEN5
jetmapping.vhd lvec_mask_address
End of explanation
"""


import numpy as np
channels     = 2
elements     = 512
mask_address = np.empty(shape=[channels, elements],  dtype=np.int32)

for i in range(elements):
  mask_address[0,i] = (511-i) * 2 + 0
  mask_address[1,i] =      i  * 2 + 1

print("  i | High  Low \n----|-----------")
for i in range(elements):
  print("{:3} | {:4} {:4}".format(i,mask_address[0,i],mask_address[1,i]))

"""
Explanation: KonicaMinolta KM1024i
jetmapping.vhd lvec_mask_address
End of explanation
"""


import numpy as np
channels  = 10
data_size = 3
bounds    = np.empty(shape=[channels,2],  dtype=np.int32)

for i in range(1,channels+1):
  bounds[i-1][0] = data_size * i - 1   # High
  bounds[i-1][1] = data_size * (i - 1) # Low
          
print("  i | High  Low \n----|-----------")
for i in range(1,channels+1):
  print("{:3} | {:4} {:4}".format(i,bounds[i-1,0],bounds[i-1,1]))

"""
Explanation: Kyocera KJ4B_1200_64k CPLD
Printhead data
End of explanation
"""


import numpy as np
g_RAM_FRAME_SIZE  = 256
data_size = 3
bounds_left_msn    = np.empty(shape=[g_RAM_FRAME_SIZE,2],  dtype=np.int32)
bounds_right_msn   = np.empty(shape=[g_RAM_FRAME_SIZE,2],  dtype=np.int32)
bounds_left_lsn    = np.empty(shape=[g_RAM_FRAME_SIZE,2],  dtype=np.int32)
bounds_right_lsn   = np.empty(shape=[g_RAM_FRAME_SIZE,2],  dtype=np.int32)

for i in range(0,int(g_RAM_FRAME_SIZE / 8 - 1 + 1)):
  bounds_left_msn[i][0]  = (i * 8) + 3
  bounds_left_msn[i][1]  = (i * 8) + 0
  bounds_right_msn[i][0] = (i * 8) + 7
  bounds_right_msn[i][1] = (i * 8) + 4
  bounds_left_lsn[i][0]  = (i * 8) + 7
  bounds_left_lsn[i][1]  = (i * 8) + 4
  bounds_right_lsn[i][0] = (i * 8) + 3
  bounds_right_lsn[i][1] = (i * 8) + 0
          
print("  i | High  Low <= High  Low | High  Low <= High  Low\n----|------------------------|-----------------------")
for i in range(0,int(g_RAM_FRAME_SIZE / 8 - 1 + 1)):
  print("{:3} | {:4} {:4} <= {:4} {:4} | {:4} {:4} <= {:4} {:4}".format(i,bounds_left_msn[i,0],bounds_left_msn[i,1],bounds_right_msn[i,0],bounds_right_msn[i,1],bounds_left_lsn[i,0],bounds_left_lsn[i,1],bounds_right_lsn[i,0],bounds_right_lsn[i,1]))

"""
Explanation: Jetmapping BitSwap
Bit swap in BMP, in 4bit/pixel mode the first pixel is stored in the more significant nibble, therefore bitmap is encoded like [7..4][3..0][11..8][15..12]..etc
(N * 8) + 3 downto (N * 8) + 0) <= coe_user_buffer_output_data((N * 8) + 7 downto (N * 8) + 4);
End of explanation
"""


import numpy as np
channels  = 8
data_size = 3
bounds    = np.empty(shape=[channels,2],  dtype=np.int32)

for i in range(1,channels+1):
  bounds[i-1][0] = data_size * i - 1   # High
  bounds[i-1][1] = data_size * (i - 1) # Low
          
print("  i | High  Low \n----|-----------")
for i in range(1,channels+1):
  print("{:3} | {:4} {:4}".format(i,bounds[i-1,0],bounds[i-1,1]))

"""
Explanation: Manual Data Assignment
End of explanation
"""


