- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm starting with vhdl, and i'm try to write any kind of comaprator with memory of the out signal. Can anyboidy help me.. Program have to check state of input from keypad (ps2) and check it is signal of a letter. if pressed keypad is a letter then on the out will be signal of these key LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY bufor IS PORT(in: IN STD_LOGIC_VECTOR (21 downto 0); out: OUT STD_LOGIC_VECTOR (7 downto 0)); END ENTITY; ARCHITECTURE mem OF bufor IS shared variable li1 : std_logic_vector(7 downto 0); shared variable li2 : std_logic_vector(7 downto 0); BEGIN process (in) is begin li1 := "00000000"; li2 := "00000000"; li1 := in(8 downto 1); -- checking of keypad key if (((li2) /= (li1))and (li1=( X"21" OR X"23" OR X"24" OR X"2B" OR X"34" OR X"33" OR X"43" OR X"3B" OR X"42" OR X"4B" OR X"3A" OR X"31" OR X"44" OR X"4D" OR X"15" OR X"2D" OR X"1B" OR X"2C" OR X"3C" OR X"2A" OR X"1D" OR X"22" OR X"35" OR X"1A"))) then li2 := li1; end if; out <= li2; end process; end mem;Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The OR chain you wrote is not correct; it will reduce in a
((li2) /= (li1)) and (li1 = X"7F") condition, since you are logically ORing the 8bit codes of keys. You should write: ... (li1 = X"21") OR (li1 = X"23") OR (li1 = X"24") OR ....- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cris72 i've fixed that :) you're BIG :) now i have a little problem, beacouse when the input signal isn't signal of keypad i have 0 ont the out...
Sorry for my english ;]- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- when the input signal isn't signal of keypad i have 0 ont the out... --- Quote End --- That's correct. The process you wrote indeed makes this. Infact every time the process runs (when 'in' changes), you assign li1 := "00000000"; li2 := "00000000"; then, whenever the 'if' condition is not fulfilled (namely when signal is not from keypad) your output keeps this zero status. If your code is supposed to hold the last keypad code on 'out' as long as a non-keypad code is received, simply remove these 2 lines.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page