File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 31
31
# ROT13 input CSR. Doesn't need to do anything special.
32
32
class FomuROT13In (Module , AutoCSR ):
33
33
def __init__ (self ):
34
+ # 8-Bit CSR (one ASCII character)
34
35
self .csr = CSRStorage (8 )
35
36
36
37
# ROT13 output CSR, plus the wiring to automatically create the output from the input CSR.
37
38
class FomuROT13Out (Module , AutoCSR ):
38
39
def __init__ (self , rot13_in ):
40
+ # Set up an 8-bit CSR (one ASCII character)
39
41
self .csr = CSRStorage (8 )
42
+ # There are three cases:
43
+ # 1. It's "A" through "M": Add 13, to make the letters "N" through "Z".
44
+ # 2. It's "N" through "Z": Remove 13, to make the letters "A" through "M".
45
+ # 3. It's something else, so leave it alone.
46
+ #
47
+ # In all three cases, we want to wire up the "output" signal (self.csr.storage)
48
+ # to be equal to something based on the input signal (rot13_in.csr.storage).
40
49
self .sync += If ( # A-M, a-m
41
50
(rot13_in .csr .storage >= ord ('A' )) & (rot13_in .csr .storage <= ord ('M' )) | (rot13_in .csr .storage >= ord ('a' )) & (rot13_in .csr .storage <= ord ('m' )),
42
51
self .csr .storage .eq (rot13_in .csr .storage + 13 )
You can’t perform that action at this time.
0 commit comments