Skip to content

Commit

Permalink
buck50.py 0.9.6, vcd2txt.py
Browse files Browse the repository at this point in the history
  • Loading branch information
thanks4opensource committed Feb 13, 2021
1 parent 5228546 commit e77172a
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 5 deletions.
8 changes: 8 additions & 0 deletions RELEASE_NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
0.9.2 buck50.{cxx,elf} 0.9.6 buck50.py 2021 Feb 12 Fri
-----------------------------------------------------------
* Fixed small buck50.py bugs: Missing initialization in upload_digital()
if no samples, typo in `help trigger trigger`, removed extra "#!" line.
* Added simple vcd2txt.py utility.



0.9.2 buck50.{cxx,elf} 0.9.5 buck50.py 2021 Jan 12 Tue
-----------------------------------------------------------
* Fixed buck50.py bugs in `dump` command with "auto-digital=disabled",
Expand Down
10 changes: 5 additions & 5 deletions build/buck50.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

# buck50: Test and measurement firmware for “Blue Pill” STM32F103 development board
# Copyright (C) 2019,2020 Mark R. Rubin aka "thanks4opensource"
# Copyright (C) 2019, 2020, 2021 Mark R. Rubin aka "thanks4opensource"
#
# This file is part of buck50.
#
Expand All @@ -20,7 +20,6 @@
# <https:#www.gnu.org/licenses/gpl.html>


#!/usr/bin/env python3

import argparse
import collections
Expand Down Expand Up @@ -49,7 +48,7 @@
#
#

VERSION = (0, 9, 5)
VERSION = (0, 9, 6)

COPYRIGHT = '''%s %d.%d.%d
Copyright 2020 Mark R. Rubin aka "thanks4opensource"''' \
Expand Down Expand Up @@ -4119,7 +4118,8 @@ def upload_digital(samples ,

if file:
if save_as == DigitalFormat.VCD:
chng = bits ^ last
timval = 0
chng = bits ^ last
if chng:
timval = tcks * upload_config['tick-units'].val \
/ (CPU_HZ * upload_config['per-tick' ].val)
Expand Down Expand Up @@ -5180,7 +5180,7 @@ def trig_cmd(cmd, input, fields):
% field)
if not deletes:
sys.stderr.write("Specify one or more triggers "
"to delete: [-m] [p[-q] ...\n" )
"to delete: n[-m] [p[-q] ...\n" )
return
for delete in deletes:
if delete == 0:
Expand Down
100 changes: 100 additions & 0 deletions build/vcd2txt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env python3

# buck50: Test and measurement firmware for “Blue Pill” STM32F103 development board
# Copyright (C) 2019, 2020, 2021 Mark R. Rubin aka "thanks4opensource"
#
# This file is part of buck50.
#
# The buck50 program is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# The buck50 program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# (LICENSE.txt) along with the buck50 program. If not, see
# <https:#www.gnu.org/licenses/gpl.html>



import argparse
import sys



def parse_commandline():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)


def units(text):
VALIDS = {'ns' : 1e9,
'us' : 1e6,
'ms' : 1e3,
's' : 1.0 ,
}
if not text in VALIDS:
raise argparse.ArgumentTypeError( "units must be one of {}"
.format(VALID_SCALES) )
return (text, VALIDS[text])

parser.add_argument('-u', '--units',
nargs='?',
type=units,
default='us')

parser.add_argument('infile',
nargs='?',
type=argparse.FileType('r'),
default=sys.stdin)

parser.add_argument('outfile',
nargs='?',
type=argparse.FileType('w'),
default=sys.stdout)

return parser.parse_args()



if __name__ != '__main__':
sys.exit(1)


UNITS = {'ns' : 1e-9,
'us' : 1e-6,
'ms' : 1e-3,
's' : 1.0 ,
}

args = parse_commandline()

traces = {}
tick = None
for line in args.infile:
if line.startswith('$timescale'):
fields = line.split()
tick = float(fields[1]) * UNITS[fields[2].lower()]

if line.startswith('$var'):
fields = line.split()
traces[fields[3]] = fields[4]

if line.startswith('$enddefinitions'):
break

if tick is None:
sys.stderr.write("No $timescale in input VCD file\n")
sys.exit(1)

for line in args.infile:
if line[0] == '#':
args.outfile.write( '%.3f %s\n'
% (int(line[1:]) * tick * args.units[1],
args.units[0]))
else:
args.outfile.write(" %s %s\n" % (line[0], traces[line[1]]))

0 comments on commit e77172a

Please sign in to comment.