UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor prakece25
Visitor
11,268 Views
Registered: ‎02-11-2010

vhdl program

Jump to solution

if anyone have coding for division in vhdl please do help me 

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Visitor prakece25
Visitor
14,142 Views
Registered: ‎02-11-2010

Re: vhdl program

Jump to solution

actually i am doing program for integer division .numerator has lot more variables to be added . The denominator has only integer of 20.But xilinx is not accepting this division since it can accept only denominator should be of power of 2.

 

xkp00<=conv_std_logic_vector(conv_integer(fns(0))*conv_integer(xkp00)/20-8*conv_integer(xkp11)/20+48,10) ;

 

this is one of my coding line here only the denominator part 20 is not accepted . instead if i put 16+4  there is no error but the output is not coming properly.ie it shows all the outputs are 0.

0 Kudos
17 Replies
Historian
Historian
11,255 Views
Registered: ‎02-25-2008

Re: vhdl program

Jump to solution

prakece25 wrote:

if anyone have coding for division in vhdl please do help me 

 


entity divider is

    port (

        divisor : in integer;

        dividend : in integer;

        result : out integer);

end entity divider;

 

architecture dothemath of divider is

begin

    result <= dividend / divisor;

end architecture dothemath;

 

 

 

----------------------------Yes, I do this for a living.
Scholar drjohnsmith
Scholar
11,230 Views
Registered: ‎07-09-2009

Re: vhdl program

Jump to solution

Hi

 

can I ask what type of division . in time ( counter ) or in maths.

 

 

Integer, fixed point, floating point, divide by a constant or a variable ?

 

If you have a multiplier / divider it could be easy, if you have not, then its a big tree of code, or a rom.

 

The question is really what do you want to divide and by what ?

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
0 Kudos
Visitor prakece25
Visitor
14,143 Views
Registered: ‎02-11-2010

Re: vhdl program

Jump to solution

actually i am doing program for integer division .numerator has lot more variables to be added . The denominator has only integer of 20.But xilinx is not accepting this division since it can accept only denominator should be of power of 2.

 

xkp00<=conv_std_logic_vector(conv_integer(fns(0))*conv_integer(xkp00)/20-8*conv_integer(xkp11)/20+48,10) ;

 

this is one of my coding line here only the denominator part 20 is not accepted . instead if i put 16+4  there is no error but the output is not coming properly.ie it shows all the outputs are 0.

0 Kudos
Scholar drjohnsmith
Scholar
11,133 Views
Registered: ‎07-09-2009

Re: vhdl program

Jump to solution

HI

 

can I ask have you looked at what hardware this is generating ?

 

This looks like C code.

 

You have defined three inputs to a multiplier,

  fns(0) , ( xkp00/ 20 ) - 8, and (xkp11/20)+48

 and returned the answer to 10 bits.

 

 For the inputs, you have deifned  two divider, I assume 32 bit integers each  xkp00 / 20  and xkp11/20.

 

You have also defined a subtractor and an adder, probably on 64 bits.

 

Not the most efficient implimentaiont in hardware I guess. 

 

 

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
0 Kudos
Historian
Historian
11,110 Views
Registered: ‎02-25-2008

Re: vhdl program

Jump to solution

prakece25 wrote:

actually i am doing program for integer division .numerator has lot more variables to be added . The denominator has only integer of 20.But xilinx is not accepting this division since it can accept only denominator should be of power of 2.

 

xkp00<=conv_std_logic_vector(conv_integer(fns(0))*conv_integer(xkp00)/20-8*conv_integer(xkp11)/20+48,10) ;

 

this is one of my coding line here only the denominator part 20 is not accepted . instead if i put 16+4  there is no error but the output is not coming properly.ie it shows all the outputs are 0.


You're not "doing a program." You are describing hardware. There is a significant difference. You must understand this.

----------------------------Yes, I do this for a living.
0 Kudos
Visitor prakece25
Visitor
11,085 Views
Registered: ‎02-11-2010

Re: vhdl program

Jump to solution
thank u drjohnsmith but for simulation can i clear the error
0 Kudos
Visitor prakece25
Visitor
11,084 Views
Registered: ‎02-11-2010

Re: vhdl program

Jump to solution
thank u bassman59 . i can understand a little bit . but i dont know exactly.i hav just converted my matlab coding into vhdl.. that may be of problem. can u help me in anyway?
0 Kudos
Scholar drjohnsmith
Scholar
11,078 Views
Registered: ‎07-09-2009

Re: vhdl program

Jump to solution

HI

 

significant differance.  do you want to simulate only, or do you want to generate real silicon ( synthesise ).

   

Seems your using std logic arith, which in most places I go to is a big no no.

 

anyway.

 

You also have to look at order of ooperation even for synthesis.

 

 

xkp00<=conv_std_logic_vector(          [ conv_integer(fns(0)) * conv_integer(xkp00)/20 ]   - [ 8 *conv_integer(xkp11)/20  ] +  48     ,10         )

 

 I've added some brackets ( in [ ] ) just to show you what the synth is actualy doing ( it won't synth like that ).

 

 

Spliting this out 

  

A, B, C, D and E are 32 bit integers.

 

A <=  conv_integer(fns(0));

B <=  conv_integer(xkp00);

C <=  B / 20;

D <= conv_integerxkp11);

E <= 8 * D / 20;

 

 

this gives a 32 bit integer result, which you thentake 10 bits of, I don't know whic 10 bits the funciton takes, I don't use it. 

 

 

xkp00 <= conv_std_logic_vector ( ( A * C ) - E + 48, 10 ); -- i.e. take 10 bits

 

Is that the expresion you were expecting ?

 

 

A feature of MATLAB, that catches every one, 

  MATLAB work in floating point or integers of width X. Whilst VHDL works in integers of width Y, and preferable std_logic_vectors of width Z.

 

It's up to you to make certain you get the correct bits in MATLAB. 

   typical for something like this, the nearer your MATLAB code is like the VHDL with fixed size numbers, the better is will synthesis to good VHDL.

 

 

 

 

 

Message Edited by drjohnsmith on 10-03-2010 01:10 PM
<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
0 Kudos
Visitor prakece25
Visitor
11,035 Views
Registered: ‎02-11-2010

Re: vhdl program

Jump to solution

thank u drjohnsmith  u hav given

 

 

 

A, B, C, D and E are 32 bit integers.

 

A <=  conv_integer(fns(0));

B <=  conv_integer(xkp00);

C <=  B / 20;

D <= conv_integerxkp11);

E <= 8 * D / 20;

xkp00 <= conv_std_logic_vector ( ( A * C ) - E + 48, 10 ); -- i.e. take 10 bits

 

 if i do take the codings like this , will it work or not. i am taking here only 10 bits for my purpose

0 Kudos
Scholar drjohnsmith
Scholar
9,406 Views
Registered: ‎07-09-2009

Re: vhdl program

Jump to solution

Hi

 

that is your code,

  just split out so it's easier to discuss.

 

As you can see, it's a lot of logic, so although it would synthesis, I would not want to do so.

   For simulation, where you don't make silicon I can't see why it would not work.

 

It might also let you look at the 32 bit integers to see if your getting the intermediate values you expect.

  

e.g. what does B / 20 give you. is it a 32 bit answer or 64 bits ? if 64 bits, what happens to the other 32 bits if you assign it back to a 32 bit integer ?

 

In matlab or C etc, where everything is floating points, you ignore this, 

   In DSP or FPGA world, you need to know the  size of your numbers, and what happens to them

 

 

for instance, your conv_std_logic_vector functioni from synopsis.

   what does this do to a 32 bit integer ?

       Does it take the top 10 , bottom 10 , middle ten bits, round off / up or what ? You have to know.

          and it all depends where your data is sat in the integer. If it's all at the top end, then if the convert is taking the bottom 10 bits, then your going to get 0 out of the equaiton.

 

put it in a simulator, step throught a few numbers and see what each of the integers are, 

   You might be surprised.

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
Visitor prakece25
Visitor
9,399 Views
Registered: ‎02-11-2010

Re: vhdl program

Jump to solution

thank u drjohnsmith

                        i am taking here only the LSB 10 bits.But this coding is ok for model sim it  also shows the output  .but for implementation i need to work with xilinx. that's why i post here. but i need only 10 bit output.if i send u the coding would you clear the error?

0 Kudos
Scholar drjohnsmith
Scholar
9,394 Views
Registered: ‎07-09-2009

Re: vhdl program

Jump to solution

Hi

 

just to clarify, I don't work for xilinx.

 

I'm an independent  consultant, 

 

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
0 Kudos
Visitor prakece25
Visitor
9,383 Views
Registered: ‎02-11-2010

Re: vhdl program

Jump to solution
 Thank you drjohnsmith
0 Kudos
9,217 Views
Registered: ‎05-03-2010

Re: vhdl program

Jump to solution

hi i need the coding for scalabe encryption algorithm using fpga.. if any one have done it means please post it to praveensimbhu_86@yahoo.co.in or bprawinkumar@gmail.com... Need it urgent.. plz do the favor.. and also i did one coding in that i have got 2000 range of sliced used.. but in my existing paper for same input they got only 200 plus slices used.. plz any one tel me how to reduce the numbre of slices used from 2000 to 200 ranges...send to my mail id plzzzzzzzzzzz..

Tags (2)
0 Kudos
Scholar drjohnsmith
Scholar
9,203 Views
Registered: ‎07-09-2009

Re: vhdl program

Jump to solution

Hi

 

will it work? Yes, it's psedo code, so naturaly.

 

Will it give you the answer your expecting ? unlikely.

 

You have not answered the fundamental questions we asked you above, and until you do, it is not going to give the answer you expect !

 

Ok, on paper, put some numbers in for fns(0) and xkp00 and work out what you expect from xkp00 !

 

Can we see you results ?

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
0 Kudos
7,860 Views
Registered: ‎02-17-2013

Re: vhdl program

Jump to solution

hello i am writing a program for configuration declaration in this program i am making two architecture by one entity . in this program when i am compaling then last architectutre is compaling which is count_255. but i want execute architecture count_64k . how it can possible pls help me 

 

 

---------------------------------------------------------------------

LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;

ENTITY counter1 IS
PORT(load, clear, clk : IN std_logic;
data_in : IN INTEGER;
data_out : OUT INTEGER);
END counter1;
ARCHITECTURE count_64k OF counter1 IS
BEGIN
PROCESS(clk)
VARIABLE count : INTEGER := 0;
BEGIN
IF clear = '1' THEN
count := 0;
ELSIF load = '1' THEN
count := data_in;
ELSE
IF (clk'EVENT) AND (clk = '1') THEN
IF (count = 65535) THEN
count := 0;
ELSE
count := count + 1;
END IF;
END IF;
END IF;
data_out <= count;
END PROCESS;
END count_64k;
ARCHITECTURE count_255 OF counter1 IS
BEGIN
PROCESS(clk)
VARIABLE count : INTEGER := 0;
BEGIN
IF (clear = '1') THEN
count := 0;
ELSIF load = '1' THEN
count := data_in;
ELSE
IF (clk'EVENT) AND (clk = '1')
THEN
IF (count = 255) THEN
count := 0;
ELSE
count := count + 1;
END IF;

END IF;
END IF;
data_out <= count;
END PROCESS;
END count_255;

CONFIGURATION small_count OF counter1 IS
FOR count_255
END FOR;
END small_count;
CONFIGURATION big_count OF counter1 IS
FOR count_64k
END FOR;
END big_count;

0 Kudos
Adventurer
Adventurer
7,837 Views
Registered: ‎01-21-2011

Re: vhdl program

Jump to solution

@bassman59 wrote:

prakece25 wrote:

actually i am doing program for integer division .numerator has lot more variables to be added . The denominator has only integer of 20.But xilinx is not accepting this division since it can accept only denominator should be of power of 2.

 

xkp00<=conv_std_logic_vector(conv_integer(fns(0))*conv_integer(xkp00)/20-8*conv_integer(xkp11)/20+48,10) ;

 

this is one of my coding line here only the denominator part 20 is not accepted . instead if i put 16+4  there is no error but the output is not coming properly.ie it shows all the outputs are 0.


You're not "doing a program." You are describing hardware. There is a significant difference. You must understand this.


They hired me  to make those FPGA alive

they call me 'software' or 'coding' engineer or similar such name

I refuse the name, but I take $$$

 

:-)

 

 

0 Kudos