divsec
Newbie level 4
how to convert a 8 bit input signal into analog using digital to analog converter(DAC)?
This is normal DAC program which takes clock and reset as input and produces square wave output.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity square_wave is
Port ( clk : in std_logic;
rst : in std_logic;
dac_out : out std_logic_vector(0 to 7));
end square_wave;
architecture Behavioral of square_wave is
signal temp : std_logic_vector(3 downto 0):="0000";
signal counter : std_logic_vector(0 to 7):="00000000";
signal en :std_logic;
begin
process(clk)
begin
if rising_edge(clk) then temp <= temp + '1' ;
end if;
end process;
process(temp(3))
begin
if rst='1' then counter <= "00000000";
elsif rising_edge(temp(3)) then
if counter<150 and en='0' then
counter <= counter +1 ;
en<='0';
dac_out <="00000000";
elsif counter=0 then en<='0';
else en<='1';
counter <= counter-1;
dac_out <="11111111";
end if;
end if;
end process;
end Behavioral;
can i use this program itself to covert 8 bit input into analog?if so where i should modify?
please help me regarding this...
This is normal DAC program which takes clock and reset as input and produces square wave output.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity square_wave is
Port ( clk : in std_logic;
rst : in std_logic;
dac_out : out std_logic_vector(0 to 7));
end square_wave;
architecture Behavioral of square_wave is
signal temp : std_logic_vector(3 downto 0):="0000";
signal counter : std_logic_vector(0 to 7):="00000000";
signal en :std_logic;
begin
process(clk)
begin
if rising_edge(clk) then temp <= temp + '1' ;
end if;
end process;
process(temp(3))
begin
if rst='1' then counter <= "00000000";
elsif rising_edge(temp(3)) then
if counter<150 and en='0' then
counter <= counter +1 ;
en<='0';
dac_out <="00000000";
elsif counter=0 then en<='0';
else en<='1';
counter <= counter-1;
dac_out <="11111111";
end if;
end if;
end process;
end Behavioral;
can i use this program itself to covert 8 bit input into analog?if so where i should modify?
please help me regarding this...