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 code for truncation

Status
Not open for further replies.
It all depands on whats your number representation code and what you want to achieve....
 

sir, for example input bit:10 bit,output bit:8 bit... means how to reduce this truncated 2 bits effects in information?
 

you can reduce the truncate error by rounding instead of choping

eg: output <= input(9 downto 2) --! choping
output <= input(9 downto 2 ) + 1 if input(1 downto 0) > "10" ..... --! rounding todo: handle if input is signed
 

easiest rounding method is to truncate to LSB -1, then add 1, then truncate the LSB.

So for 10 bits down to 8 bits:

Truncate to 9 bits
+1
truncate to 8 bits

Then you have a rounded result.

Remember, that with every truncate, you will have an error of +- 0.5. If you chain several truncations, especially if the following calculation is a multiply, you compound the errors.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top