Sorry, Guys. We're not quite done yet with the quadrature encoder. I tried to rewrite it as a synchronous process. The behavioral sim shows it working as intended. The post-route sim and onboard test don't work. 'debouncing' never changes state in the sim. The leds don't sequence when I twist the magic knob.
Can someone please look at the following and comment? I suspect it may be a mistiming on setting a_prev and b_prev. a_prev and b_prev are the sampled states of 'a' and 'b' during the previous clock. The intended function is that we test for a change in 'a'. If it's an active-edge change, it updates the count according the direction indicated by 'b'. The other edge of 'a' simply debounces to skip the noise. The next change in 'b' cancels the debounce.
In general, is it always this difficult and fraught with peril? I write >2000 lines/month in C++ with only minor misspelling mishaps. These 50 lines have caused me more gray hairs than many whole systems.
Also, is there a way to tell XST to not treat reset as a clock? I haven't fully read up on configuration, having spent way too much time on this little time waster.
Last, .... is this really worth pursuing? I've been programming for 25 years, and know that the greatest leassons come after the greatest pain. But there's also good pain, and just senseless injury. Is this not a suitable first Zen parable to contemplate? I'm goaded forward by the belief that there's a good lesson on synchronous systems lurking as the punchline.
(If it matters, the target is a Spartan-3A DSP starter kit board. ISE 10.1 tools.)
Thanks. Mike.
===================================================== library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL;
------------------ entity q_decode is Port ( a : in STD_LOGIC; b : in STD_LOGIC; clk : in STD_LOGIC; rst : in STD_LOGIC; leds : out std_logic_vector(7 downto 0)); end q_decode;
architecture Behavioral of q_decode is signal debouncing : STD_LOGIC := '0'; signal a_prev, b_prev : STD_LOGIC := '0'; signal a_start : STD_LOGIC := '0'; signal count : std_logic_vector(3 downto 0) := "1001"; begin process (clk, rst, a, b) begin if (rst = '1') then a_start