Search code examples
vhdl

how i can put the IF loop work in my program


I am writing a program that does the following:

Purpose: To move the image on the screen.

Inputs: 8 x 8 image

Commands: 00 - shift to the right; 01- move left; 10 - move up; 11- scroll down.

and since I am new to VHDL I need some help.

library ieee;  
 use ieee.std_logic_1164.all;  
 use ieee.numeric_std.all;  

 entity imagem is  
  port(A,B,C,D,E,F,G,H : in unsigned(7 downto 0);  
      SEL : in unsigned(1 downto 0);  
       OTA,OTB,OTC,OTD,OTE,OTF,OTG,OTH: out unsigned(7 downto 0));  
 end imagem;  

architecture img of imagem is  
   begin  
     if SEL = "00"  then

        OTA <= A sll 1 ;
    OTB <= B sll 1 ; 
    OTC <= C sll 1 ; 
    OTD <= D sll 1 ; 
    OTE <= E sll 1 ; 
    OTF <= F sll 1 ; 
    OTG <= G sll 1 ; 
    OTH <= H sll 1 ; 

      elsif SEL = "01" then

    OTA <= A srl 1 ;
    OTB <= B srl 1 ; 
    OTC <= C srl 1 ; 
    OTD <= D srl 1 ; 
    OTE <= E srl 1 ; 
    OTF <= F srl 1 ; 
    OTG <= G srl 1 ; 
    OTH <= H srl 1 ; 

      elsif SEL = "10" then

    OTA <= B ;
    OTB <= C ; 
    OTC <= D ; 
    OTD <= E ; 
    OTE <= F ; 
    OTF <= G ; 
    OTG <= H ; 
    OTH <= "00000000" ; 

      else 

    OTA <= "00000000" ;
    OTB <= A ; 
    OTC <= B ; 
    OTD <= C ; 
    OTE <= D ; 
    OTF <= E ; 
    OTG <= F ; 
    OTH <= G ; 
      end if;       
 end img;

Solution

  • To make the IF statement work, put it inside a process...

    library ieee;  
     use ieee.std_logic_1164.all;  
     use ieee.numeric_std.all;  
    
     entity imagem is  
      port(A,B,C,D,E,F,G,H : in unsigned(7 downto 0);  
          SEL : in unsigned(1 downto 0);  
           OTA,OTB,OTC,OTD,OTE,OTF,OTG,OTH: out unsigned(7 downto 0));  
     end imagem;  
    
    architecture img of imagem is  
    begin
    process (SEL)
       begin  
         if SEL = "00"  then
    
            OTA <= A sll 1 ;
            OTB <= B sll 1 ; 
            OTC <= C sll 1 ; 
            OTD <= D sll 1 ; 
            OTE <= E sll 1 ; 
            OTF <= F sll 1 ; 
            OTG <= G sll 1 ; 
            OTH <= H sll 1 ; 
    
          elsif SEL = "01" then
    
            OTA <= A srl 1 ;
            OTB <= B srl 1 ; 
            OTC <= C srl 1 ; 
            OTD <= D srl 1 ; 
            OTE <= E srl 1 ; 
            OTF <= F srl 1 ; 
            OTG <= G srl 1 ; 
            OTH <= H srl 1 ; 
    
          elsif SEL = "10" then
    
        OTA <= B ;
        OTB <= C ; 
        OTC <= D ; 
        OTD <= E ; 
        OTE <= F ; 
        OTF <= G ; 
        OTG <= H ; 
        OTH <= "00000000" ; 
    
          else 
    
        OTA <= "00000000" ;
        OTB <= A ; 
        OTC <= B ; 
        OTD <= C ; 
        OTE <= D ; 
        OTF <= E ; 
        OTG <= F ; 
        OTH <= G ; 
          end if; 
    end process;
    
     end img;