fix program 3 to have correct error detection,
added duplicate label syntax error check in assembler
This commit is contained in:
parent
9254063e3e
commit
dd4f8ef9f8
@ -126,7 +126,7 @@ module program3_tb () ;
|
|||||||
dut.DM.core[m+64] = msg_crypto1[m];
|
dut.DM.core[m+64] = msg_crypto1[m];
|
||||||
for(int n=24; n<64; n++) begin // load subsequent, possibly corrupt, encrypted message into data memory
|
for(int n=24; n<64; n++) begin // load subsequent, possibly corrupt, encrypted message into data memory
|
||||||
// set flipper = 8 or higher to disable bit corruption
|
// set flipper = 8 or higher to disable bit corruption
|
||||||
flipper = 8;//$random; // value between 0 and 63, inclusive
|
flipper = $random;//$random; // value between 0 and 63, inclusive
|
||||||
dut.DM.core[n+64] = msg_crypto1[n]^(1<<flipper);
|
dut.DM.core[n+64] = msg_crypto1[n]^(1<<flipper);
|
||||||
if(flipper<8) flipped[n]=1;
|
if(flipper<8) flipped[n]=1;
|
||||||
end
|
end
|
||||||
|
@ -119,6 +119,9 @@ for file in targets:
|
|||||||
line = line.replace('\t', '') # remove leading tabs
|
line = line.replace('\t', '') # remove leading tabs
|
||||||
line = line.replace('\n', '') # remove trailing newline
|
line = line.replace('\n', '') # remove trailing newline
|
||||||
if ': ' in line:
|
if ': ' in line:
|
||||||
|
if line.split(': ')[0] in labels:
|
||||||
|
print('dublicate label "' + line.split(': ')[0] + '" detected')
|
||||||
|
exit(1)
|
||||||
labels[line.split(': ')[0]] = index # ': ' must be used to end a label
|
labels[line.split(': ')[0]] = index # ': ' must be used to end a label
|
||||||
no_comments.append(line.split(': ')[1])
|
no_comments.append(line.split(': ')[1])
|
||||||
else:
|
else:
|
||||||
|
@ -88,17 +88,35 @@ finish_preamble: LDI lfsr_routine
|
|||||||
LDI #d32 // get value of space
|
LDI #d32 // get value of space
|
||||||
SUB r1 // compare if r1 == 32
|
SUB r1 // compare if r1 == 32
|
||||||
JEZ r2 // jump to finish preamble loop if this plaintext == space(32)
|
JEZ r2 // jump to finish preamble loop if this plaintext == space(32)
|
||||||
CLB r1 // clear leading bit of plaintext
|
LDI correct_pre
|
||||||
GET r1 // get r1 to r0
|
PUT r2 // put correct handler address in r2
|
||||||
STW r12 // store plaintext
|
CHK r1 // check r1 for errors
|
||||||
NXT r12 // increment write only if we found the first non preamble char
|
JEZ r2
|
||||||
|
error_pre: LDI #x80
|
||||||
|
STW r12
|
||||||
|
LDI common
|
||||||
|
JMP r0
|
||||||
|
correct_pre: CLB r1
|
||||||
|
GET r1
|
||||||
|
STW r12
|
||||||
|
common_pre: NXT r12 // increment write only if we found the first non preamble char
|
||||||
main_loop: LDI lfsr_routine // load address for the lfsr_routine label
|
main_loop: LDI lfsr_routine // load address for the lfsr_routine label
|
||||||
JAL r0 // jump to the lfsr_routine label
|
JAL r0 // jump to the lfsr_routine label
|
||||||
LDW r11 // load the next ciphertext byte
|
LDW r11 // load the next ciphertext byte
|
||||||
XOR r7 // bitwise XOR the current state with ciphertext space to generate plaintext
|
PUT r1 // store ciphertext in r1
|
||||||
CLB r0 // clear the leading bit of the plaintext as in requirements
|
LDI correct
|
||||||
STW r12 // store plaintext to write pointer
|
PUT r2 // load address of correct handler in r2
|
||||||
NXT r11 // increment read pointer
|
CHK r1 // check r1(ciphertext) for errors
|
||||||
|
JEZ r2 // if there are no errors, jump to correct handler, otherwise continue to error handler
|
||||||
|
error: LDI #x80
|
||||||
|
STW r12
|
||||||
|
LDI common
|
||||||
|
JMP r0
|
||||||
|
correct: GET r1 // retrieve ciphertext from r1
|
||||||
|
XOR r7 // bitwise XOR the current state with ciphertext space to generate plaintext
|
||||||
|
CLB r0 // clear the leading bit of the plaintext as in requirements
|
||||||
|
STW r12 // store plaintext to write pointer
|
||||||
|
common: NXT r11 // increment read pointer
|
||||||
NXT r12 // increment write pointer
|
NXT r12 // increment write pointer
|
||||||
LDI finish_post // load address of label done
|
LDI finish_post // load address of label done
|
||||||
NXT r9 // decrement number of remaining plaintext chars
|
NXT r9 // decrement number of remaining plaintext chars
|
||||||
|
Reference in New Issue
Block a user