How to set value of a signal in process?

OP #2252370
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;
(Company: abaxor engineering) #2252379
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

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.