// codec_loopback_demo.v -- Codec loopback demo // Ed Doering // 07/18/2000 // // //------------------------------------------------------------------------------- // Uncomment the `define line below *only* if targeting the XStend version 1.3 board // (the XStend board includes Schmitt trigger inverters between the FPGA // and each of the four codec control inputs) `define XSTEND 1 module Codec_Loopback_Demo ( // Loop the codec output back to its input // Inputs: I$Clock // 12MHz clock , I$Reset // Active high asynchronous reset , I$SerialDataFromCodec // Serial data from codec (connect to 'SDOUT' signal) , // Outputs: O$LeftChannelDataValid // Indicates when left channel data is valid, active high , O$RightChannelDataValid // Indicates when right channel data is valid, active high , O$MasterClock // connect to 'MCLK' of codec , O$LeftRightClock // connect to 'LRCK' of codec , O$SerialClock // connect to 'SCLK' of codec , O$SerialDataToCodec // connect to 'SDIN' of codec `ifdef XSTEND , O$MicroReset // connect to 8051 microcontroller reset pin , O$RAMOutputEnable // connect to RAM output enable `endif ); // Port mode declarations: input I$Clock; input I$Reset; input I$SerialDataFromCodec; output O$LeftChannelDataValid; output O$RightChannelDataValid; output O$MasterClock; output O$LeftRightClock; output O$SerialClock; output O$SerialDataToCodec; `ifdef XSTEND output O$MicroReset; output O$RAMOutputEnable; `endif // Registered variable declarations: reg O$LeftChannelDataValid; reg O$RightChannelDataValid; // Wire declarations: wire [19:0] w$Left; wire [19:0] w$Right; wire w$MasterClock; wire w$LeftRightClock; wire w$SerialClock; wire w$SerialDataToCodec; `ifdef XSTEND // Hold the XS40 micro in reset mode, and disable the RAM output assign O$MicroReset = 1; assign O$RAMOutputEnable = 1; // Invert the four codec signals to cancel out the inverters assign O$MasterClock = ~w$MasterClock; assign O$LeftRightClock = ~w$LeftRightClock; assign O$SerialClock = ~w$SerialClock; assign O$SerialDataToCodec = ~w$SerialDataToCodec; `else assign O$MasterClock = w$MasterClock; assign O$LeftRightClock = w$LeftRightClock; assign O$SerialClock = w$SerialClock; assign O$SerialDataToCodec = w$SerialDataToCodec; `endif // Instantiate the codec interface, and wire for loopback Codec U1 ( // Inputs: .I$Clock ( I$Clock ), .I$Reset ( I$Reset ), .I$LeftChannel ( w$Left ), .I$RightChannel ( w$Right ), .I$SerialDataFromCodec ( I$SerialDataFromCodec ), // Outputs: .O$LeftChannel ( w$Left ), .O$RightChannel ( w$Right ), .O$LeftChannelDataValid ( O$LeftChannelDataValid ), .O$RightChannelDataValid( O$RightChannelDataValid ), .O$MasterClock ( w$MasterClock ), .O$LeftRightClock ( w$LeftRightClock ), .O$SerialClock ( w$SerialClock ), .O$SerialDataToCodec ( w$SerialDataToCodec ) ); endmodule