为什么在16位计算机上使用20个地址空间可以访问1 MB而不是2 MB? [英] Why does 20 address space with on a 16 bit machine give access to 1 Megabyte and not 2 Megabytes?

查看:130
本文介绍了为什么在16位计算机上使用20个地址空间可以访问1 MB而不是2 MB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这个问题听起来很简单,但是我很惊讶.在古老的1 MB内存巨大的日子里,Intel试图找出如何使用16位来访问1 MB内存的方法.他们提出了使用段和偏移地址值生成20位地址的想法.

OK, this question sounds simple but I am taken by surprise. In the ancient days when 1 Megabyte was a huge amount of memory, Intel was trying to figure out how to use 16 bits to access 1 Megabyte of memory. They came up with the idea of using segment and offset address values to generate a 20 bit address.

现在,20位给出2 ^ 20 = 1,048,576个可以寻址的位置.现在假设我们在每个地址位置访问1个字节,我们得到1,048,576/(1024 * 1024)= 2 ^ 20/2 ^ 20兆字节= 1兆字节.好的,可以理解.

Now, 20 bits gives 2^20 = 1,048,576 locations that can be addressed. Now assuming that we access 1 byte per address location we get 1,048,576/(1024*1024) = 2^20/2^20 Megabytes = 1 Megabyte. Ok understood.

混乱到了,在古老的8086中我们拥有16位数据总线,并且一次只能访问2个字节而不是1个字节,这等于20位地址可以访问总共2 MB的数据,对吗?当数据总线为2字节宽时,为什么我们假定每个地址中只存储1个字节?我在这里很困惑.

The confusion comes here, we have 16 bit data bus in the ancient 8086 and can access 2 bytes at a time rather than 1, this equate 20 bit address to being able to access a total of 2 Megabyte of data right? Why do we assume that each address only has 1 byte stored in it when the data bus is 2 bytes wide? I am confused here.

推荐答案

在尝试理解总线时考虑总线是非常重要的.这可能比软件问题更像是一个电子问题,但这是答案:

It is very important to consider the bus when trying to understand this. This is probably more of an electrical question than a software one, but here is the answer:

对于8086,当从ROM读取时,不使用最低有效地址线(A0),从而立即将地址线的数量减少到19.

For 8086, when reading from ROM, The least significant address line (A0) is not used, reducing the number of address lines to 19 right then and there.

在CPU需要从奇数地址读取16位(例如0x3和0x4的字节)的情况下,它将实际上执行两次16位读取:一次从0x2读取,一次从0x4读取,并丢弃字节0x2和0x5.

In the case where the CPU needs to read 16 bits from an odd address, say, bytes at 0x3 and 0x4, it will actually do two 16-bit reads: One from 0x2 and one from 0x4, and discard bytes 0x2 and 0x5.

对于8位ROM读取,总线上的读取仍然是16位,但是不需要的字节将被丢弃.

For 8-bit ROM reads, the read on the bus is still 16-bits but the unneeded byte is discarded.

但是对于RAM,有时只需要写入一个字节,这会变得更加复杂.处理器上还有一个额外的输出信号,称为BHE#(总线高电平使能). A0和BHE#的组合用于确定写入是8位还是16位宽,以及写入的地址是奇数还是偶数.

But for RAM there is sometimes a need to write just a single byte, this gets a little more complex. There is an extra output signal on the processor called BHE# (Bus high enable). The combination of A0 and BHE# are used to determine if the write is an 8 or 16-bits wide, and whether or not it is at an odd or even address.

理解这两个信号是回答您的问题的关键.尽可能简单地说明:

Understanding these two signals is key to answering your question. Stating it simply as possible:

8位偶数访问:A0 OFF,BHE#OFF

8-bit even access: A0 OFF, BHE# OFF

8位奇数访问:A0开启,BHE#开启

8-bit odd access: A0 ON, BHE# ON

16位访问(必须为偶数):A0关闭,BHE#打开

16-bit access (must be even): A0 OFF, BHE# ON

并且我们不能通过A0 ON和BHE#OFF来进行总线循环,因为对总线的偶数字节进行奇数访问是没有意义的.

And we cannot have a bus cycle with A0 ON and BHE# OFF because an odd access to the even byte of the bus is meaningless.

这与您的原始理解有关:对于存储设备,您是完全正确的.一个1兆字节的16位内存芯片实际上只有19条地址线,对于该芯片,16位是一个字节,实际上,它们实际上没有A0地址输入.

Relating this back to your original understanding: You are completely correct in the case of memory devices. A 1 megabyte 16-bit memory chip will indeed only have 19 address lines, to that chip, 16 bits is a byte, and in effect, they do not physically have an A0 address input.

...差不多. 16位可写存储设备有两个额外的信号(BHE#和BLE#),它们分别连接到CPU的BHE#和A0.这样,他们知道在进行8位访问时会忽略总线的一部分,从而使它们成为8/16位混合设备. ROM芯片没有这些信号.

... almost. 16-bit writable memory devices have two extra signals (BHE# and BLE#) which are connected to the CPU's BHE# and A0 respectively. This so they know to ignore part of the bus when an 8-bit access is under way, making them hybrid 8/16 bit devices. ROM chips do not have these signals.

对于没有启发性的硬件,这是我们要涉及的相当复杂的领域,并且在性能方面以及在具有8位和16位硬件混合的大型系统中,它确实的确变得非常复杂.

For the hardware unenlightened, this is a fairly complex area we're touching on here, and it does get very complex indeed in terms of performance considerations and in large systems with mixed 8 and 16 bit hardware.

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆