Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

convert from verilog to vhdl plzz!!!

Status
Not open for further replies.

the_phoenix

Newbie level 6
Joined
Jul 26, 2006
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,439
to_stdlogic

hey guys, i need help urgently.

i'm a newbie at vlsi and as far as i'm concerned i've made myself fairly able at vhdl. i'm planning to reaslise the following project .This happens to be my first project with vhdl anyway.

link:: h**p://www.fpga4fun.com/PongGame.html

Now, i need u to plz convert this (at least the skeleton of the code) into vhdl so that i can look at a very simple implemetation .
Plzz help me with the translation of the code into vhdl.

cheers

any suggestions for possible circuit addons will be greatly appreciated!!!
 

vhdl to_stdlogic

I am wondering why you want to do that! Simulators can work with mixed design and also synthesis tools can synthesis the mixed-HDL code!
 

or_br

Here it goes.....
translation of pong.v
done with x-hdl eval version!

Code:
ENTITY pong IS
   PORT (
      clk                     : IN std_logic;   
      vga_h_sync              : OUT std_logic;   
      vga_v_sync              : OUT std_logic;   
      vga_R                   : OUT std_logic;   
      vga_G                   : OUT std_logic;   
      vga_B                   : OUT std_logic;   
      quadA                   : IN std_logic;   
      quadB                   : IN std_logic);   
END pong;

ARCHITECTURE translated OF pong IS

   COMPONENT hvsync_generator
      PORT (
         clk                     : IN  std_logic;
         vga_h_sync              : OUT std_logic;
         vga_v_sync              : OUT std_logic;
         inDisplayArea           : OUT std_logic;
         CounterX                : OUT std_logic_vector(9 DOWNTO 0);
         CounterY                : OUT std_logic_vector(8 DOWNTO 0));
   END COMPONENT;


   SIGNAL inDisplayArea            :  std_logic;   
   SIGNAL CounterX                 :  std_logic_vector(9 DOWNTO 0);   
   SIGNAL CounterY                 :  std_logic_vector(8 DOWNTO 0);   
   SIGNAL PaddlePosition           :  std_logic_vector(8 DOWNTO 0);   
   SIGNAL quadAr                   :  std_logic_vector(2 DOWNTO 0);   
   SIGNAL quadBr                   :  std_logic_vector(2 DOWNTO 0);   
   SIGNAL ballX                    :  std_logic_vector(9 DOWNTO 0);   
   SIGNAL ballY                    :  std_logic_vector(8 DOWNTO 0);   
   SIGNAL ball_inX                 :  std_logic;   
   SIGNAL ball_inY                 :  std_logic;   
   SIGNAL ball                     :  std_logic;   
   SIGNAL border                   :  std_logic;   
   SIGNAL paddle                   :  std_logic;   
   SIGNAL BouncingObject           :  std_logic;   
   SIGNAL ResetCollision           :  std_logic;   
   SIGNAL CollisionX1              :  std_logic;   
   SIGNAL CollisionX2              :  std_logic;   
   SIGNAL CollisionY1              :  std_logic;   
   SIGNAL CollisionY2              :  std_logic;   
   SIGNAL UpdateBallPosition       :  std_logic;   
   SIGNAL ball_dirX                :  std_logic;   
   SIGNAL ball_dirY                :  std_logic;   
   SIGNAL temp_xhdl12              :  std_logic;   
   SIGNAL temp_xhdl13              :  std_logic;   
   SIGNAL R                        :  std_logic;   
   SIGNAL G                        :  std_logic;   
   SIGNAL B                        :  std_logic;   
   SIGNAL vga_h_sync_xhdl1         :  std_logic;   
   SIGNAL vga_v_sync_xhdl2         :  std_logic;   
   SIGNAL vga_R_xhdl3              :  std_logic;   
   SIGNAL vga_G_xhdl4              :  std_logic;   
   SIGNAL vga_B_xhdl5              :  std_logic;   

BEGIN
   vga_h_sync <= vga_h_sync_xhdl1;
   vga_v_sync <= vga_v_sync_xhdl2;
   vga_R <= vga_R_xhdl3;
   vga_G <= vga_G_xhdl4;
   vga_B <= vga_B_xhdl5;
   syncgen : hvsync_generator 
      PORT MAP (
         clk => clk,
         vga_h_sync => vga_h_sync_xhdl1,
         vga_v_sync => vga_v_sync_xhdl2,
         inDisplayArea => inDisplayArea,
         CounterX => CounterX,
         CounterY => CounterY);   
   

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      quadAr <= quadAr(1 DOWNTO 0) & quadA;    
   END PROCESS;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      quadBr <= quadBr(1 DOWNTO 0) & quadB;    
   END PROCESS;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      IF ((((quadAr(2) XOR quadAr(1)) XOR quadBr(2)) XOR quadBr(1)) = '1') THEN
         IF ((quadAr(2) XOR quadBr(1)) = '1') THEN
            IF (NOT and_br(PaddlePosition) = '1') THEN
               PaddlePosition <= PaddlePosition + "000000001";    
            END IF;
         ELSE
            IF (or_br(PaddlePosition) = '1') THEN
               PaddlePosition <= PaddlePosition - "000000001";    
            END IF;
         END IF;
      END IF;
   END PROCESS;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      IF (ball_inX = '0') THEN
         ball_inX <= to_stdlogic(CounterX = ballX) AND ball_inY;    
      ELSE
         ball_inX <= to_stdlogic(NOT (CounterX = ballX + "0000010000"));    
      END IF;
   END PROCESS;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      IF (ball_inY = '0') THEN
         ball_inY <= to_stdlogic(CounterY = ballY);    
      ELSE
         ball_inY <= to_stdlogic(NOT (CounterY = ballY + "000010000"));    
      END IF;
   END PROCESS;
   ball <= ball_inX AND ball_inY ;
   border <= to_stdlogic((CounterX(9 DOWNTO 3) = "0000000") OR (CounterX(9 DOWNTO 3) = "1001111") OR (CounterY(8 DOWNTO 3) = "000000") OR (CounterY(8 DOWNTO 3) = "111011")) ;
   paddle <= to_stdlogic(((CounterX >= PaddlePosition + "000001000") AND (CounterX<=PaddlePosition + "001111000")) AND (CounterY(8 DOWNTO 4) = "11011")) ;
   BouncingObject <= border OR paddle ;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      ResetCollision <= to_stdlogic((CounterY = "111110100") AND (CounterX = "0000000000"));    
   END PROCESS;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      IF (ResetCollision = '1') THEN
         CollisionX1 <= '0';    
      ELSE
         IF (((BouncingObject AND to_stdlogic(CounterX = ballX)) AND to_stdlogic(CounterY = ballY + "000001000")) = '1') THEN
            CollisionX1 <= '1';    
         END IF;
      END IF;
   END PROCESS;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      IF (ResetCollision = '1') THEN
         CollisionX2 <= '0';    
      ELSE
         IF (((BouncingObject AND to_stdlogic(CounterX = ballX + "0000010000")) AND to_stdlogic(CounterY = ballY + "000001000")) = '1') THEN
            CollisionX2 <= '1';    
         END IF;
      END IF;
   END PROCESS;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      IF (ResetCollision = '1') THEN
         CollisionY1 <= '0';    
      ELSE
         IF (((BouncingObject AND to_stdlogic(CounterX = ballX + "0000001000")) AND to_stdlogic(CounterY = ballY)) = '1') THEN
            CollisionY1 <= '1';    
         END IF;
      END IF;
   END PROCESS;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      IF (ResetCollision = '1') THEN
         CollisionY2 <= '0';    
      ELSE
         IF (((BouncingObject AND to_stdlogic(CounterX = ballX + "0000001000")) AND to_stdlogic(CounterY = ballY + "000010000")) = '1') THEN
            CollisionY2 <= '1';    
         END IF;
      END IF;
   END PROCESS;
   UpdateBallPosition <= ResetCollision ;
   temp_xhdl12 <= '1' WHEN ball_dirX = '1' ELSE '1';
   temp_xhdl13 <= '1' WHEN ball_dirY = '1' ELSE '1';

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      IF (UpdateBallPosition = '1') THEN
         IF ((NOT (CollisionX1 AND CollisionX2)) = '1') THEN
            ballX <= ballX + (temp_xhdl12);    
            IF (CollisionX2 = '1') THEN
               ball_dirX <= '1';    
            ELSE
               IF (CollisionX1 = '1') THEN
                  ball_dirX <= '0';    
               END IF;
            END IF;
         END IF;
         IF ((NOT (CollisionY1 AND CollisionY2)) = '1') THEN
            ballY <= ballY + (temp_xhdl13);    
            IF (CollisionY2 = '1') THEN
               ball_dirY <= '1';    
            ELSE
               IF (CollisionY1 = '1') THEN
                  ball_dirY <= '0';    
               END IF;
            END IF;
         END IF;
      END IF;
   END PROCESS;
   R <= BouncingObject OR ball OR (CounterX(3) XOR CounterY(3)) ;
   G <= BouncingObject OR ball ;
   B <= BouncingObject OR ball ;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      vga_R_xhdl3 <= R AND inDisplayArea;    
      vga_G_xhdl4 <= G AND inDisplayArea;    
      vga_B_xhdl5 <= B AND inDisplayArea;    
   END PROCESS;

END translated;

translation of hvsync_generator
Code:
ENTITY hvsync_generator IS
   PORT (
      clk                     : IN std_logic;   
      vga_h_sync              : OUT std_logic;   
      vga_v_sync              : OUT std_logic;   
      inDisplayArea           : OUT std_logic;   
      CounterX                : OUT std_logic_vector(9 DOWNTO 0);   
      CounterY                : OUT std_logic_vector(8 DOWNTO 0));   
END hvsync_generator;

ARCHITECTURE translated OF hvsync_generator IS


   SIGNAL CounterXmaxed            :  std_logic;   
   SIGNAL vga_HS                   :  std_logic;   
   SIGNAL vga_VS                   :  std_logic;   
   SIGNAL vga_h_sync_xhdl1         :  std_logic;   
   SIGNAL vga_v_sync_xhdl2         :  std_logic;   
   SIGNAL inDisplayArea_xhdl3      :  std_logic;   
   SIGNAL CounterX_xhdl4           :  std_logic_vector(9 DOWNTO 0);   
   SIGNAL CounterY_xhdl5           :  std_logic_vector(8 DOWNTO 0);   

BEGIN
   vga_h_sync <= vga_h_sync_xhdl1;
   vga_v_sync <= vga_v_sync_xhdl2;
   inDisplayArea <= inDisplayArea_xhdl3;
   CounterX <= CounterX_xhdl4;
   CounterY <= CounterY_xhdl5;
   CounterXmaxed <= to_stdlogic(CounterX_xhdl4 = "1011111111") ;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      IF (CounterXmaxed = '1') THEN
         CounterX_xhdl4 <= "0000000000";    
      ELSE
         CounterX_xhdl4 <= CounterX_xhdl4 + "0000000001";    
      END IF;
   END PROCESS;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      IF (CounterXmaxed = '1') THEN
         CounterY_xhdl5 <= CounterY_xhdl5 + "000000001";    
      END IF;
   END PROCESS;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      vga_HS <= to_stdlogic(CounterX_xhdl4(9 DOWNTO 4) = "101101");    
      vga_VS <= to_stdlogic(CounterY_xhdl5 = "111110100");    
   END PROCESS;

   PROCESS
   BEGIN
      WAIT UNTIL (clk'EVENT AND clk = '1');
      IF (inDisplayArea_xhdl3 = '0') THEN
         inDisplayArea_xhdl3 <= (CounterXmaxed) AND to_stdlogic(CounterY_xhdl5 < "111100000");    
      ELSE
         inDisplayArea_xhdl3 <= to_stdlogic(NOT (CounterX_xhdl4 = "1001111111"));    
      END IF;
   END PROCESS;
   vga_h_sync_xhdl1 <= NOT vga_HS ;
   vga_v_sync_xhdl2 <= NOT vga_VS ;

END translated;
 

verilog wait until

thx a lot pal.......i cudnt quite thank u enough......

dont mind if i bug u in the future ......'guess i'll get cracking with it now!!!!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top