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.

VHDL to Verilog Problem !

Status
Not open for further replies.

angjohn

Junior Member level 2
Junior Member level 2
Joined
Aug 29, 2004
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
272
do u any1 of u know how to translate foolwing VHDL code to Verilog other than the verilog source code i show below ( can any1 know how to translate the code to verilog without using the disable Stament)!

VHDL :
Code:
-- BitComparator
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;

entity BitComparator is
	port (
		d : in STD_LOGIC_VECTOR(15 downto 0);
		whichbit : in STD_LOGIC_VECTOR(3 downto 0);
		set : out STD_LOGIC;
		en : in STD_LOGIC;
		CLK : in STD_LOGIC
	);
end BitComparator;

architecture BitComparator_arch of BitComparator is
	signal BitSelect : STD_LOGIC;
begin
	-- Enter concurrent statements here
	
	process(clk, en) 
	begin
		if(clk'event and clk='1') then
			
			--BitSelect <= '0';
			
			if (en = '1') then
				for i in 0 to 15 loop
					BitSelect <= d(i);
					exit when (i = whichbit); 
				end loop;
			end if;
		end if;
	end Process;
	
	Set <= BitSelect;
	
	
end BitComparator_arch;



Verilog
Code:
// BitComparator
module BitComparator (d, whichbit, set, en, CLK);

   input[15:0] d; 
   input[3:0] whichbit; 
   output set; 
   wire set;
   input en; 
   input CLK; 

   reg BitSelect; 

   always @(posedge CLK)
   begin
         if (en == 1'b1)
         begin
            begin : compare
               integer i;
               for(i = 0; i <= 15; i = i + 1)
               begin
                  BitSelect <= d[i] ; 
                  if ((i == whichbit)) disable compare; 
               end
            end 
         end 
   end 
   assign set = BitSelect ;
endmodule
 

u can use the software to translate it.
 

can anyone foward or suggest good verilog to vhdl conversion and vice versa software....

also are there any drawbacks in using the conversion softwares
 

Here is the translated code!
The best tool is ur BRAIN!!!

Code:
// BitComparator
module BitComparator (d, whichbit, set, en, CLK);
   input[15:0] d;
   input[3:0] whichbit;
   output set;
   
   input en;
   input CLK;

   reg         set;
   always @(posedge CLK)
         if (en == 1'b1) 
             set <= d[whichbit] ;
endmodule
 

You can write the Verilog code without using the disable statement as follows:

Code:
 if (en == 1'b1)
         begin
            begin : compare
               integer i;
               for(i = 0; i <= 15; i = i + 1)
               begin
                   if (i < whichbit)
                     BitSelect <= d[i] ;
               end
            end
         end
 

    angjohn

    Points: 2
    Helpful Answer Positive Rating
use x-hdl software


maxer
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top