Reading the Value/Offset of an IFD Entry

Reading the Value/Offset of an IFD Entry

classicClassiclistListthreadedThreaded
3 messages  Options  Options 
Reply |  Threaded |  More    

Reading the Value/Offset of an IFD Entry

Tillerson, Clint
4 posts

When reading the value/offset attribute for an IFD entry (Tiff tag), Im confused about how you to know whether the offset should be read as a short integer vs. a long integer.  Does that make sense?  In other words, when the actual value of the tag will not fit into 4 bytes, then the number represents the offset (in bytes) to where the value or values are stored.

If I understand correctly (and perhaps I do not), the offset will always be either a 2-byte or 4-byte integer.  Is that true.   However, I have no way of knowing whether to read only the first 2 bytes to get the offset or read all 4 bytes.  The field type attribute tells you the data type of the tag value, not the data type of offset value.

Heres some background:  Im writing a Fortran program that extracts land cover data from GEOTIFF files.  Depending on the source of the GEOTIFF file, it could be either big endian or little endian thus, I cannot use a compiler switch to deal with the byte swapping and must handle byte swapping in my Fortran code when necessary.    The problem Im running into is reading the offset value and swapping bytes appropriately.  If the offset value fits into two bytes, Ive discovered that I must read only the first two bytes and ignore the second two, else Im including bytes that arent part of the offset value.  There does not seem to be a way to determine whether the offset is stored in only the first two bytes or all four.

Thanks!

Clint


_______________________________________________ 
Geotiff mailing list 
[hidden email] 
http://lists.maptools.org/mailman/listinfo/geotiff
Reply |  Threaded |  More    

Re: Reading the Value/Offset of an IFD Entry

Niles Ritter
6 posts

On Fri, 2007-10-26 at 10:10 -0400, Tillerson, Clint wrote: 
> When reading the value/offset attribute for an IFD entry (Tiff tag), 
> I’m confused about how you to know whether the offset should be read 
> as a short integer vs. a long integer. 

TIFF is based from the ground-up on offsets to data, which can be 
anywhere in the file. Since TIFF files can be up to 4GB in size, 
all offsets stored in TIFF are always LONG (4-byte unsigned integers 
in the byte-order specified by the TIFF header). 

http://partners.adobe.com/public/developer/tiff/index.html

> Here’s some background:  I’m writing a Fortran program that extracts 
> land cover data from GEOTIFF files. 

Ah, youth and high spirits. FORTRAN! It makes me nostalgic. 

I wrote a FORTRAN TIFF parser back in the 80's, when I worked at 
NASA/JPL's image-processing center (MIPL). Believe me, you don't 
want to write a FORTRAN TIFF: that path is clouded by the Dark Side, 
and will only lead you to suffering, and countless hours of 
debugging (FORTRAN!). It's a good CS homework assignment, but not 
a good investment of your (or your company's) developer time. 

Do what I eventually did, abandon the FORTRAN TIFF project and 
just use the (C-based)  "libtiff" library. It's as gold-plated 
as you can get. All Fortran compilers in this millennium 
support calls to C functions.  Reference: 

http://www-mipl.jpl.nasa.gov/vicar/vicar250/html/vichelp/vtiff.html

Count your blessings; at least you weren't asked to write it in ADA ! 

--Niles. 


_______________________________________________ 
Geotiff mailing list 
[hidden email] 
http://lists.maptools.org/mailman/listinfo/geotiff
Reply |  Threaded |  More    

Re: Reading the Value/Offset of an IFD Entry

noelkhan
8 posts
In reply to  this post by Tillerson, Clint
Quote "...how you to know whether the offset should be read as a 
short integer vs. a long integer...."


All pointers are 4-byte LONG values; regardless of whether the pointer is pointing to the next IFD or pointing to some tag's value. 

Quote "...when the actual value of the tag will not fit into 4 bytes, then 
the number represents the offset (in bytes) to where the value or values 
are stored...."


Correct, the "Value" is actually a pointer if the size of the value is > 4 bytes. Note that this pointer is base-0 and from the beginning of the tiff file, not from the current file position. 

Quote "...the offset will always be either a 2-byte or 4-byte integer.  Is that true...."
  
Negative. The offset/pointer will  always be a LONG (4-bytes). 

Quote "...The field type attribute tells you the data type of the tag value, not the data type of offset value...."

See page 15 of the TIFF6 spec for a listing of data types and their sizes in terms of bytes (hereinafter, "ByteSize"). Once you've read the field Type and Count (a.k.a., "N"), the size of the tag's "Value" is calculated as: ByteSize*N. 

If (ByteSize*N) > 4 bytes, then the "Value" is in fact a pointer to a value. 

If (ByteSize*N) <= 4, then parse N number of DataTypes. Again, the number of bytes per data type is known.   

Quote "I'm writing a Fortran program .... must handle byte swapping in my Fortran code when necessary."

:)   I'm writing a program in VB6 that reads TIFF/GeoTIFF headers. To handle byte order I: [1] utilize a function ReadNBytes(N) that reads N number of bytes into a byte array. [2] That byte array is then passed by reference to a function ByteArrayToNumber. It is here that I handle byte order: for MM, I iterate through the bytes from 1...N; and for II from N...1. [3] Each iteration, I pass each byte to a function named ByteToBitPattern, which converts the byte into a string representation of bits. [4] Finally, I pass my bit-string to a function BitPatternToValue that converts the bit-string to a numerical value. 

It may seem round-about, but it's the only way (I thought of) to create a generic function that can read and return numerical values of any byte size and in either order (MM/II) using Visual Basic 6. 

So much fun. 

However, I've been tearing my forlock out trying to figure out how Model coordinates are encoded into the GeoTiff tags. If you've figured that out, please share how. 

Cheers, 
Noel
<think>我们正在处理一个关于Xilinx FPGA设计中I/O约束的问题,具体涉及IBUF的延迟值设置。 用户问题:Pack 1748 I/O component input buffer PCI_CORE/XPCI_DEVSEL/IBUF IFD_DELAY_VALUE value 6 not driving register in IOB 分析: 1. 问题发生在布局布线阶段,提示信息表明:一个IBUF(输入缓冲器)的IFD_DELAY_VALUE属性设置为6,但该IBUF没有驱动位于IOB(Input/Output Block)中的寄存器。 2. IOB是FPGA芯片上靠近I/O引脚的资源块,通常包含输入/输出寄存器,用于实现高速接口的时序要求(如减少输入延迟)。 3. IFD_DELAY_VALUE是IBUF的一个属性,用于设置输入延迟。这个属性通常与IDELAY元件相关,用于调整输入数据的延迟,以满足建立和保持时间要求。 4. 当输入信号直接驱动位于IOB内部的寄存器时,设置IFD_DELAY_VALUE可以优化输入路径的时序。但是,如果该IBUF驱动的寄存器不在IOB中(而是在内部逻辑中),那么设置IFD_DELAY_VALUE可能无效,甚至导致实现工具(如Vivado)报出警告或错误。 可能的原因: - 设计者希望将输入寄存器放在IOB中以获得最佳性能,但由于某些原因(如逻辑资源分配、约束不完整等),该寄存器没有被实现工具放入IOB。 - IFD_DELAY_VALUE属性设置不正确,或者该属性在非IOB寄存器的情况下不被支持。 解决方案: 1. 确保目标寄存器被正确地约束在IOB中。在Xilinx FPGA中,可以通过以下约束来指定寄存器放置在IOB中: - 对于Vivado:使用`IOB`属性约束,例如: set_property IOB TRUE [get_cells <寄存器实例名>] 或者使用XDC约束: set_instance_assignment -name IOBDELAY_LOCATION IOB -to <寄存器实例名> 注意:具体约束语法可能因工具版本而异。 2. 检查输入路径的时序约束是否完整,特别是输入延迟(input delay)约束。如果输入信号有外部延迟,需要设置输入延迟约束,例如: set_input_delay -clock <时钟名> -max <最大延迟> [get_ports <端口名>] set_input_delay -clock <时钟名> -min <最小延迟> [get_ports <端口名>] 3. 如果该输入信号不需要使用IDELAY(即可变延迟元件),则不需要设置IFD_DELAY_VALUE属性。可以尝试移除该属性设置,看问题是否解决。 4. 如果确实需要使用IDELAY,确保设计中的IBUF与IDELAY元件正确连接,并且IDELAY的输出驱动了寄存器。同时,确保IDELAY元件被正确约束(例如位置约束)。 5. 如果寄存器无法放入IOB(例如因为IOB资源已被占用),则可能需要重新考虑设计,或者调整布局策略。 6. 检查Vivado的日志文件,查看是否有其他相关警告或错误,这些信息可能有助于确定根本原因。 注意:在Xilinx FPGA中,为了使用IFD_DELAY_VALUE,通常要求IBUF驱动一个位于同一IOB中的寄存器(即输入寄存器)。如果该寄存器不在IOB中,则IFD_DELAY_VALUE可能无法应用。 因此,关键步骤是确保寄存器被放置在IOB中,或者移除不必要的IFD_DELAY_VALUE属性设置。 相关问题: 1. 如何将寄存器约束到IOB中? 2. 在Xilinx FPGA中,IBUF和IDELAY元件的作用是什么? 3. 如何设置输入延迟约束? 4. 如何解决FPGA实现中的布局布线错误?</think>### 关于Xilinx FPGA I/O约束问题的分析 您的问题涉及FPGA设计中I/O缓冲器(IBUF)的延迟值设置问题,具体错误提示为:`Pack 1748 I/O component input buffer PCI_CORE/XPCI_DEVSEL/IBUF IFD_DELAY_VALUE value 6 not driving register in IOB`。这通常发生在布局布线阶段,表明工具无法实现您指定的I/O约束要求。 #### 核心问题分析 1. **IFD_DELAY_VALUE作用** `IFD_DELAY_VALUE`是IBUF原语的属性,用于设置输入延迟链的抽头值(范围0-63)。当您设置`IFD_DELAY_VALUE=6`时,表示要求: - 输入信号必须通过可编程延迟单元(IDELAY) - 延迟单元输出必须直接驱动**位于IOB内的寄存器**(即输入寄存器) 2. **错误原因** 工具报错表明: - 指定的延迟值(6)已被接受 - 但目标寄存器`PCI_CORE/XPCI_DEVSEL`**未放置在IOB内部** - 可能原因包括: * 寄存器被综合到通用逻辑区域(SLICES) * 物理约束冲突(如LOC约束冲突) * 时序约束不完整导致工具无法优化 #### 解决方案步骤 1. **检查寄存器位置约束** 在XDC约束文件中添加: ```tcl set_property IOB TRUE [get_cells PCI_CORE/XPCI_DEVSEL] ``` 强制工具将寄存器放入IOB。验证实现日志是否显示: ```log INFO: [Place 30-574] ... Placed component PCI_CORE/XPCI_DEVSEL in IOB ``` 2. **确认时钟约束完整性** 确保相关时钟已正确定义: ```tcl create_clock -name clk_pci -period 10 [get_ports PCI_CLK] set_input_delay -clock clk_pci -max 2.5 [get_ports PCI_DEVSEL] ``` 3. **检查资源利用率** 运行`report_utilization -io`,确认目标Bank有足够IOB资源: ``` +-----------------+------+-------+--------+-------+ | Site Type | Used | Fixed | Prohib | Avail | +-----------------+------+-------+--------+-------+ | IOB | 32 | 0 | 0 | 64 | | IDELAYCTRL | 1 | 0 | 0 | 2 | +-----------------+------+-------+--------+-------+ ``` 4. **替代方案(若仍失败)** - 方案1:手动实例化IDELAYE2原语 ```verilog IDELAYE2 #( .IDELAY_VALUE(6), .DELAY_SRC("IDATAIN") ) u_delay ( .DATAOUT(delayed_signal), .DATAIN(raw_signal), ... ); ``` - 方案2:使用`IBUF_DELAY_VALUE`通用属性替代专用约束 #### 关键原理说明 在Xilinx 7系列及以上FPGA中: - IOB内部寄存器支持**零保持时间**特性[^1] - 输入延迟链(IDELAY)必须与IOB寄存器物理相邻 - 当`IFD_DELAY_VALUE>0`时,工具自动推断IDELAYCTRL模块[^2] - 时钟频率>250MHz时建议使用IODELAY分组约束 > 提示:使用`report_io_registers -file io_report.txt`可验证寄存器是否成功放入IOB。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值