Add TRST support to xsvf tools. Courtesy of Dick Hollenbeck <dick@softplc.com>
[openocd.git] / tools / xsvf_tools / svf2xsvf.py
index 20080db3049e1c04efd1d779e1ec38f32752ecc5..bf2a12099f42dda152c1a24ca8cee419201ca63d 100644 (file)
@@ -57,6 +57,11 @@ outputFilename = sys.argv[2]
 doCOMMENTs = True       # Save XCOMMENTs in the output xsvf file
 #doCOMMENTs = False       # Save XCOMMENTs in the output xsvf file
 
+# pick your file encoding
+file_encoding = 'ISO-8859-1'
+#file_encoding = 'utf-8'
+
+
 xrepeat = 0             # argument to XREPEAT, gives retry count for masked compares
 
 
@@ -74,7 +79,8 @@ StateTxt = ("RESET","IDLE",
 
 (XCOMPLETE,XTDOMASK,XSIR,XSDR,XRUNTEST,hole0,hole1,XREPEAT,XSDRSIZE,XSDRTDO,
     XSETSDRMASKS,XSDRINC,XSDRB,XSDRC,XSDRE,XSDRTDOB,XSDRTDOC,
-    XSDRTDOE,XSTATE,XENDIR,XENDDR,XSIR2,XCOMMENT,XWAIT,XWAITSTATE,LCOUNT,LDELAY,LSDR) = range(28)
+    XSDRTDOE,XSTATE,XENDIR,XENDDR,XSIR2,XCOMMENT,XWAIT,XWAITSTATE,
+    LCOUNT,LDELAY,LSDR,XTRST) = range(29)
 
 #Note: LCOUNT, LDELAY, and LSDR are Lattice extensions to SVF and provide a way to loop back
 # and check a completion status, essentially waiting on a part until it signals that it is done.
@@ -90,6 +96,8 @@ LSDR  1 TDI  (0)
         TDO  (1);
 """
 
+#XTRST is an opcode Xilinx seemed to have missed and it comes from the SVF TRST statement.
+
 LineNumber = 1
 
 def s_ident(scanner, token): return ("ident", token.upper(), LineNumber)
@@ -127,8 +135,13 @@ scanner = re.Scanner([
     re.MULTILINE
     )
 
+# open the file using the given encoding
+file = open( sys.argv[1], encoding=file_encoding )
+
 # read all svf file input into string "input"
-input = open( sys.argv[1] ).read()
+input = file.read()
+
+file.close()
 
 # Lexer:
 # create a list of tuples containing (tokenType, tokenValue, LineNumber)
@@ -368,6 +381,8 @@ run_state_allowed = ('IRPAUSE', 'DRPAUSE', 'RESET', 'IDLE')
 enddr_state_allowed = ('DRPAUSE', 'IDLE')
 endir_state_allowed = ('IRPAUSE', 'IDLE')
 
+trst_mode_allowed = ('ON', 'OFF', 'Z', 'ABSENT')
+
 enddr_state = IDLE
 endir_state = IDLE
 
@@ -681,6 +696,19 @@ try:
                 if tokVal != ';':
                     raise ParseError( tokLn, tokVal, "Expecting ';' after FREQUENCY cycles HZ")
 
+        elif tokVal == 'TRST':
+            nextTok()
+            if tokVal not in trst_mode_allowed:
+                raise ParseError( tokLn, tokVal, "Expecting 'ON|OFF|Z|ABSENT' after TRST")
+            trst_mode = tokVal
+            nextTok()
+            if tokVal != ';':
+                raise ParseError( tokLn, tokVal, "Expecting ';' after TRST trst_mode")
+            obuf = bytearray( 2 )
+            obuf[0] = XTRST
+            obuf[1] = trst_mode_allowed.index( trst_mode )  # use the index as the binary argument to XTRST opcode
+            output.write( obuf )
+
         else:
             raise ParseError( tokLn, tokVal, "Unknown token '%s'" % tokVal)
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)