Compare commits

...

2 Commits

Author SHA1 Message Date
Eric Yu f27bb51086 parsedata.py 2024-02-14 12:13:19 -08:00
Eric Yu 3871bf7829 python 2024-01-18 10:26:30 -08:00
7 changed files with 449 additions and 1 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__

View File

@ -0,0 +1,119 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import re\n",
"import pandas as pd\n",
"import numpy as np\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"with open('/homes/hyu3/Documents/12024/525/ee477-designs-module0/clk_gen/build/sim-syn-rundir/run.log', 'r') as f:\n",
" text = f.read()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['1996' ':']\n"
]
}
],
"source": [
"splited = text.split('ps')\n",
"num = []\n",
"for element in splited:\n",
" num.append(element.split(')')[-1])\n",
"num1 = []\n",
"for element in num:\n",
" num1.append(element.split(' ')[1])\n",
"num1 = num1[1:-1]\n",
"print(np.array(num1))\n",
"# # Create an array with sample data\n",
"# data = np.array(num1).reshape(-1, 3)\n",
"\n",
"# new = data[:,0:2]\n",
"# # Convert the array to a DataFrame\n",
"# df = pd.DataFrame(data, columns=['pos', 'neg', 'Age'])\n",
"\n",
"# # Write the DataFrame to an Excel file\n",
"# df.to_excel('result.xlsx', index=False)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'new' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/tmp/ipykernel_32355/4269454735.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0msum\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mduty\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0melement\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mnew\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msum\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0melement\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0msum\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'new' is not defined"
]
}
],
"source": [
"sum = []\n",
"duty = []\n",
"for element in new:\n",
" result = sum(element)\n",
" sum.append(result)\n",
" duty.append(element[0]/result)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
},
"vscode": {
"interpreter": {
"hash": "697073d1a6d86fc2b43096c19ba8b1d0f2263c5609f8b095efe5b6511829db6d"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@ -0,0 +1,26 @@
import re
import pandas as pd
import numpy as np
with open('/homes/hyu3/Documents/12024/525/ee477-designs-module0/clk_gen/build/sim-syn-rundir/run.log', 'r') as f:
text = f.read()
splited = text.split('ps')
num = []
for element in splited:
num.append(element.split(')')[-1])
num1 = []
for element in num:
num1.append(element.split(' ')[1])
num1 = num1[1:-2]
print(num1)
# Create an array with sample data
data = np.array(num1).reshape(-1, 3)
# Convert the array to a DataFrame
df = pd.DataFrame(data, columns=['pos', 'neg', 'Age'])
# Write the DataFrame to an Excel file
df.to_excel('data.xlsx', index=False)

278
src/python/forward.py Executable file
View File

@ -0,0 +1,278 @@
#!/usr/bin/env python3
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
#
# This file is part of paramiko.
#
# Paramiko is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
#
# Paramiko 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 Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Paramiko; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
Sample script showing how to do local port forwarding over paramiko.
This script connects to the requested SSH server and sets up local port
forwarding (the openssh -L option) from a local port through a tunneled
connection to a destination reachable from the SSH server machine.
"""
import getpass
import os
import socket
import select
import json
try:
import SocketServer
except ImportError:
import socketserver as SocketServer
import sys
from optparse import OptionParser
import paramiko
SERVER = "linuxsrv01.ece.uw.edu" # Modify this line for different server
SSH_PORT = 22
DEFAULT_PORT = 5901
g_verbose = True
class ForwardServer(SocketServer.ThreadingTCPServer):
daemon_threads = True
allow_reuse_address = True
class Handler(SocketServer.BaseRequestHandler):
def handle(self):
try:
chan = self.ssh_transport.open_channel(
"direct-tcpip",
(self.chain_host, self.chain_port),
self.request.getpeername(),
)
except (ConnectionResetError):
print("ConnectionResetError")
sys.exit(1)
except Exception as e:
verbose(
"Incoming request to %s:%d failed: %s"
% (self.chain_host, self.chain_port, repr(e))
)
return
if chan is None:
verbose(
"Incoming request to %s:%d was rejected by the SSH server."
% (self.chain_host, self.chain_port)
)
return
verbose(
"Connected! Tunnel open %r -> %r -> %r"
% (
self.request.getpeername(),
chan.getpeername(),
(self.chain_host, self.chain_port),
)
)
while True:
r, w, x = select.select([self.request, chan], [], [])
if self.request in r:
data = self.request.recv(1024)
if len(data) == 0:
break
chan.send(data)
if chan in r:
data = chan.recv(1024)
if len(data) == 0:
break
self.request.send(data)
peername = self.request.getpeername()
chan.close()
self.request.close()
verbose("Tunnel closed from %r" % (peername,))
def forward_tunnel(local_host, local_port, remote_host, remote_port, transport):
# this is a little convoluted, but lets me configure things for the Handler
# object. (SocketServer doesn't give Handlers any way to access the outer
# server normally.)
class SubHander(Handler):
chain_host = remote_host
chain_port = remote_port
ssh_transport = transport
ForwardServer((local_host, local_port), SubHander).serve_forever()
def verbose(s):
if g_verbose:
print(s)
HELP = """\
Set up a forward tunnel across an SSH server, using paramiko. A local port
(given with -p) is forwarded across an SSH session to an address:port from
the SSH server. This is similar to the openssh -L option.
"""
def get_host_port(spec, default_port):
"parse 'hostname:22' into a host and port, with the port optional"
args = (spec.split(":", 1) + [default_port])[:2]
args[1] = int(args[1])
return args[0], args[1]
def parse_options():
global g_verbose
parser = OptionParser(
usage="usage: %prog [options] <ssh-server>",
version="%prog 1.0",
description=HELP,
)
parser.add_option(
"-q",
"--quiet",
action="store_false",
dest="verbose",
default=True,
help="squelch all informational output",
)
parser.add_option(
"-p",
"--local-port",
action="store",
type="int",
dest="port",
default=DEFAULT_PORT,
help="local port to forward (default: %d)" % DEFAULT_PORT,
)
parser.add_option(
"-u",
"--user",
action="store",
type="string",
dest="user",
default=getpass.getuser(),
help="username for SSH authentication (default: %s)"
% getpass.getuser(),
)
parser.add_option(
"-K",
"--key",
action="store",
type="string",
dest="keyfile",
default=None,
help="private key file to use for SSH authentication",
)
parser.add_option(
"",
"--no-key",
action="store_false",
dest="look_for_keys",
default=True,
help="don't look for or use a private key file",
)
parser.add_option(
"-P",
"--password",
action="store",
dest="readpass",
default=None,
help="read password (for key or password auth) from stdin",
)
parser.add_option(
"-r",
"--remote",
action="store",
type="string",
dest="remote",
default="localhost",
metavar="host",
help="remote host to forward to",
)
parser.add_option(
"-c",
"--config",
action="store",
type="string",
dest="config",
default=None,
help="config file to use",
)
options, args = parser.parse_args()
# If a config file is provided, load it and overwrite the options
if options.config:
with open(options.config, 'r') as f:
config_options = json.load(f)
for key, value in config_options.items():
setattr(options, key, value)
if len(args) != 1:
parser.error("Incorrect number of arguments.")
if options.user is None:
parser.error("User and Password required (-u).")
g_verbose = options.verbose
return options, args[0]
def main():
options, server = parse_options()
if not options.readpass:
password = getpass.getpass("Enter SSH password: ")
else:
password = options.readpass
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.WarningPolicy())
verbose("Connecting to ssh host ...")
try:
client.connect(server, username=options.user, password=password)
client.get_transport().set_keepalive(60)
except Exception as e:
print("*** Failed to connect to host: %r" % (e))
sys.exit(1)
ssh_stdin, ssh_stdout, ssh_stderr = client.exec_command("vncserver -list")
xdisplay = ssh_stdout.readlines()[-1]
if "DISPLAY" in xdisplay:
print("setting up vncserver")
ssh_stdin, ssh_stdout, ssh_stderr = client.exec_command('vncserver -interface 0.0.0.0 && vncserver -list')
xdisplay = ssh_stdout.readlines()[-1]
port = 5900 + int(xdisplay.split()[0][1:])
verbose(
"Now forwarding port " + str(port) + " ... "
)
try:
forward_tunnel("0.0.0.0", options.port, options.remote, int(port), client.get_transport())
except KeyboardInterrupt:
print("C-c: Port forwarding stopped.")
sys.exit(0)
if __name__ == "__main__":
main()

6
src/python/parse_pdk.py Normal file
View File

@ -0,0 +1,6 @@
import os
from skywater_pdk import base, corners, liberty
lib = "sky130_fd_sc_hd__tt_025C_1v80"
c = base.Cell(name=lib)
print(corners.CornerType.parse('tt'))

19
src/python/parsedata.py Normal file
View File

@ -0,0 +1,19 @@
import os, numpy as np
f = open("data.txt", "r").readlines()
# create a numpy array of the data
data = np.zeros((len(f), 2))
for i in range(len(f)):
# get the last two columns of the data, then convert them to numpy integers, and place it into the array
data[i] = np.array(f[i].strip().split(",")[-2:], dtype=np.int32)
# sum each index of the array
sum = np.sum(data, axis=1)
count = 0
for i in sum:
# print(count, i)
# convert each i in pico seconds to MHz
print(count, (1/(i*10**-12))/10**6)
count += 1

View File

@ -1 +0,0 @@
/home/projects/ee477.2023wtr/cad/pdk/sky130A/libs.ref/sky130_fd_sc_hd/lib/sky130_fd_sc_hd__tt_025C_1v80.lib