-
Notifications
You must be signed in to change notification settings - Fork 64
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
base: master
Are you sure you want to change the base?
Conversation
FYI - @tcal-x |
class FomuROT13Out(Module, AutoCSR): | ||
def __init__(self, rot13_in): | ||
self.csr = CSRStorage(8) | ||
self.sync += If( # A-M, a-m |
There was a problem hiding this comment.
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 :-)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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! |
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.