diff --git a/synth/digilent_atlys/ac97out.vhdl b/synth/digilent_atlys/ac97out.vhdl
index fae2365..15342e7 100644
--- a/synth/digilent_atlys/ac97out.vhdl
+++ b/synth/digilent_atlys/ac97out.vhdl
@@ -51,7 +51,6 @@ architecture rtl of ac97out is
x"800000" );
-- Output registers.
- signal r_ready: std_logic;
signal r_sdo: std_logic;
signal r_sync: std_logic;
@@ -76,7 +75,7 @@ architecture rtl of ac97out is
begin
-- Drive outputs.
- data_ready <= r_ready;
+ data_ready <= not r_datavalid;
ac97_sdo <= r_sdo;
ac97_sync <= r_sync;
@@ -155,15 +154,12 @@ begin
end if;
-- Capture input data.
- if r_ready = '1' and data_valid = '1' then
+ if r_datavalid = '0' and data_valid = '1' then
r_datavalid <= '1';
r_dataleft <= std_logic_vector(data_left);
r_dataright <= std_logic_vector(data_right);
end if;
- -- Update ready flag.
- r_ready <= (not r_datavalid) and (not data_valid);
-
-- Synchronous reset.
if rst = '1' then
r_initdone <= '0';
diff --git a/synth/digilent_atlys/test_sincos.gise b/synth/digilent_atlys/test_sincos.gise
index 37d03a4..59a6dac 100644
--- a/synth/digilent_atlys/test_sincos.gise
+++ b/synth/digilent_atlys/test_sincos.gise
@@ -52,6 +52,7 @@
+
@@ -76,6 +77,7 @@
+
@@ -101,7 +103,7 @@
-
+
@@ -123,7 +125,7 @@
-
+
@@ -132,12 +134,10 @@
-
+
-
-
@@ -148,7 +148,7 @@
-
+
@@ -163,7 +163,7 @@
-
+
@@ -176,7 +176,7 @@
-
+
diff --git a/synth/digilent_atlys/test_sincos.xise b/synth/digilent_atlys/test_sincos.xise
index 0fdf5c1..714ab01 100644
--- a/synth/digilent_atlys/test_sincos.xise
+++ b/synth/digilent_atlys/test_sincos.xise
@@ -17,7 +17,7 @@
-
+
@@ -36,15 +36,17 @@
+
+
+
+
-
-
@@ -58,8 +60,6 @@
-
-
@@ -76,55 +76,44 @@
-
-
-
-
-
-
-
-
-
+
-
-
-
@@ -132,12 +121,10 @@
-
-
@@ -164,12 +151,9 @@
-
-
-
@@ -187,7 +171,6 @@
-
@@ -208,7 +191,6 @@
-
@@ -220,7 +202,6 @@
-
@@ -252,7 +233,6 @@
-
@@ -260,9 +240,7 @@
-
-
@@ -280,7 +258,6 @@
-
@@ -305,7 +282,6 @@
-
@@ -313,12 +289,10 @@
-
-
@@ -333,8 +307,6 @@
-
-
@@ -359,28 +331,21 @@
-
-
-
-
-
-
-
diff --git a/synth/digilent_atlys/top_test_sincos.vhd b/synth/digilent_atlys/top_test_sincos.vhd
index 6c780b3..3a7bcd1 100644
--- a/synth/digilent_atlys/top_test_sincos.vhd
+++ b/synth/digilent_atlys/top_test_sincos.vhd
@@ -31,7 +31,7 @@
-- LED 3 = Transmitting
--
-- AC97 audio:
--- not yet implemented
+-- 999.985 Hz sine wave on output
--
library ieee;
@@ -42,17 +42,17 @@ entity top_test_sincos is
port (
-- 100 MHz system clock
- clk: in std_logic;
+ clk: in std_logic;
-- Reset button
- resetn: in std_logic;
+ resetn: in std_logic;
-- Status LEDs
- led: out std_logic_vector(7 downto 0);
+ led: out std_logic_vector(7 downto 0);
-- Uart
- uartrx: in std_logic;
- uarttx: out std_logic;
+ uartrx: in std_logic;
+ uarttx: out std_logic;
-- AC97 audio
ac97_bitclk: in std_logic;
@@ -65,9 +65,21 @@ end entity;
architecture rtl of top_test_sincos is
+ -- Frequency is 21845 / 2**20 * 48000 Hz = 999.985 Hz
+ constant tone_freq: integer := 21845;
+
signal r_rstgen: std_logic_vector(7 downto 0) := "00000000";
signal r_reset: std_logic;
+ signal r_ac97_rstcnt: unsigned(7 downto 0);
+ signal r_ac97_rst: std_logic;
+ signal r_ac97_rstsync: std_logic_vector(7 downto 0);
+ signal r_ac97_phase: unsigned(19 downto 0);
+ signal s_ac97_sine: signed(17 downto 0);
+ signal s_ac97_dataleft: signed(19 downto 0);
+ signal s_ac97_dataright: signed(19 downto 0);
+ signal s_ac97_ready: std_logic;
+
begin
-- Instantiate test design with serial interface.
@@ -84,13 +96,35 @@ begin
stat_clkmod => led(2),
stat_txser => led(3) );
+ -- Instantiate sine generator for AC97 output.
+ u1: entity work.sincos_gen_d18_p20
+ port map (
+ clk => ac97_bitclk,
+ clk_en => '1',
+ in_phase => r_ac97_phase,
+ out_sin => s_ac97_sine,
+ out_cos => open );
+
+ -- Instantiate AC97 output
+ u2: entity work.ac97out
+ port map (
+ bitclk => ac97_bitclk,
+ rst => r_ac97_rstsync(0),
+ data_left => s_ac97_dataleft,
+ data_right => s_ac97_dataright,
+ data_valid => '1',
+ data_ready => s_ac97_ready,
+ ac97_sdo => ac97_sdo,
+ ac97_sync => ac97_sync );
+
+ s_ac97_dataleft <= s_ac97_sine & "00";
+ s_ac97_dataright <= s_ac97_sine & "00";
+
-- Drive unused LEDs.
led(7 downto 4) <= "0000";
- -- AC97 not yet implemented
- ac97_sdo <= '0';
- ac97_sync <= '0';
- ac97_rst <= '0';
+ -- Drive AC97 reset pin.
+ ac97_rst <= r_ac97_rst;
-- Reset synchronizer.
process (clk) is
@@ -106,5 +140,34 @@ begin
end if;
end process;
+ -- Reset generator for AC97 codec.
+ process (clk) is
+ begin
+ if rising_edge(clk) then
+ if r_reset = '1' then
+ r_ac97_rstcnt <= (others => '1');
+ r_ac97_rst <= '0';
+ else
+ r_ac97_rstcnt <= r_ac97_rstcnt - 1;
+ if r_ac97_rstcnt = 0 then
+ r_ac97_rst <= '1';
+ end if;
+ end if;
+ end if;
+ end process;
+
+ -- Synchronous process in AC97 bitclock domain.
+ process (ac97_bitclk, r_ac97_rst) is
+ begin
+ if r_ac97_rst = '0' then
+ r_ac97_rstsync <= (others => '1');
+ elsif rising_edge(ac97_bitclk) then
+ r_ac97_rstsync <= "0" & r_ac97_rstsync(7 downto 1);
+ if s_ac97_ready = '1' then
+ r_ac97_phase <= r_ac97_phase + tone_freq;
+ end if;
+ end if;
+ end process;
+
end architecture;