J
james.purvis
Hi,
I am a student of robotics at Plymouth University, England. I have
been using VHDL pretty solidly for about 5 months now and I have come
up against a rather devious problem. The project at hand is using a
small differential drive robot with an Altera Cyclone II FPGA and an
ATmel 64. Using the two active IR sensors on the robot we are to make
a line follower (easy part) that makes a "Happy" sound when it detects
that it has been on a black line twice (or more) within ten seconds
and a "Sad" sound if it has hit the line less than twice. The code
below is an entity which I intend to chose one of the two input
frequencies (Happy and Sad) and output the relevant one according to
the conditions previously specified.
I have also tried the following amendment:
I have tried a lot of different methods to get this to work, but my
biggest gripe at the moment is that when using SignalTap II
"StimCount" is determined to be a Combinational Group and I cannot
prove that it counts, whilst "Count" is a Registered group and works
perfectly. I will be honest, I'm pretty sure that I've got completely
the wrong method for StimCount at the moment, so any help or insight
would be greatly appreciated.
Image of node finder: http://imageshack.us/photo/my-images/685/nodefinder.png/
Cheers
James
I am a student of robotics at Plymouth University, England. I have
been using VHDL pretty solidly for about 5 months now and I have come
up against a rather devious problem. The project at hand is using a
small differential drive robot with an Altera Cyclone II FPGA and an
ATmel 64. Using the two active IR sensors on the robot we are to make
a line follower (easy part) that makes a "Happy" sound when it detects
that it has been on a black line twice (or more) within ten seconds
and a "Sad" sound if it has hit the line less than twice. The code
below is an entity which I intend to chose one of the two input
frequencies (Happy and Sad) and output the relevant one according to
the conditions previously specified.
Code:
library IEEE;
Use IEEE.std_logic_1164.all;
Use IEEE.numeric_std.all;
Use IEEE.math_real.all;
entity NoiseSelect is
port
(
-- Input ports
LftS : in std_logic; -- Left Opto-Sensor
RgtS : in std_logic; -- Right Opto-Sensor
Happy : in std_logic;
Sad : in std_logic;
HappyDone : in std_logic;
SadDone : in std_logic;
Clk : in std_logic; -- 1 Hz
SysClk : in std_logic; -- 50 MHz
-- Output ports
TenFlagOut : out std_logic;
Outfreq : out std_logic
);
end NoiseSelect;
architecture Selecter of NoiseSelect is
signal CanPlay : std_logic;
signal Count : unsigned (3 downto 0);
signal TenFlag : std_logic;
signal StimCount : unsigned (5 downto 0);
signal StimCountFlag : std_logic;
signal StimCountReset : std_logic;
begin
TenFlagOut <= TenFlag;
StimCountFlag <= RgtS or LftS;
--CanPlay <= not(HappyDone) and not(sadDone);
--------------------------------------------
TenSecCount: process(Clk,Count,TenFlag)
begin
if (Clk'event) and (Clk = '1') then -- Every one second
if (TenFlag = '0') then -- provided Tens flag is 0
Count <= Count + 1; -- increment counter
elsif (TenFlag = '1') then -- until counter reaches 9 (0 to 9 =
10)
Count <= "0000"; -- then reset counter to 0
end if;
end if;
end process;
--------------------------------------------
CountReset: process(Clk,Count,TenFlag)
begin
if (Count = "1001") then -- When counter reaches 9
TenFlag <= '1'; -- Show that 10 seconds have passed
else
TenFlag <= '0'; -- Else keep 10 sec flag low
end if;
end process;
--------------------------------------------
StimulusCount: process(RgtS,LftS,TenFlag,StimCount)
begin
if (SysClk'event) and (SysClk = '1') then
if (StimCountFlag = '1') and (StimCountReset = '0') then
StimCount <= StimCount + 1;
elsif (StimCountFlag = '0') and (StimCountReset = '0') then
StimCount <= StimCount;
elsif (StimCountReset = '1') then
StimCount <= "000000";
end if;
end if;
end process;
--------------------------------------------
StimCountRes: process(TenFlag,StimCountReset)
begin
if (TenFlag'event) and (TenFlag = '0') then
StimCountReset <= '1';
end if;
if (TenFlag = '1') then
StimCountReset <= '0';
elsif (TenFlag = '0') then
StimCountReset <= '0';
end if;
end process;
--------------------------------------------
end Selecter;
I have also tried the following amendment:
Code:
--------------------------------------------
StimulusCount: process(RgtS,LftS,TenFlag,StimCount)
begin
if (SysClk'event) and (SysClk = '1') then
if (StimCountFlag = '1') then
StimCount <= StimCount + 1;
elsif (StimCountReset = '1') then
StimCount <= "000000";
end if;
end if;
end process;
--------------------------------------------
StimCountRes: process(TenFlag,StimCountReset)
begin
if (TenFlag'event) and (TenFlag = '0') then
StimCountReset <= '1';
else
StimCountReset <= '0';
end if;
end process;
--------------------------------------------
I have tried a lot of different methods to get this to work, but my
biggest gripe at the moment is that when using SignalTap II
"StimCount" is determined to be a Combinational Group and I cannot
prove that it counts, whilst "Count" is a Registered group and works
perfectly. I will be honest, I'm pretty sure that I've got completely
the wrong method for StimCount at the moment, so any help or insight
would be greatly appreciated.
Image of node finder: http://imageshack.us/photo/my-images/685/nodefinder.png/
Cheers
James