P
Preben Holm
Guest
Hi,
(question first asked in comp.arch.fpga, but think it probably suits
this group better since this more a VHDL question than FPGA in general
question)
I wonder why this results in undefined values (further comments in
bottom of post):
----------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
--use UNISIM.VComponents.all;
entity trigger_level is
Port ( clk : in std_logic;
prescale : in std_logic;
din : in std_logic_vector(7 downto 0);
level : in std_logic_vector(7 downto 0);
rf : in std_logic;
hold : in std_logic;
trig : out std_logic);
end trigger_level;
architecture Behavioral of trigger_level is
type samples_buffer is array(9 downto 0) of
std_logic_vector(7 downto 0);
signal samples : samples_buffer;
begin
process(clk)
begin
if rising_edge(clk) and prescale = '1' and hold = '0' then
-- no reset circuit (not needed) for reducing the number of
slices to 1 instead of 5
for i in 9 downto 1 loop
samples(i) <= samples(i-1);
end loop;
samples(0) <= din;
end if;
end process;
process(clk)
begin
if rising_edge(clk) then
if (rf = '1') then --- falling edge
if (samples(0) < level and samples(9) > level) then
trig <= '1';
else
trig <= '0';
end if;
elsif (rf = '0') then --- rising edge
if (samples(0) > level and samples(9) < level) then
trig <= '1';
else
trig <= '0';
end if;
else
trig <= '0';
end if;
end if;
end process;
end Behavioral;
----------------------------------
The design should be a trigger for an oscilloscope, and I think I have
an error in my design here! The trouble is that I get triggers where I
shouldn't! (or my presampler probably doesn't work, but I think this
simulation told me where the error was!)
The simulation "error" is viewable on my website:
http://www.interrupt.dk/sim.jpg
The trigger is a level/edge trigger that should activate on rising and
falling edges!
And like always: Thanks for helping
Preben Holm
(question first asked in comp.arch.fpga, but think it probably suits
this group better since this more a VHDL question than FPGA in general
question)
I wonder why this results in undefined values (further comments in
bottom of post):
----------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
--use UNISIM.VComponents.all;
entity trigger_level is
Port ( clk : in std_logic;
prescale : in std_logic;
din : in std_logic_vector(7 downto 0);
level : in std_logic_vector(7 downto 0);
rf : in std_logic;
hold : in std_logic;
trig : out std_logic);
end trigger_level;
architecture Behavioral of trigger_level is
type samples_buffer is array(9 downto 0) of
std_logic_vector(7 downto 0);
signal samples : samples_buffer;
begin
process(clk)
begin
if rising_edge(clk) and prescale = '1' and hold = '0' then
-- no reset circuit (not needed) for reducing the number of
slices to 1 instead of 5
for i in 9 downto 1 loop
samples(i) <= samples(i-1);
end loop;
samples(0) <= din;
end if;
end process;
process(clk)
begin
if rising_edge(clk) then
if (rf = '1') then --- falling edge
if (samples(0) < level and samples(9) > level) then
trig <= '1';
else
trig <= '0';
end if;
elsif (rf = '0') then --- rising edge
if (samples(0) > level and samples(9) < level) then
trig <= '1';
else
trig <= '0';
end if;
else
trig <= '0';
end if;
end if;
end process;
end Behavioral;
----------------------------------
The design should be a trigger for an oscilloscope, and I think I have
an error in my design here! The trouble is that I get triggers where I
shouldn't! (or my presampler probably doesn't work, but I think this
simulation told me where the error was!)
The simulation "error" is viewable on my website:
http://www.interrupt.dk/sim.jpg
The trigger is a level/edge trigger that should activate on rising and
falling edges!
And like always: Thanks for helping
Preben Holm