Skip to content

Commit b13d69a

Browse files
committed
Fixed overflow in APS2 and APS3 drivers in numpy > 2.0
1 parent f50bc16 commit b13d69a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

QGL/drivers/APS2Pattern.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -610,16 +610,16 @@ def to_instruction(self, write_flag=True, label=None):
610610
(nco_select_bits) << NCO_SELECT_OP_OFFSET)
611611
if self.instruction == "MODULATE":
612612
#zero-indexed quad count
613-
payload |= np.uint32(self.length / ADDRESS_UNIT - 1)
613+
payload |= np.uint64(self.length / ADDRESS_UNIT - 1)
614614
elif self.instruction == "SET_FREQ":
615615
# frequencies can span -2 to 2 or 0 to 4 in unsigned
616-
payload |= np.uint32(
616+
payload |= np.uint64(
617617
(self.frequency / MODULATION_CLOCK if self.frequency > 0 else
618618
self.frequency / MODULATION_CLOCK + 4) * 2**28)
619619
elif (self.instruction == "SET_PHASE") | (
620620
self.instruction == "UPDATE_FRAME"):
621621
#phases can span -0.5 to 0.5 or 0 to 1 in unsigned
622-
payload |= np.uint32(np.mod(self.phase / (2 * np.pi), 1) * 2**28)
622+
payload |= np.uint64(np.mod(self.phase / (2 * np.pi), 1) * 2**28)
623623

624624
instr = Instruction(MODULATION << 4, payload, label)
625625
instr.writeFlag = write_flag

QGL/drivers/APS3Pattern.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -590,16 +590,16 @@ def to_instruction(self, write_flag=True, label=None):
590590
self.nco_select << NCO_SELECT_OP_OFFSET)
591591
if self.instruction == "MODULATE":
592592
#zero-indexed quad count
593-
payload |= np.uint32(self.length / ADDRESS_UNIT - 1)
593+
payload |= np.uint64(self.length / ADDRESS_UNIT - 1)
594594
elif self.instruction == "SET_FREQ":
595595
# frequencies can span -4 to 4 or 0 to 8 in unsigned
596-
payload |= np.uint32(
596+
payload |= np.uint64(
597597
(self.frequency / MODULATION_CLOCK if self.frequency > 0 else
598598
self.frequency / MODULATION_CLOCK + 8) * 2**27)
599599
elif (self.instruction == "SET_PHASE") | (
600600
self.instruction == "UPDATE_FRAME"):
601601
#phases can span -0.5 to 0.5 or 0 to 1 in unsigned
602-
payload |= np.uint32(np.mod(self.phase / (2 * np.pi), 1) * 2**27)
602+
payload |= np.uint64(np.mod(self.phase / (2 * np.pi), 1) * 2**27)
603603

604604
instr = Instruction(MODULATION << 4, payload, label)
605605
instr.writeFlag = write_flag

0 commit comments

Comments
 (0)