# 
# Copyright 2013 Jeff Bush
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 

# Unpack signals dumped by the debug_trace.v module
import sys, csv

FIELDS = [ 3, 1, 1, 3, 1, 1, 10, 512, 4 ]
BYTES_PER_TRACE = (sum(FIELDS) + 7) / 8

traceVals = []
hexstr = ''
for line in sys.stdin.readlines():
	hexstr = line[:2] + hexstr
	if len(hexstr) == BYTES_PER_TRACE * 2:
		intval = int(hexstr, 16)
		event = []
		for width in reversed(FIELDS):
			fieldVal = intval & ((1 << width) - 1)
			intval >>= width
			event = [ fieldVal ] + event
		
		traceVals += [ event ]
		hexstr = ''

print hexstr

REQUEST_TYPES = [
	'L2REQ_LOAD',	
	'L2REQ_STORE',	
	'L2REQ_FLUSH',
	'L2REQ_DINVALIDATE',	
	'L2REQ_LOAD_SYNC',	
	'L2REQ_STORE_SYNC',	
	'L2REQ_IINVALIDATE'
]

RESPONSE_TYPES = [
	'L2RSP_LOAD_ACK',
	'L2RSP_STORE_ACK',	
	'L2RSP_DINVALIDATE',	
	'L2RSP_IINVALIDATE'
]

print 'valid,strand,op,success,update_enable,is_l2_fill,cache_write_index,update_data'
for values in traceVals:
	preamble, l2req_valid, is_l2_fill, l2req_op, cache_hit, update_enable, \
		cache_write_index, updatedata, postamble = values

	if preamble != 2 or postamble != 2:
		print 'bad trace entry', preamble, postamble
	else:
		csvLine = str(l2req_valid) + ',' + str(is_l2_fill) + ',' + REQUEST_TYPES[l2req_op] \
			+ ',' + str(cache_hit) + ',' + str(update_enable) + ',' \
			+ str(cache_write_index) + ',' + hex(update_data)

		print csvLine

@@ -1072,22 +1072,8 @@
 ''%0A%0A
-print hexstr%0A%0A
 REQU
@@ -1335,63 +1335,251 @@
 %0A%5D%0A%0A
-print 'valid,strand,op,success,update_enable,is_l2_fill
+# 3'b010,%0A# rd_l2req_valid,%09// 1%0A# rd_is_l2_fill,%09// 1%0A# rd_l2req_op,%09// 3%0A# rd_cache_hit,%09// 1%0A# wr_update_enable,%09// 1%0A# wr_cache_write_index, // 10%0A# wr_update_data, // 512%0A# 4'b0010%0A%0Aprint 'valid,is_l2_fill,l2req_op,cache_hit,update_enable
 ,cac
@@ -1593,23 +1593,16 @@
 e_index,
-update_
 data'%0Afo
@@ -1698,16 +1698,16 @@
 able, %5C%0A
-
 %09%09cache_
@@ -1725,16 +1725,17 @@
 , update
+_
 data, po

Update decoder tool