#!/bin/sh # # This shell script processes GHDL simulation report output # and converts time stamps to microseconds in a more convenient # format. # # Example usage: # # $ ./test_bench --stop-time=100ms 2>&1 | ./filter # awk -F ':' ' function time_conv(s) { match(s, "^@([0-9]+)([a-zA-Z]+)$", a); units = a[2]; value = a[1]; if (units == "us") div = "1"; else if (units == "ns") div = "1000"; else if (units == "ps") div = "1000000"; else if (units == "ms") div = "0.001"; else div = "0"; cmd = sprintf("echo \"scale=3;%s/%s\" | bc 2>/dev/null", value, div); cmd | getline var; close(cmd); return var; } { printf("%-64s %s us\n", $6, time_conv($4)); } '