LIBRARY IEEE,work; USE IEEE.std_logic_1164.ALL; USE IEEE.std_logic_unsigned.ALL; USE work.codec.ALL; ENTITY channel IS GENERIC ( DAC_WIDTH: positive := 20; ADC_WIDTH: positive := 20 ); PORT ( -- interface I/O signals clk: IN std_logic; -- clock input reset: IN std_logic; -- synchronous active-high reset chan_on: IN std_logic; bit_cntr: IN std_logic_vector(5 DOWNTO 0); subcycle_cntr: IN std_logic_vector(1 DOWNTO 0); chan_sel: IN std_logic; -- select L/R channel for read/write rd: IN std_logic; -- read from the codec ADC wr: IN std_logic; -- write to the codec DAC adc_out: OUT std_logic_vector(ADC_WIDTH-1 DOWNTO 0); -- ADC output dac_in: IN std_logic_vector(DAC_WIDTH-1 DOWNTO 0); -- DAC input adc_out_rdy: OUT std_logic; -- ADC output is ready to be read adc_overrun: OUT std_logic; -- ADC overwritten before being read dac_in_rdy: OUT std_logic; -- DAC input is ready to be written dac_underrun: OUT std_logic; -- input to DAC arrived late -- codec chip I/O signals sdin: OUT std_logic; -- serial output to codec DAC sdout: IN std_logic -- serial input from codec ADC ); END channel; ARCHITECTURE channel_arch OF channel IS SIGNAL dac_shfreg: std_logic_vector(DAC_WIDTH-1 DOWNTO 0); SIGNAL dac_empty: std_logic; -- DAC shift register is empty SIGNAL dac_wr: std_logic; -- the DAC channel has been written SIGNAL dac_wr_nxt: std_logic; -- the DAC channel has been written SIGNAL dac_in_rdy_int: std_logic; -- internal version of dac_in_rdy SIGNAL adc_shfreg: std_logic_vector(ADC_WIDTH-1 DOWNTO 0); SIGNAL adc_full: std_logic; -- ADC shift register is full SIGNAL adc_rd: std_logic; -- the ADC channel has been read SIGNAL adc_rd_nxt: std_logic; -- the ADC channel has been read SIGNAL adc_out_rdy_int: std_logic; -- internal version adc_out_rdy BEGIN -- receives data from codec ADC rcv_adc: PROCESS(clk,chan_on,subcycle_cntr,bit_cntr,adc_shfreg,sdout) BEGIN IF(clk'event AND (clk=YES)) THEN IF(reset='1') THEN adc_shfreg <= (OTHERS=>'0'); adc_full <= NO; ELSIF((chan_on=YES) AND (subcycle_cntr=2)) THEN IF(bit_cntr'0'); dac_empty <= YES; ELSIF(chan_sel=YES AND wr=YES) THEN dac_shfreg <= dac_in; ELSIF(chan_on=YES AND subcycle_cntr=2) THEN IF(bit_cntr