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.

ASM03 - How Fast the Bits of a Periodic Stream Could Be Outputted, AVR8 Code?

KerimF

Advanced Member level 5
Joined
May 17, 2011
Messages
1,556
Helped
376
Reputation
760
Reaction score
379
Trophy points
1,373
Location
Aleppo city - Syria
Activity points
13,106
Let us assume that an even number (N) of bits is saved on a table of size (L) bytes, where:.
L = int(N/8) + (mod(N,8)<>0)
Examples:
If N=200 bits, L=25 bytes
If N=202 bits, L=26 bytes
If N=204 bits, L=26 bytes
If N=206 bits, L=26 bytes
If N=208 bits, L=26 bytes
If N=210 bits, L=27 bytes
Etc...

The AVR8 code in question reads a bit from a bit stream table (saved in SRAM, for speed). Then it outputs this bit (0 or 1) to an output pin. When it reaches the Nth bit (the last bit in the table, not the last byte since N may not be a multiple of 8), it restarts from the first bit, for the next cycle.

I found that the minimum number of MCU cycles which is needed by the loop of this code is 4 cycles. This is the best speed I was able to achieve :(

Anyway, I have the impression that no one here had a good reason, in the past, to be interested in writing such special fast code. Therefore, for your curiosity in the least, I think I will have to post what I did on this thread, after about a week from now (The delay is for the case that my impression could be wrong :( ).

Cheers,
Kerim
 
Assuming that the code is reading the bits from SRAM one byte at a time, it would require at least 2 cycles to load the byte from SRAM (1 cycle for the LDD instruction and 1 cycle for the LD instruction). Additionally, it would require at least 2 cycles to extract the bit from the byte and output it to the output pin (1 cycle for the AND instruction and 1 cycle for the OUT instruction).

Therefore, the minimum number of MCU cycles needed for each iteration of the loop would be 4 cycles, as you have observed. It is possible that the code could be optimized further, but it would depend on the specific implementation of the code and the constraints of the system.
 
Assuming that the code is reading the bits from SRAM one byte at a time, it would require at least 2 cycles to load the byte from SRAM (1 cycle for the LDD instruction and 1 cycle for the LD instruction). Additionally, it would require at least 2 cycles to extract the bit from the byte and output it to the output pin (1 cycle for the AND instruction and 1 cycle for the OUT instruction).

Therefore, the minimum number of MCU cycles needed for each iteration of the loop would be 4 cycles, as you have observed. It is possible that the code could be optimized further, but it would depend on the specific implementation of the code and the constraints of the system.

Thank you. So far, you presented the easy side of the code which is surely better than giving nothing :).

Now, let us see how the loop can also detect the last bit of the stream (while we remember that N bits is even but not necessary a multiple of 8), and reload the byte that contains the first bit.

I bet even OpenAI cannot give a valid answer :D
But I can believe that you, having a human mind as mine (not artificial), may do it anytime when you really think about it very seriously. On my side, it took me many weeks to get its various tricks :(
 
I wish I could share your enthusiasm even for this odd challenge.

This is not a challenge because I realized since long that if I know something that someone else doesn't, he likely knows many things that I don't.
It is all about what someone really needs to know.
By design, the human intelligence is supposed to help humans, as individuals, complement each other by having each a real interest in one field or another, if not more than one, and at certain levels.
 
Hi,

I think it is time, as I promised, to present you the code of the AVR8 4-cycle loop which outputs bits serially of a periodic stream while they are read from a table [in SRAM].
Since the text of the code is 253 lines (including comments and blank lines), I attached it instead of posting it.

For instance, I don’t mind that openAI will also include it in its archive :)

Obviously, if someone will find out something not clear enough or perhaps a bug, please don’t hesitate to notify me and even discuss it.

Cheers,
Kerim
 

Attachments

  • AVR8 4-cyle loop.txt
    7.6 KB · Views: 68

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top