EmbDev.net

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


Author: Karthiga G. (karthiga05)
Posted on:

Rate this post
0 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! :)
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity counter4 is
   port(count:out std_logic_vector(3 downto 0);
        clk:in std_logic;
        reset:in std_logic);
end counter4;

architecture behav_counter4 of counter4 is
    
   component ha port (a: in  std_logic;
                      b: in  std_logic;
                      sum: out std_logic;
                      c_out: out std_logic);
   end component;
   
   component fa port (a, b, cin : in std_logic;
                      sum, c_out : out std_logic);
   end component;
   
   signal ain,s,c:std_logic_vector(3 downto 0);
   signal bin:std_logic_vector(3 downto 0):="0001";
               
   --configuration specification   
   for all:ha use entity work.ha(rtl);
   for all:fa use entity work.fa(fa_behav);
      
   begin
      u1:ha port map(a => ain(0), b => bin(0), sum => s(0), c_out => c(0));
      u2:fa port map(a => ain(1), b => bin(1), sum => s(1), cin => c(0), c_out => c(1));
      u3:fa port map(a => ain(2), b => bin(2), sum => s(2), cin => c(1), c_out => c(2));
      u4:fa port map(a => ain(3), b => bin(3), sum => s(3), cin => c(2), c_out => c(3));
      
      
      counter:process(clk, reset) --process(sensitivity list)
      begin
         if reset'event and (reset = '1') then 
            ain <= (others => '0'); 
         
         elsif (clk'event and clk='1') then
            ain <= s; 
            count <= s;
                
         end if;
      end process;
           
end behav_counter4; 

Author: Thomas Reinemann (Company: abaxor engineering) (abaxor)
Posted on:

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

Tom

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

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

Author: Karthiga G. (karthiga05)
Posted on:

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

i have done so but it shows error.

Author: Br ian (brian_w17)
Posted on:

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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.