nikhilsigma
Full Member level 2
- Joined
- Jun 19, 2010
- Messages
- 142
- Helped
- 17
- Reputation
- 34
- Reaction score
- 16
- Trophy points
- 1,298
- Location
- Delhi, India
- Activity points
- 2,584
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; ---- Uncomment the following library declaration if instantiating ---- any Xilinx primitives in this code. --library UNISIM; --use UNISIM.VComponents.all; entity server is Port ( a : in STD_LOGIC; -- a is the rquests from the user b : in STD_LOGIC; ar,ag,al : out STD_LOGIC:='0'); -- c is showinh the processing of disk according to request(a)... end server; architecture Behavioral of server is signal a1 :integer:=0; signal a2 :std_logic := '0'; begin reqA : process (a,a2,a1) begin if(a' event and a='1') then a1<=a1+1; end if; if(a2' event and a2='1') then a1<=a1-1; end if; if(a1>0) then al<='1'; ag<='0'; else al<='0'; if(a2='1') then ag<='0'; else ag<='1'; end if; end if; end process reqA; logic : process begin if(a1>0) then ar<='1'; a2<='1'; wait for 2 sec; -- wait for 2second clock ar<='0'; a2<='0'; elsif (a1=0) then a2<='0'; wait until rising_edge(b); -- wait for small clock end if; end process logic; end Behavioral;
you have two 'event statements for the same FF. the resources in the FPGA fabric do not support this.i had made that wait until rising_edge(clk).... so now both the wait statements are of this kind only.....
and i am writing vhdl for the first time...
so it would be very helpful, if you could please tell me...what are the bad points in that code....and why ??
Thanks...
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; ---- Uncomment the following library declaration if instantiating ---- any Xilinx primitives in this code. --library UNISIM; --use UNISIM.VComponents.all; entity server is Port ( clk : in STD_LOGIC; ain : in STD_LOGIC; ar: out STD_LOGIC; ao : out STD_LOGIC; -- dclk, p,q,r,s : out std_logic; ag : out STD_LOGIC); end server; architecture Behavioral of server is signal a,ai,ar1,tempclk : std_logic:='0'; signal a1, a2 : integer :=0; begin align :process(clk) -- aligns the asynchronous input signal to clk.....where a1 is the input from the switch... begin if(clk='1') then if(ain='1') then a<='1'; -- reproduced signal else a<='0'; end if; ai<=a; -- reproduced signal delayed by a clock cycle... end if; end process align; count : process(clk) -- count and record the input requests in a1. begin if(clk='1') then if(a='1' and ai='0') then a1<=a1+1; -- elsif rising_edge(a2) -- then -- a1<=a1-1; end if; end if; end process count; main:process(tempclk) -- main process giving delay(processing) on request(a1), begin if(tempclk='1') then if(a1-a2>0) -- difference of a1 and a2 will give the number of pending requests... then a2<=a2+1; --a2 keeps the record that how many requests have been processed.. ar<='1'; ar1<='1'; else ar<='0'; ar1<='0'; end if; end if; end process main; dispA: process(clk) -- displaying output on orange/yellow and green leds i.e. signal ao and ag respectively begin if(clk='1') then if(a1-a2>0) then ao<='1'; ag<='0'; else ao<='0'; if(ar1='1') then ag<='0'; else ag<='1'; end if; end if; end if; end process dispA; delclk : process(clk) -- generating a clock of 2seconds....in tempclk variable i: integer:=0; begin if(clk='1') then i:=i+1; if(i>5) then tempclk<=not tempclk; i:=0; end if; end if; end process delclk; end Behavioral;
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; ---- Uncomment the following library declaration if instantiating ---- any Xilinx primitives in this code. --library UNISIM; --use UNISIM.VComponents.all; entity server is Port ( clk : in STD_LOGIC; ain : in STD_LOGIC; ar: out STD_LOGIC; ao : out STD_LOGIC; ag : out STD_LOGIC); end server; architecture Behavioral of server is signal a,ai,ar1,tempclk : std_logic:='0'; signal a1, a2 : integer :=0; begin align :process(clk,ain) -- aligns the asynchronous input signal to clk.....where a1 is the input from the switch... begin if(rising_edge(clk)) then if(ain='1') then a<='1'; -- reproduced signal else a<='0'; end if; ai<=a; -- reproduced signal delayed by a clock cycle... end if; end process align; count : process(clk,a,ai) -- count and record the input requests in a1. begin if(rising_edge(clk)) then if(a='1' and ai='0') then a1<=a1+1; end if; end if; end process count; main:process(tempclk,a1,a2) -- main process giving delay(processing) on request(a1), begin if(rising_edge(tempclk)) then if(a1-a2>0) -- difference of a1 and a2 will give the number of pending requests... then a2<=a2+1; --a2 keeps the record that how many requests have been processed.. ar<='1'; ar1<='1'; else ar<='0'; ar1<='0'; end if; end if; end process main; dispA: process(clk,a1,a2,ar1) -- displaying output on orange/yellow and green leds i.e. signal ao and ag respectively begin if(rising_edge(clk)) then if(a1-a2>0) then ao<='1'; ag<='0'; else ao<='0'; if(ar1='1') then ag<='0'; else ag<='1'; end if; end if; end if; end process dispA; delclk : process(clk) -- generating a clock of 2seconds....in tempclk variable i: integer:=0; begin if(rising_edge(clk)) then i:=i+1; if(i>5) then tempclk<=not tempclk; i:=0; end if; end if; end process delclk; end Behavioral;
WARNING:Xst:2734 - Property "use_dsp48" is not applicable for this technology.
WARNING:Xst:2734 - Property "use_dsp48" is not applicable for this technology.
whats the difference between.....
process(clk)
if rising_edge(clk)
then
and
process(clk)
if clk='1'
then
The statement: if clk='1' is not a synchronous one, it's only looking at a level. What you want is: if clk='1' and clk'event. THAT is the same as 'if rising_edge...
The big difference is that yes you are correct if you are simulating, but the synthesisor ignores the sensitivity list when it compiles, and looks just at the logic. The sensitity list is only for simulation. So, the synthesisor just sees a level sensitive latch in the second process.
This is not a bug or a problem with VHDL, it is the way it always has been and always will be.
it does matter. The 2nd example is illegal VHDL because a process must have either a sensitivity list OR contain a wait statement.
The sensitivity list is essential for simulation, because without a sensitivity list, the process does nothing and will never do anything, except for the first runthrough at sim start.
A sensitivity list tells the simulator which signals should trigger the process. In the case of the top one, the process gets "run" whenever there is a 'event on the clk signal.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?