Skip to content

Commit

Permalink
grok.py changes
Browse files Browse the repository at this point in the history
  • Loading branch information
keirf committed May 30, 2024
1 parent ee5a162 commit 2494009
Showing 1 changed file with 35 additions and 19 deletions.
54 changes: 35 additions & 19 deletions grok.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,42 @@
CELL=4*MHZ
THRESH=2*CELL-MHZ//2

b = bitarray()
count, prev, run = 0, 128, 0
class Bits:
def __init__(self):
self.b = bitarray()
self.prev, self.run = 128, 0
def process(self,line):
for i in range(6, len(line)-1, 3):
x = int(line[i:i+2], 16)
for j in range(8):
level = x & 128
if level != self.prev:
self.prev = level
if level == 0:
while self.run > THRESH:
self.b.append(False)
self.run -= CELL
self.b.append(True)
self.run = 0
self.run += 1
x <<= 1

wdata = Bits()
rdata = Bits()
wreq = Bits()
count = 0
for line in f:
if count == 1000:
if count == 100000:
break
if not line.startswith('RDATA'):
if line.startswith('WDATA'):
wdata.process(line)
elif line.startswith('RDATA'):
rdata.process(line)
elif line.startswith('/WREQ'):
wreq.process(line)
else:
continue
count += 1
for i in range(6, len(line)-1, 3):
x = int(line[i:i+2], 16)
for j in range(8):
level = x & 128
if level != prev:
prev = level
if level == 0:
while run > THRESH:
b.append(False)
run -= CELL
b.append(True)
run = 0
run += 1
x <<= 1
print(b)
print(wdata.b)
print(rdata.b)
print(wreq.b)

0 comments on commit 2494009

Please sign in to comment.