From fe9b48d095473c585518173185937b3e1a7550c0 Mon Sep 17 00:00:00 2001 From: Leon Schoorl Date: Mon, 16 Sep 2024 14:28:56 +0200 Subject: [PATCH] WIP externally clocked sync out --- .../data/constraints/fullMeshHwCcTest.xdc | 5 +++++ .../src/Bittide/Instances/Domains.hs | 1 + .../Bittide/Instances/Hitl/HwCcTopologies.hs | 18 ++++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bittide-instances/data/constraints/fullMeshHwCcTest.xdc b/bittide-instances/data/constraints/fullMeshHwCcTest.xdc index 52c8c5b82..0e1eb7b2f 100644 --- a/bittide-instances/data/constraints/fullMeshHwCcTest.xdc +++ b/bittide-instances/data/constraints/fullMeshHwCcTest.xdc @@ -12,6 +12,7 @@ set_property BOARD_PART_PIN GPIO_LED_0_LS [get_ports spiDone] set_clock_groups \ -asynchronous \ -group [get_clocks -include_generated_clocks {SYSCLK_300_p}] \ + -group [get_clocks -include_generated_clocks {USER_SMA_CLOCK_p}] -group [get_clocks -include_generated_clocks {SMA_MGT_REFCLK_C_p}] # Color | FPGA pin | LVLSHFT | Connection @@ -42,3 +43,7 @@ set_property -dict {IOSTANDARD LVCMOS12 PACKAGE_PIN AM17} [get_ports {MISO}] set_property -dict {IOSTANDARD LVCMOS18 PACKAGE_PIN H27} [get_ports {SYNC_IN}] # USER_SMA_GPIO_N (connected on node 0 to SYNC_IN of all nodes) set_property -dict {IOSTANDARD LVCMOS18 PACKAGE_PIN G27} [get_ports {SYNC_OUT}] + +# USER_SMA_CLOCK +set_property -dict {IOSTANDARD LVDS PACKAGE_PIN D23} [get_ports {USER_SMA_CLOCK_p}] +set_property -dict {IOSTANDARD LVDS PACKAGE_PIN C23} [get_ports {USER_SMA_CLOCK_n}] diff --git a/bittide-instances/src/Bittide/Instances/Domains.hs b/bittide-instances/src/Bittide/Instances/Domains.hs index a0889d6f7..53b6c44a0 100644 --- a/bittide-instances/src/Bittide/Instances/Domains.hs +++ b/bittide-instances/src/Bittide/Instances/Domains.hs @@ -25,6 +25,7 @@ createDomain vXilinxSystem{vName="Basic625", vPeriod=hzToPeriod 625e6, vResetKin createDomain vXilinxSystem{vName="Ext125", vPeriod= hzToPeriod 125e6, vResetKind=Asynchronous} createDomain vXilinxSystem{vName="Ext200", vPeriod=hzToPeriod 200e6, vResetKind=Asynchronous} createDomain vXilinxSystem{vName="Ext300", vPeriod=hzToPeriod 300e6, vResetKind=Asynchronous} +createDomain vXilinxSystem{vName="Ext300A", vPeriod=hzToPeriod 300e6, vResetKind=Asynchronous} createDomain vXilinxSystem{vName="GthRx", vPeriod=hzToPeriod 125e6} createDomain vXilinxSystem{vName="GthTx", vPeriod= hzToPeriod 125e6} diff --git a/bittide-instances/src/Bittide/Instances/Hitl/HwCcTopologies.hs b/bittide-instances/src/Bittide/Instances/Hitl/HwCcTopologies.hs index 57b3cedfd..6018a01ea 100644 --- a/bittide-instances/src/Bittide/Instances/Hitl/HwCcTopologies.hs +++ b/bittide-instances/src/Bittide/Instances/Hitl/HwCcTopologies.hs @@ -80,6 +80,7 @@ import Clash.Annotations.TH (makeTopEntity) import Clash.Class.Counter import Clash.Cores.Xilinx.GTH import Clash.Cores.Xilinx.Ila (Depth (..), IlaConfig (..), ila, ilaConfig) +import Clash.Cores.Xilinx.Xpm.Cdc.Single import Clash.Sized.Extra (unsignedToSigned) import Clash.Xilinx.ClockGen @@ -141,7 +142,7 @@ partsPerToSteps :: PartsPer -> FincFdecCount partsPerToSteps = fromIntegral . roundFloatInteger . PartsPer.toSteps commonStepSizePartsPer -commonSpiConfig :: TestConfig6_200_on_0a_RegisterMap +commonSpiConfig :: Si5395RegisterMap commonSpiConfig = case commonStepSizeSelect of PPB_100 -> testConfig6_200_on_0a_100ppb_and_1 @@ -667,11 +668,14 @@ hwCcTopologyWithRiscvTest refClkDiff sysClkDiff syncIn rxns rxps miso = testConfig = hitlVio disabled sysClk done success makeTopEntity 'hwCcTopologyWithRiscvTest +unsafeResetSynch :: (KnownDomain domIn, KnownDomain domOut) => Reset domIn -> Reset domOut +unsafeResetSynch = unsafeFromActiveHigh . unsafeSynchronizer clockGen clockGen . unsafeToActiveHigh -- | Top entity for this test. See module documentation for more information. hwCcTopologyTest :: "SMA_MGT_REFCLK_C" ::: DiffClock Ext200 -> "SYSCLK_300" ::: DiffClock Ext300 -> + "USER_SMA_CLOCK" ::: DiffClock Ext300A -> "SYNC_IN" ::: Signal Basic125 Bool -> "GTH_RX_NS" ::: TransceiverWires GthRxS LinkCount -> "GTH_RX_PS" ::: TransceiverWires GthRxS LinkCount -> @@ -682,7 +686,7 @@ hwCcTopologyTest :: ::: ( "FINC" ::: Signal Basic125 Bool , "FDEC" ::: Signal Basic125 Bool ) - , "SYNC_OUT" ::: Signal Basic125 Bool + , "SYNC_OUT" ::: Signal Basic125A Bool , "spiDone" ::: Signal Basic125 Bool , "" ::: ( "SCLK" ::: Signal Basic125 Bool @@ -690,13 +694,19 @@ hwCcTopologyTest :: , "CSB" ::: Signal Basic125 Bool ) ) -hwCcTopologyTest refClkDiff sysClkDiff syncIn rxns rxps miso = +hwCcTopologyTest refClkDiff sysClkDiff userSmaClkDiff syncIn rxns rxps miso = (txns, txps, unbundle hwFincFdecs, syncOut, spiDone, spiOut) where refClk = ibufds_gte3 refClkDiff :: Clock Ext200 (sysClk, sysRst) = clockWizardDifferential sysClkDiff noReset - ilaControl@IlaControl{..} = ilaPlotSetup IlaPlotSetup{..} + (smaClk :: Clock Basic125A, smaRst :: Reset Basic125A) = clockWizardDifferential userSmaClkDiff (unsafeResetSynch $ unsafeFromActiveLow spiDone) + ilaControl@IlaControl{syncRst,syncStart} = ilaPlotSetup IlaPlotSetup{..} startTest = isJust <$> testConfig + syncOut = dflipflop smaClk + $ syncOutGenerator smaClk (sync sysClk smaClk startTest) + $ trueFor (SNat @(Seconds 5)) smaClk smaRst (sync sysClk smaClk allReady) + + sync = xpmCdcSingle cfg = fromMaybe disabled <$> testConfig