EmbDev.net

Forum: FPGA, VHDL & Verilog How to set value of a signal in process?


von Karthiga G. (karthiga05)


Rate this post
useful
not useful
hi. im required to not set bin=0001 whn i declare the signal. I am 
required to set the value of bin in the clk'event portion. how do i do 
tht?
thanks in advance! :)
1
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_unsigned.all;
4
5
entity counter4 is
6
   port(count:out std_logic_vector(3 downto 0);
7
        clk:in std_logic;
8
        reset:in std_logic);
9
end counter4;
10
11
architecture behav_counter4 of counter4 is
12
    
13
   component ha port (a: in  std_logic;
14
                      b: in  std_logic;
15
                      sum: out std_logic;
16
                      c_out: out std_logic);
17
   end component;
18
   
19
   component fa port (a, b, cin : in std_logic;
20
                      sum, c_out : out std_logic);
21
   end component;
22
   
23
   signal ain,s,c:std_logic_vector(3 downto 0);
24
   signal bin:std_logic_vector(3 downto 0):="0001";
25
               
26
   --configuration specification   
27
   for all:ha use entity work.ha(rtl);
28
   for all:fa use entity work.fa(fa_behav);
29
      
30
   begin
31
      u1:ha port map(a => ain(0), b => bin(0), sum => s(0), c_out => c(0));
32
      u2:fa port map(a => ain(1), b => bin(1), sum => s(1), cin => c(0), c_out => c(1));
33
      u3:fa port map(a => ain(2), b => bin(2), sum => s(2), cin => c(1), c_out => c(2));
34
      u4:fa port map(a => ain(3), b => bin(3), sum => s(3), cin => c(2), c_out => c(3));
35
      
36
      
37
      counter:process(clk, reset) --process(sensitivity list)
38
      begin
39
         if reset'event and (reset = '1') then 
40
            ain <= (others => '0'); 
41
         
42
         elsif (clk'event and clk='1') then
43
            ain <= s; 
44
            count <= s;
45
                
46
         end if;
47
      end process;
48
           
49
end behav_counter4;

von Thomas R. (Company: abaxor engineering) (abaxor)


Rate this post
useful
not useful
Don't use the event attribute on the reset.
1
 
2
       counter:process(clk, reset) --process(sensitivity list)
3
       begin
4
          if (reset = '1') then
5
             ain <= (others => '0');
6
 
7
          elsif (clk'event and clk='1') then
8
             ain <= s;
9
             count <= s;
10
             bin <= "0001";
11
          end if;
12
       end process;

Tom

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
> I am required to set the value of bin in the clk'event portion.
Why?

von Karthiga G. (karthiga05)


Rate this post
useful
not useful
Thomas Reinemann wrote:
> Don't use the event attribute on the reset.
>
>
1
>           elsif (clk'event and clk='1') then
2
>              ain <= s;
3
>              count <= s;
4
>              bin <= "0001";
5
>           end if;
6
>        end process;
7
>
>
> Tom

i have done so but it shows error.

von Br i. (brian_w17)


Rate this post
useful
not useful
What errors are you getting?

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.