1
\$\begingroup\$

I have copied the following sentence from a PIC MCU datasheet:

"PIC18(L)F26K22, PIC18(L)F46K22: 64 Kbytes of Flash Memory, up to 37,768 single-word instructions."

the question is what does " 37,768 single-word instructions" mean for a memory ?

does it show how fast is the memory or something else ? what's its meaning and how is it calculated ?

\$\endgroup\$
  • 4
    \$\begingroup\$ First of all, it's 32,768 words, and it's a measure of the memory size, not speed. \$\endgroup\$ – Dave Tweed Jan 7 at 2:56
  • \$\begingroup\$ By the way, according to international standard the size of the Flash would correctly be described as 64 kibibytes or 64 KiB. The prefix kibi means 2^10 while kilo means 10^3. \$\endgroup\$ – Elliot Alderson Jan 7 at 2:59
  • 1
    \$\begingroup\$ I guess it's this datasheet: microchip.com/stellent/groups/picmicro_sg/documents/devicedoc/… It does actually contain the 37768 figure (page 64, section 5.1), so technically the quote here is correct. It's obviously a typo, though, there's the correct number in table 1 on page 2. \$\endgroup\$ – ilkkachu Jan 7 at 6:23
6
\$\begingroup\$

First, your question contains a typo, you mean 32,768 (2^15) not 37,768.

The PIC in question has a 16-bit instruction word.

The flash memory size is specified as 64K (65536) bytes. With two bytes per word, that is space for 32768 simple instructions.

Many processors, apparently including this one, offer instructions of varying length - more complex instructions may include things like immediate operands or memory addresses. These take more bits to encode, and so are longer than the "single-word" instructions.

The data sheet is thus giving you a best case. Depending on the compiler or hand coding strategy, actual code might have varying average instruction length, so it is harder to say how many typical instructions could fit in flash. Even if it's possible to write a program using all single-word instructions, on a machine designed to support them it may well be more efficient to use some multi-word ones, especially if that avoids needing to go do another fetch of a constant from data memory.

\$\endgroup\$
  • \$\begingroup\$ Did you mean "immediate operands"? \$\endgroup\$ – chrylis Jan 7 at 5:53
0
\$\begingroup\$

I expect that it should be 32,768 single-word instructions. If a "word" is two bytes and the memory has 65,536 bytes then the memory can hold 32,768 such words. It doesn't have anything to do with the speed of the memory.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.