atancic
Newbie level 6
Hello, I am trying to generate different waveforms. I started with generating square wave. Once I managed to do it, I switched to triangular and this is my code below. I am using DAC800 and when I run the simulation it looks to me that the code is good as values of dac_out change as they should but when I implement it on the board I do not get the desired output on the oscilloscope.
Am I making a mistake somewhere in the code?
Am I making a mistake somewhere in the code?
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use ieee.numeric_std_unsigned.all;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity triangulartest1 is
Port (clk, reset : in STD_LOGIC;
dac_out : out STD_LOGIC_VECTOR(7 downto 0));
end triangulartest1;
architecture Behavioral of triangulartest1 is
signal flag : natural;
signal temp : unsigned(7 downto 0) := "00000000";
begin
process(clk)
begin
if temp = "00000000" then flag <=0;
end if;
if temp = "11111111" then flag<=1;
end if;
if (rising_edge(clk)) and (flag = 0) then temp<= temp + "00000101";
dac_out <= std_logic_vector(temp);
elsif (rising_edge(clk)) and (flag = 1) then temp<= temp - "00000101";
dac_out <= std_logic_vector(temp);
end if;
end process;
end Behavioral;