- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys im very new in VHDL and im trying to write a program as to turn on an LED from the GPIO_0 which i put a PIR sensor to it..the PIR sensor is directly connectted to GPIO_O(0).. so the problem is that when i run the program some error show up and i havent have any idea how to correct it back. please help me guys..
:):):)Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
LEDR <= "0101" should be better.... Franck.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
and using a 5-bit value should help too
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- and using a 5-bit value should help too --- Quote End --- how do i set the 5- bit value. sory im realy dont know..hmm actualy the program i got it from my friend.. but i try to manipulated it but i did not work.. guys tq.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You defined your vectors as 5 bits wide (4 downto 0) so when you assign a value, you should also use 5 bits. "0101" is only 4 bits. You will need to put an extra bit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tq guys.. i finally able on running my program and the able to get the out from the pir sensor.. guys how can i put a delay to the out of my program.. if there any example that i can refer to. or can i use bad clock program as to put delay at the output...
a newbie in programming..tq for all of your help- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How long do you want your delay to be? For a one clock cycle delay you can just use a register. If you need more than that you will need a chain of registers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mr daixiwen
i would like to maintain the output around 1 to 5 minutes. can u give me a quick tutor about this register mr daixiwen.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you just need to maintain the output, you can just use a counter. After the output you want to maintain is generated, set the counter to the number of clock cycles you want to hold your value, and decrement it by one on each cycle. When it reaches zero, stop maintaining the value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- If you just need to maintain the output, you can just use a counter. After the output you want to maintain is generated, set the counter to the number of clock cycles you want to hold your value, and decrement it by one on each cycle. When it reaches zero, stop maintaining the value. --- Quote End --- Tq mr daixiwen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Library IEEE;
use IEEE.STD_LOGIC_SIGNED; use IEEE.STD_LOGIC_UNSIGNED; use ieee.std_logic_1164.all; use IEEE.numeric_std.all; entity ltestinggpiowithdelay is port( GPIO_0 : in std_logic_vector(2 downto 0); CLK : in std_logic; DIN : in std_logic_vector (2 DOWNTO 0); q : out std_logic_vector(2 downto 0)); end ltestinggpiowithdelay ; architecture bufferwithGpio_arc of ltestinggpiowithdelay is begin process(GPIO_0) begin if (GPIO_0(0)='1') then q<=GPIO_0(2 downto 0); else q<= "000"; end if; end process; clk_proc:process(CLK) variable count:std_logic_vector(2 downto 0) := "000"; begin if (CLK'EVENT AND CLK = '1') then if GPIO_0(0) = '1' then count := DIN; else count := "count+1 >"; end if; end if; q <= count after 50 ns; end process clk_proc; end bufferwithGpio_arc; mr daixiwen so my programming is basically to read the input from the PIR sensor and i would like to maintain the output for sometime when the PIR detects movement as to turn on a relay etc. please check whether my programming is correct or not. now when i compile the program it seems a new error stated( object with std_logic type cannot contain character 'C'object with std_logic type cannot contain character 'C').. i am already blank already. please guide me.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are several problems here. I would suggest to read a book or an online course on VHDL first.
use IEEE.STD_LOGIC_SIGNED;
use IEEE.STD_LOGIC_UNSIGNED;
use ieee.std_logic_1164.all;
use IEEE.numeric_std.all;
please don't do that. The non standard std_logic_signed and std_logic_unsigned cause many problems, especially when used at the same time than numeric_std. If you include both it is even worse because the operators on std_logic_vector are overloaded for both signed and unsigned operations. There is no way to know what will happen. Please only include std_logic_1164 and numeric_std variable count:std_logic_vector(2 downto 0) := "000";
as you are using numeric_std, you can declare this variable as an unsigned instead of std_logic_vector, and that way you can use the + and - operators on it. count := DIN;
once you change count to the unsigned type, this line won't work any more because count and DIN are different types. Either change the DIN port to also be an unsigned, or do an explicit cast: count := unsigned(DIN);
count := "count+1 >";
there are several syntax errors there. I don't know where the '>' is coming from, and the quotes "" are only used to specify a literal value. If you just want to increase the counter, do count := count+1;
Your code doesn't do anything yet when the counter reaches its final value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hm base on your explanation mr daixiwen how should i program my counter so that the output can hold at any time. how about some example or tutorial that i can refer to..tq mr daixiwen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know any example or tutorial about this subject, it is a rather trivial VHDL construction. Just have a counter value that you increase or decrease and do something when it reaches a predetermined value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i am creating a program tO TURN ON LED USINg switches from the de2 board. the problem is the program runs without errror just warning. and while i test it on my de2 board it doesnot goes as plan. so for my program is there is 3 switch the first switch must be turn on and the led will turn on, the second switch will turn on the second led and the 3rdrn on both switch also will turn the 3 led.. i wanted the first switch to be the main controller.. if the first switch does not turn switch 2 and 3 cannot turn on the led.. but when i try runn it with my de2 it doesnot work that way. only 1 led turn on.. i have set the pin assignment correctly..really need some advice on sloving this tq in advance
entity Mux is port( A_bus : in std_logic_vector(2 downto 0); output : out std_logic_vector(2 downto 0)); end Mux; architecture arc_nnmux of Mux is begin process(A_bus) begin if A_bus <= (2=>'0',1=> '0', 0=>'1')then output <="001"; elsif A_bus <=(2=>'0',1=>'1',0=>'1')then output <="011"; elsif A_bus <=(2=>'1',1=>'1',0=>'1')then output <="111"; else output<= "000"; end if; end process; end arc_nnmux;- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You code is rather confusing. Instead of using the <= operator I think it would be a lot easier to check individual bits of A_bus in your ifs. It would make the priority order more visible.
What do you call "first switch"? Is it the one connected to A_bus(0) or A_bus(2)? Did you check the polarity of the switch and led signals?- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page