forked from PAWPAW-Mirror/lib_xua
- Renamed i_sync to i_pll_ref.
- Always used i_pll_ref interface from clockgen rather than direct port access
This commit is contained in:
@@ -51,7 +51,7 @@ void XUA_Buffer(
|
|||||||
#endif
|
#endif
|
||||||
, chanend c_aud
|
, chanend c_aud
|
||||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||||
, client interface sync_if i_sync
|
, client interface pll_ref_if i_pll_ref
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ void XUA_Buffer_Ep(chanend c_aud_out,
|
|||||||
, chanend c_buff_ctrl
|
, chanend c_buff_ctrl
|
||||||
#endif
|
#endif
|
||||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||||
, client interface sync_if i_sync
|
, client interface pll_ref_if i_pll_ref
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ void XUA_Buffer(
|
|||||||
#endif
|
#endif
|
||||||
, chanend c_aud
|
, chanend c_aud
|
||||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||||
, client interface sync_if i_sync
|
, client interface pll_ref_if i_pll_ref
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -150,7 +150,7 @@ void XUA_Buffer(
|
|||||||
, c_buff_ctrl
|
, c_buff_ctrl
|
||||||
#endif
|
#endif
|
||||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||||
, i_sync
|
, i_pll_ref
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
|||||||
, chanend c_buff_ctrl
|
, chanend c_buff_ctrl
|
||||||
#endif
|
#endif
|
||||||
#if XUA_SYNCMODE == XUA_SYNCMODE_SYNC
|
#if XUA_SYNCMODE == XUA_SYNCMODE_SYNC
|
||||||
, client interface sync_if i_sync
|
, client interface pll_ref_if i_pll_ref
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -529,7 +529,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
|||||||
if (sofCount == framesPerSec)
|
if (sofCount == framesPerSec)
|
||||||
{
|
{
|
||||||
/* Port is accessed via interface to allow flexibilty with location */
|
/* Port is accessed via interface to allow flexibilty with location */
|
||||||
i_sync.toggle();
|
i_pll_ref.toggle();
|
||||||
sofCount = 0;
|
sofCount = 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ static int clockValid[NUM_CLOCKS]; /* Store current val
|
|||||||
static int clockInt[NUM_CLOCKS]; /* Interupt flag for clocks */
|
static int clockInt[NUM_CLOCKS]; /* Interupt flag for clocks */
|
||||||
static int clockId[NUM_CLOCKS];
|
static int clockId[NUM_CLOCKS];
|
||||||
|
|
||||||
[[combinable]]
|
[[distributable]]
|
||||||
void PllRefPinTask(server interface sync_if i_sync, out port p_pll_ref)
|
void PllRefPinTask(server interface pll_ref_if i_pll_ref, out port p_pll_ref)
|
||||||
{
|
{
|
||||||
static unsigned pinVal= 0;
|
static unsigned pinVal= 0;
|
||||||
static unsigned short pinTime = 0;
|
static unsigned short pinTime = 0;
|
||||||
@@ -49,18 +49,18 @@ void PllRefPinTask(server interface sync_if i_sync, out port p_pll_ref)
|
|||||||
{
|
{
|
||||||
select
|
select
|
||||||
{
|
{
|
||||||
case i_sync.toggle():
|
case i_pll_ref.toggle():
|
||||||
pinVal = ~pinVal;
|
pinVal = ~pinVal;
|
||||||
p_pll_ref <: pinVal;
|
p_pll_ref <: pinVal;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case i_sync.init():
|
case i_pll_ref.init():
|
||||||
p_pll_ref <: pinVal @ pinTime;
|
p_pll_ref <: pinVal @ pinTime;
|
||||||
pinTime += (unsigned short)(LOCAL_CLOCK_INCREMENT - (LOCAL_CLOCK_INCREMENT/2));
|
pinTime += (unsigned short)(LOCAL_CLOCK_INCREMENT - (LOCAL_CLOCK_INCREMENT/2));
|
||||||
p_pll_ref @ pinTime <: pinVal;
|
p_pll_ref @ pinTime <: pinVal;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case i_sync.toggle_timed(int relative):
|
case i_pll_ref.toggle_timed(int relative):
|
||||||
|
|
||||||
if (!relative)
|
if (!relative)
|
||||||
{
|
{
|
||||||
@@ -241,10 +241,11 @@ extern int samples_to_host_inputs_buff[NUM_USB_CHAN_IN];
|
|||||||
int VendorAudCoreReqs(unsigned cmd, chanend c);
|
int VendorAudCoreReqs(unsigned cmd, chanend c);
|
||||||
|
|
||||||
#pragma unsafe arrays
|
#pragma unsafe arrays
|
||||||
#if (AUDIO_IO_TILE == PLL_REF_TILE)
|
//#if (AUDIO_IO_TILE == PLL_REF_TILE)
|
||||||
|
#if 0
|
||||||
void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, out port p, chanend c_dig_rx, chanend c_clk_ctl, chanend c_clk_int)
|
void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, out port p, chanend c_dig_rx, chanend c_clk_ctl, chanend c_clk_int)
|
||||||
#else
|
#else
|
||||||
void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interface sync_if i_sync, chanend c_dig_rx, chanend c_clk_ctl, chanend c_clk_int)
|
void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interface pll_ref_if i_pll_ref, chanend c_dig_rx, chanend c_clk_ctl, chanend c_clk_int)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
timer t_local;
|
timer t_local;
|
||||||
@@ -355,15 +356,8 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
|
|||||||
outuint(c_dig_rx, 1);
|
outuint(c_dig_rx, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (AUDIO_IO_TILE == PLL_REF_TILE)
|
|
||||||
/* Initial ref clock output and get timestamp */
|
/* Initial ref clock output and get timestamp */
|
||||||
p <: pinVal @ pinTime;
|
i_pll_ref.init();
|
||||||
pinTime += (unsigned short)(LOCAL_CLOCK_INCREMENT - (LOCAL_CLOCK_INCREMENT/2));
|
|
||||||
p @ pinTime <: pinVal;
|
|
||||||
#else
|
|
||||||
/* TODO ideally always use interface */
|
|
||||||
i_sync.init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
@@ -486,15 +480,8 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
|
|||||||
/* Generate local clock from timer */
|
/* Generate local clock from timer */
|
||||||
case t_local when timerafter(timeNextEdge) :> void:
|
case t_local when timerafter(timeNextEdge) :> void:
|
||||||
|
|
||||||
#if (AUDIO_IO_TILE == PLL_REF_TILE)
|
|
||||||
/* Setup next local clock edge */
|
/* Setup next local clock edge */
|
||||||
pinTime += (short) LOCAL_CLOCK_INCREMENT;
|
i_pll_ref.toggle_timed(0);
|
||||||
pinVal = !pinVal;
|
|
||||||
p @ pinTime <: pinVal;
|
|
||||||
#else
|
|
||||||
/* TODO ideally always use interface */
|
|
||||||
i_sync.toggle_timed(0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Record time of edge */
|
/* Record time of edge */
|
||||||
timeLastEdge = timeNextEdge;
|
timeLastEdge = timeNextEdge;
|
||||||
@@ -623,16 +610,8 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
|
|||||||
/* Setup for next edge */
|
/* Setup for next edge */
|
||||||
timeNextEdge = spdifReceivedTime + LOCAL_CLOCK_INCREMENT + LOCAL_CLOCK_MARGIN;
|
timeNextEdge = spdifReceivedTime + LOCAL_CLOCK_INCREMENT + LOCAL_CLOCK_MARGIN;
|
||||||
|
|
||||||
#if (AUDIO_IO_TILE == PLL_REF_TILE)
|
|
||||||
/* Toggle edge */
|
/* Toggle edge */
|
||||||
p <: pinVal @ pinTime;
|
i_pll_ref.toggle_timed(1);
|
||||||
pinTime += (short) LOCAL_CLOCK_INCREMENT;
|
|
||||||
pinVal = !pinVal;
|
|
||||||
p @ pinTime <: pinVal;
|
|
||||||
#else
|
|
||||||
i_sync.toggle_timed(1);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Reset counters */
|
/* Reset counters */
|
||||||
spdifCounters.receivedSamples = 0;
|
spdifCounters.receivedSamples = 0;
|
||||||
@@ -737,15 +716,9 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
|
|||||||
/* Setup for next edge */
|
/* Setup for next edge */
|
||||||
timeNextEdge = adatReceivedTime + LOCAL_CLOCK_INCREMENT + LOCAL_CLOCK_MARGIN;
|
timeNextEdge = adatReceivedTime + LOCAL_CLOCK_INCREMENT + LOCAL_CLOCK_MARGIN;
|
||||||
|
|
||||||
#if (AUDIO_IO_TILE == PLL_REF_TILE)
|
|
||||||
/* Toggle edge */
|
/* Toggle edge */
|
||||||
p <: pinVal @ pinTime;
|
i_pll_ref.toggle_timed(1);
|
||||||
pinTime += LOCAL_CLOCK_INCREMENT;
|
|
||||||
pinVal = !pinVal;
|
|
||||||
p @ pinTime <: pinVal;
|
|
||||||
#else
|
|
||||||
i_sync.toggle_timed(1);
|
|
||||||
#endif
|
|
||||||
/* Reset counters */
|
/* Reset counters */
|
||||||
adatCounters.receivedSamples = 0;
|
adatCounters.receivedSamples = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -4,33 +4,27 @@
|
|||||||
#ifndef _CLOCKING_H_
|
#ifndef _CLOCKING_H_
|
||||||
#define _CLOCKING_H_
|
#define _CLOCKING_H_
|
||||||
|
|
||||||
|
interface pll_ref_if
|
||||||
|
|
||||||
interface sync_if
|
|
||||||
{
|
{
|
||||||
void toggle();
|
void toggle();
|
||||||
void init();
|
void init();
|
||||||
void toggle_timed(int relative);
|
void toggle_timed(int relative);
|
||||||
};
|
};
|
||||||
|
|
||||||
[[combinable]]
|
[[distributable]]
|
||||||
void PllRefPinTask(server interface sync_if i_sync, out port p_sync);
|
void PllRefPinTask(server interface pll_ref_if i_pll_ref, out port p_sync);
|
||||||
|
|
||||||
/** Clock generation and digital audio I/O handling.
|
/** Clock generation and digital audio I/O handling.
|
||||||
*
|
*
|
||||||
* \param c_spdif_rx channel connected to S/PDIF receive thread
|
* \param c_spdif_rx channel connected to S/PDIF receive thread
|
||||||
* \param c_adat_rx channel connect to ADAT receive thread
|
* \param c_adat_rx channel connect to ADAT receive thread
|
||||||
* \param p port to output clock signal to drive external frequency synthesizer
|
* \param i_pll_ref interface to taslk that outputs clock signal to drive external frequency synthesizer
|
||||||
* \param c_audio channel connected to the audio() thread
|
* \param c_audio channel connected to the audio() thread
|
||||||
* \param c_clk_ctl channel connected to Endpoint0() for configuration of the
|
* \param c_clk_ctl channel connected to Endpoint0() for configuration of the
|
||||||
* clock
|
* clock
|
||||||
* \param c_clk_int channel connected to the decouple() thread for clock
|
* \param c_clk_int channel connected to the decouple() thread for clock
|
||||||
interrupts
|
interrupts
|
||||||
*/
|
*/
|
||||||
#if (AUDIO_IO_TILE == PLL_REF_TILE)
|
void clockGen(streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interface pll_ref_if i_pll_ref, chanend c_audio, chanend c_clk_ctl, chanend c_clk_int);
|
||||||
void clockGen(streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interface out port p_pll_ref, chanend c_audio, chanend c_clk_ctl, chanend c_clk_int);
|
|
||||||
#else
|
|
||||||
void clockGen(streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interface sync_if i_sync, chanend c_audio, chanend c_clk_ctl, chanend c_clk_int);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ void usb_audio_core(chanend c_mix_out
|
|||||||
, chanend ?c_clk_ctl
|
, chanend ?c_clk_ctl
|
||||||
, client interface i_dfu ?dfuInterface
|
, client interface i_dfu ?dfuInterface
|
||||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||||
, client interface sync_if i_sync
|
, client interface pll_ref_if i_pll_ref
|
||||||
#endif
|
#endif
|
||||||
VENDOR_REQUESTS_PARAMS_DEC_
|
VENDOR_REQUESTS_PARAMS_DEC_
|
||||||
)
|
)
|
||||||
@@ -373,7 +373,7 @@ VENDOR_REQUESTS_PARAMS_DEC_
|
|||||||
#endif
|
#endif
|
||||||
, c_mix_out
|
, c_mix_out
|
||||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||||
, i_sync
|
, i_pll_ref
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
//:
|
//:
|
||||||
@@ -432,8 +432,8 @@ void usb_audio_io(chanend ?c_aud_in,
|
|||||||
#endif
|
#endif
|
||||||
, chanend c_pdm_pcm
|
, chanend c_pdm_pcm
|
||||||
#endif
|
#endif
|
||||||
#if (XUA_SPDIF_RX_EN && (AUDIO_IO_TILE != PLL_REF_TILE))
|
#if (XUA_SPDIF_RX_EN || ADAT_RX)
|
||||||
, client interface sync_if i_sync
|
, client interface pll_ref_if i_pll_ref
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -506,13 +506,11 @@ void usb_audio_io(chanend ?c_aud_in,
|
|||||||
|
|
||||||
#if (XUA_SPDIF_RX_EN || ADAT_RX)
|
#if (XUA_SPDIF_RX_EN || ADAT_RX)
|
||||||
{
|
{
|
||||||
/* ClockGen must currently run on same tile as AudioHub due to shared memory buffer */
|
/* ClockGen must currently run on same tile as AudioHub due to shared memory buffer
|
||||||
|
* However, due to the use of an interface the pll reference signal port can be on another tile
|
||||||
|
*/
|
||||||
thread_speed();
|
thread_speed();
|
||||||
#if AUDIO_IO_TILE == PLL_REF_TILE
|
clockGen(c_spdif_rx, c_adat_rx, i_pll_ref, c_dig_rx, c_clk_ctl, c_clk_int);
|
||||||
clockGen(c_spdif_rx, c_adat_rx, p_pll_ref, c_dig_rx, c_clk_ctl, c_clk_int);
|
|
||||||
#else
|
|
||||||
clockGen(c_spdif_rx, c_adat_rx, i_sync, c_dig_rx, c_clk_ctl, c_clk_int);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -590,8 +588,8 @@ int main()
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) || (XUA_SPDIF_RX_EN && (AUDIO_IO_TILE != PLL_REF_TILE))
|
#if ((XUA_SYNCMODE == XUA_SYNCMODE_SYNC) || XUA_SPDIF_RX_EN || ADAT_RX)
|
||||||
interface sync_if i_sync;
|
interface pll_ref_if i_pll_ref;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
USER_MAIN_DECLARATIONS
|
USER_MAIN_DECLARATIONS
|
||||||
@@ -600,8 +598,8 @@ int main()
|
|||||||
{
|
{
|
||||||
USER_MAIN_CORES
|
USER_MAIN_CORES
|
||||||
|
|
||||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) || (XUA_SPDIF_RX_EN && (AUDIO_IO_TILE != PLL_REF_TILE))
|
#if ((XUA_SYNCMODE == XUA_SYNCMODE_SYNC) || XUA_SPDIF_RX_EN || ADAT_RX)
|
||||||
on tile[PLL_REF_TILE]: PllRefPinTask(i_sync, p_pll_ref);
|
on tile[PLL_REF_TILE]: PllRefPinTask(i_pll_ref, p_pll_ref);
|
||||||
#endif
|
#endif
|
||||||
on tile[XUD_TILE]:
|
on tile[XUD_TILE]:
|
||||||
par
|
par
|
||||||
@@ -629,7 +627,7 @@ int main()
|
|||||||
#endif
|
#endif
|
||||||
, c_clk_int, c_clk_ctl, dfuInterface
|
, c_clk_int, c_clk_ctl, dfuInterface
|
||||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||||
, i_sync
|
, i_pll_ref
|
||||||
#endif
|
#endif
|
||||||
VENDOR_REQUESTS_PARAMS_
|
VENDOR_REQUESTS_PARAMS_
|
||||||
|
|
||||||
@@ -656,8 +654,8 @@ int main()
|
|||||||
#endif
|
#endif
|
||||||
, c_pdm_pcm
|
, c_pdm_pcm
|
||||||
#endif
|
#endif
|
||||||
#if (XUA_SPDIF_RX_EN && (AUDIO_IO_TILE != PLL_REF_TILE))
|
#if (XUA_SPDIF_RX_EN || ADAT_RX)
|
||||||
, i_sync
|
, i_pll_ref
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user