Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a ROT13 workshop example #273

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add a ROT13 workshop example #273

wants to merge 4 commits into from

Conversation

mibus
Copy link
Contributor

@mibus mibus commented Jul 25, 2020

This is similar to the RGB litex/workshop example, but wires two CSRs together for a slightly more complicated example.

Poke a byte value into the "input" CSR via wishbone-tool, and retrieve the ROT13-encoded output byte from the "output" CSR.

@mithro
Copy link
Member

mithro commented Jul 25, 2020

FYI - @tcal-x

class FomuROT13Out(Module, AutoCSR):
def __init__(self, rot13_in):
self.csr = CSRStorage(8)
self.sync += If( # A-M, a-m
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could do with some more explanation :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments in 5a3c933, let me know if that's what you're looking for.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap starting to look good! I do think you might want a comment which says "we only rotate the alphabetic characters" (what about the numbers? :-) and maybe a link to the ROT13 wikipedia page?

Could be good to add a test bench in the future too....

From https://en.wikipedia.org/wiki/ROT13 it looks like memfrob() in the GNU C library could be an excellent target for this type of acceleration :-P

The GNU C library, a set of standard routines available for use in computer programming, contains a function—memfrob()[15]—which has a similar purpose to ROT13, although it is intended for use with arbitrary binary data. The function operates by combining each byte with the binary pattern 00101010 (42) using the exclusive or (XOR) operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linked the wiki page, added a brief explanation of the overall cipher, mentioned that it's limited to the English alphabet.

@mithro
Copy link
Member

mithro commented Jul 25, 2020

Next step is to do that with a FIFO on each end :-)

@mibus
Copy link
Contributor Author

mibus commented Jul 25, 2020

Next step is to do that with a FIFO on each end :-)

If you think I should, I'm happy to explore that and submit a PR for that instead. This was just me exploring wiring up signals, and (so far) CSRs are all I've learned!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants