Skip to content

Commit

Permalink
switch PLL outputs on CW340
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-dewar committed Jul 12, 2023
1 parent 822a20b commit 9d34241
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion software/chipwhisperer/capture/targets/CW305.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def _con(self, scope=None, bsfile=None, force=False, fpga_id=None, defines_files
self.platform = platform
if platform == 'cw305':
self._naeusb = NAEUSB()
self.pll = PLLCDCE906(self._naeusb, ref_freq = 12.0E6)
self.pll = PLLCDCE906(self._naeusb, ref_freq = 12.0E6, board="CW305")
self.fpga = FPGA(self._naeusb)
self._naeusb.con(idProduct=[0xC305], serial_number=sn, hw_location=hw_location)
if not fpga_id is None:
Expand Down
2 changes: 1 addition & 1 deletion software/chipwhisperer/capture/targets/CW310.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, *args, **kwargs):
pass
import chipwhisperer as cw
self._naeusb = NAEUSB()
self.pll = PLLCDCE906(self._naeusb, ref_freq = 12.0E6)
self.pll = PLLCDCE906(self._naeusb, ref_freq = 12.0E6, board="CW310")
self.fpga = FPGA(self._naeusb)

self.hw = None
Expand Down
3 changes: 3 additions & 0 deletions software/chipwhisperer/capture/targets/CW340.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from .CW310 import CW310
from ...hardware.naeusb.pll_cdce906 import PLLCDCE906
from ...logging import *

class CW340(CW310):
PROG_MODES = ["serial", "parallel", "parallel16"]
Expand All @@ -10,6 +12,7 @@ class CW340(CW310):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.bytecount_size = 0
self.pll = PLLCDCE906(self._naeusb, ref_freq = 12.0E6, board="CW310")

def _con(self, scope=None, bsfile=None, force=False, fpga_id=None, defines_files=None, slurp=True, prog_speed=None, sn=None, hw_location=None, prog_mode="serial"):
self._naeusb.con(idProduct=[0xC340], serial_number=sn, hw_location=hw_location)
Expand Down
32 changes: 23 additions & 9 deletions software/chipwhisperer/hardware/naeusb/pll_cdce906.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@

class PLLCDCE906(object):

def __init__(self, usb, ref_freq):
def __init__(self, usb, ref_freq, board="CW305"):
self._usb = usb
self.reffreq = ref_freq
self._pll0source = 'PLL0'
self._pll0slew = '+0nS'
self._pll1slew = '+0nS'
self._pll2slew = '+0nS'
self._board = board

def pll_outfreq_set(self, freq, outnum):
"""Set the output frequency of a PLL
Expand All @@ -55,14 +56,27 @@ def pll_outfreq_set(self, freq, outnum):

def outnumToPin(self, outnum):
"""Convert from PLL Number to actual output pin"""
if outnum == 0:
return 0
elif outnum == 1:
return 1
elif outnum == 2:
return 4
else:
raise ValueError("Invalid output number = %d" % outnum)

# NOTE: PLL2 and PLL1 are swapped on CW340
if self._board in ["CW305", "CW310"]:
if outnum == 0:
return 0
elif outnum == 1:
return 1
elif outnum == 2:
return 4
else:
raise ValueError("Invalid output number = %d" % outnum)
elif self._board == "CW340":
if outnum == 0:
return 0
elif outnum == 2:
return 1
elif outnum == 1:
return 4
else:
raise ValueError("Invalid output number = %d" % outnum)


def outputUpdateOutputs(self, outnum, pllsrc_new=None, pllenabled_new=None, pllslewrate_new=None):
"""Update the output pins with enabled/disabled, slew rate, etc"""
Expand Down

0 comments on commit 9d34241

Please sign in to comment.