Skip to content
Snippets Groups Projects
Commit 06978488 authored by dam1n19's avatar dam1n19
Browse files

SOC1-208: Refactored and Created HTML generation scripts

parent 78e5c225
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
#------------------------------------------------------------------------------------
# Verilog Filelist compilation script
# A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license.
#
# Contributors
#
# David Mapstone (d.a.mapstone@soton.ac.uk)
# Copyright (c) 2023, SoC Labs (www.soclabs.org)
#------------------------------------------------------------------------------------
import argparse
import os
verilog_extensions = (".v", ".sv")
filelist_header = """//-----------------------------------------------------------------------------
// AUTOGENERATED: Compiled Filelist
// A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license.
//
// Contributors
//
// David Mapstone (d.a.mapstone@soton.ac.uk)
//
// Copyright � 2021-3, SoC Labs (www.soclabs.org)
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Abstract : Verilog Command File with expanded system variables
//-----------------------------------------------------------------------------
"""
def env_var_substitute(path):
# Interpret the path and remove brackets from path
sub_path = path.translate(str.maketrans('', '', '()'))
# Expand environment variables in Path
sub_path = os.path.expandvars(sub_path)
return sub_path
def read_list(filelist):
# Create Filelist List Structure
compiled_filelist = []
# Open Filelist and Read Lines
f = open(filelist, "r")
filelines = f.readlines()
f.close()
# Remove Black Lines from list
filelines = [x.rstrip("\n") for x in filelines]
filelines = [x for x in filelines if x != ""]
# Iterate over list and process
for line in filelines:
# Remove whitespace and split line into arguments
line_list = line.strip().split()
# print(line_list)
# Check Line isn't a comment
if not line_list[0].startswith("//"):
# If line is a reference to another filelist
if line_list[0] == "-f":
# Recursively call this function and append list to this compiled Filelist
print(line_list[1])
compiled_filelist += read_list(env_var_substitute(line_list[1]))
elif line_list[0] == "-y":
# Append to filelist
for file in os.listdir(env_var_substitute(line_list[1])):
if file.endswith(verilog_extensions):
compiled_filelist.append(env_var_substitute(line_list[1])+"/"+str(file))
elif line_list[0].startswith("+incdir+"):
# Append to filelist
for file in os.listdir(env_var_substitute(line_list[0].lstrip("+incdir+"))):
if file.endswith(verilog_extensions):
compiled_filelist.append(env_var_substitute(line_list[0].lstrip("+incdir+"))+"/"+str(file))
# If file list a verilog file
elif line_list[0].endswith(verilog_extensions):
# Append to filelist
compiled_filelist.append(env_var_substitute(line_list[0]))
return compiled_filelist
def filelist_compile(args):
input_filelist = args.filelist
output_filelist = args.output
print("------------------")
print("Compiling Filelist")
print("------------------")
filelist = read_list(input_filelist)
filelist = [x+"\n" for x in filelist]
filelist_str = filelist_header
for path in filelist: filelist_str += path
print("Compile Done")
print("------------------")
f_outlist = open(output_filelist, "w")
f_outlist.write(filelist_str)
f_outlist.close()
if __name__ == "__main__":
# Capture Arguments from Command Line
parser = argparse.ArgumentParser(description='Compiles Filelist to Read')
parser.add_argument("-f", "--filelist", type=str, help="Input Filelist to Read")
parser.add_argument("-o", "--output", type=str, help="Output Filelist location")
args = parser.parse_args()
filelist_compile(args)
\ No newline at end of file
#-----------------------------------------------------------------------------
# HTML Generatoration Makefile
# A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license.
#
# Contributors
#
# David Mapstone (d.a.mapstone@soton.ac.uk)
#
# Copyright � 2021-3, SoC Labs (www.soclabs.org)
#-----------------------------------------------------------------------------
# Top-level module of Hierarchy
TOP_MODULE ?= nanosoc_chip
# Filelist to give to v2html
FILELIST ?= $(PROJECT_DIR)/flist/project/system.flist
# Directory to store generated HTML
OUT_DIR ?= $(PROJECT_DIR)
# Name of generated filelist by python script
OUTPUT_FILELIST := $(OUT_DIR)/filelist.flist
bootrom:
make -C $(NANOSOC_TECH_DIR)/system bootrom
htmlgen: bootrom
@echo building HTML tree
@mkdir -p $(OUT_DIR)/build
@(cd $(OUT_DIR)/build; \
rm *.html; rm *.gif; \
$(SOCTOOLS_FLOW_DIR)/bin/htmlgen/filelist_compile.py -f $(FILELIST) -o $(OUTPUT_FILELIST) ; \
$(SOCTOOLS_FLOW_DIR)/bin/htmlgen/v2html/v2html -f $(OUTPUT_FILELIST) -ht $(TOP_MODULE) ; )
v2html Conversion Software
Limited Copyright Licence
BACKGROUND
The accompanying v2html conversion software (the software) is a
copyrighted work. This document describes conditions under which the
software can be copied, modified and distributed.
All rights, including copyright, in the software are retained by the
owner(s) as identified in each software file.
Subject to the conditions described below, you may modify source
files included with the software and distribute the modified
versions. The software accompanying this notice may include such
derivative works.
CONDITIONS FOR AUTHORIZED COPYING, MODIFICATION AND DISTRIBUTION
If you agree to all of the following conditions, you may copy, modify
and distribute the software subject to these conditions.
You do not need to agree to these conditions. However, if you do not
agree to all of the following conditions, you are not authorized to
do anything with regard to the copyrighted work that is within the
exclusive domain of a copyright owner, such as copying, modification,
and distribution.
(1) No fee (monetary or otherwise) may be charged for the software or
any derivative work (whether in exchange for copying, distribution,
use, or otherwise).
(2) The software includes copyright notices, references to this
document, and warnings concerning the intended use of the software.
All such notices are to be included in all copies of the software.
Any code copied or moved to a file not having such notices must be
accompanied by such notices. Notices that are displayed to a user
during execution of the software are to remain intact.
(3) This document may not be modified. A copy of this document must
be included with each copy of the software, including derivative
works.
(4) Failure to abide by these conditions terminates any rights that
you may otherwise have had under this licence.
(5) NO WARRANTY: The software has NO warranty from anyone; for
example, there is NO warranty that the software is error free and
there is NO warranty with respect to infringement of patents,
copyrights or any other intellectual property rights. The software
is provided "AS IS." NO support is provided for the software.
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE SPECIFICALLY DISCLAIMED.
(6) LIMITATIONS OF REMEDIES AND LIABILITY:
In no event shall Hewlett-Packard be liable for direct, indirect,
special, incidental or consequential damages (including lost
profits), whether based on contract, tort or any other legal theory.
(7) DERIVATIVE WORKS: In this document, the phrase "derivative work"
is intended to include only those works that include sufficient
copyrightable material from the software such that the derivative
work would be a copyright infringement if made without authorization
of the owner of the copyright in the software.
v2html - verilog to html converter
----------------------------------
See LICENCE.TXT for details of licencing.
See http://www.burbleland.com/v2html for more information.
Files included:
README - this file
v2html - v2html perl script
v2html-cgi - CGI helper script (for collapsible hierarchy)
LICENCE.TXT - licence
v2html.man.html - man page in html format
v2html.1 - man page in nroff format
- Make sure you have perl version 5.004 or later (perl -v tells you
the version).
Unix Installation
-----------------
- Copy v2html to somewhere like /usr/local/bin.
- If you are using the CGI script then see your web-server's documentation
on where to put CGI scripts.
- Copy v2html.1 to somewhere like /usr/local/man.
If your copy of perl is not in /usr/bin then you will have to edit the
first line of v2html and v2html-cgi to refer to where your copy of
perl in installed. Alternatively you could install a link from
/usr/bin/perl to your copy of perl.
Windows Installation
--------------------
- Put the v2html script somewhere (eg C:\v2html)
- Then, assuming you have Perl installed as c:\perl\bin\perl.exe, you should
be able to run v2html from a DOS box with a command like this:
c:\perl\bin\perl.exe c:\v2html\v2html -f my_cmd_file.vc
This diff is collapsed.
#!/usr/local/bin/perl -w
###############################################################################
#
# File: v2html-cgi
# RCS: $Header: v2html-cgi,v 3.1 1999/09/21 18:38:43 cc Exp $
# Description: CGI script for helping v2html generated html
# Author: Costas Calamvokis
# Created: Wed Sep 3 08:52:08 1997
# Modified: Tue Sep 21 11:34:21 1999 (Costas Calamvokis) v2html@burbleland.com
# Language: Perl
#
# Copyright 1998 Costas Calamvokis
# Copyright 1997 Hewlett-Packard Company
#
# This file nay be copied, modified and distributed only in accordance
# with the terms of the limited licence contained in the accompanying
# file LICENCE.TXT.
#
###############################################################################
#
# Currently does:
# Expanding/compressing hierarchies:
# - Takes a query like ?k=9437645&x=XXXXCCXC&in=hierarchy.html
# and generates html of the hierarchy in in accoring to the string
# x, each character in the string x represents one list in the .html
# file which can either be eXpanded or Compressed.
# - After each module it also generates a [X] or [C] link which when
# clicked causes this script to be called again with a new string
# which results in that module being expanded or compressed.
# - This is made much easier by v2html which marks each list that is
# with a candidate for expansion/compression with a
# number when it generates the html code.
#
# only have one file error message to avoid leaking information
# through errors (uncomment the helpful error during debugging)
$file_error_message= "v2html-cgi error.<P>\n";
print "Content-Type: text/html\n\n";
# environment variables that should be set by the web server
&check_input('QUERY_STRING',%ENV);
&check_input('SCRIPT_NAME',%ENV);
&check_input('PATH_INFO',%ENV);
&check_input('PATH_TRANSLATED',%ENV);
# Get the arguements specified in the URL
%args= getcgivars();
# query variables that should be set in the URL
# (eg .. ?k=9999x=CXCX&in=hierarchy.html
&check_input('x',%args);
&check_input('f',%args);
&check_input('in',%args);
&check_input('k',%args);
$k = $args{'k'};
$expand_string =$args{'x'};
$infile = $args{'in'};
$framed = $args{'f'};
# remove the / from script name if it is there
$ENV{'SCRIPT_NAME'} =~ s#^/## ;
# set up the cgi script and path info that we'll put in the expand/compress
# links
$cgi_script_and_path_info= "/" . $ENV{'SCRIPT_NAME'} . $ENV{'PATH_INFO'};
$marker = " <!-- v2html_handle --> ";
$printing=1; # start out printing the file
$ul_id=0;
# Work out the hierarchy file to read
$file=$ENV{'PATH_TRANSLATED'} . $infile;
# Remove any .. in the file name so people can't look at files
# that are not under the web root
$file=~ s/\.\.//g;
# open the hierarchy file
unless (open(F,"<$file")) {
print $file_error_message;
# this less cryptic message could give intruders clues about your files
#print "Couldn't open $ENV{'PATH_TRANSLATED'}$infile\n";
exit;
}
# check that the hierarchy file starts with "<!- v2html hierarchy" comment
# and that the key is correct
$_ = <F>;
&security_check_hierarchy($_);
# Have a look for the briefcase icons - if they don't exist
# use [C] and [X]
&find_icons;
# set up the extra infomation needed to do framed output
if ($framed eq "1") { $target='target="upper"'; }
else { $target=''; }
#
# main loop
#
while (<F>) {
# print the place to find the .v.html files at the bottom of the
# header - if we don't do this then it'll look for them under
# the cgi-bin directory
if (m&</head>&) {
print "<base href=\"http://$ENV{'SERVER_NAME'}" .
":$ENV{'SERVER_PORT'}$ENV{'PATH_INFO'}\">\n";
}
if ($printing) {
if (m&<ul> <!-- ul_id=([0-9]+) -->&) {
if (&check_expand_string($1)) {
# This is expanded now, so print compressor
print $marker .
"<A name=\"ul_id_$1\"></A>\n";
print $marker .
"<A $target href=\"$cgi_script_and_path_info?k=$k&x=" .
&new_expand_string($1,"C") .
"&in=$infile&f=$framed#ul_id_$1\"> $icon_c</A>\n";
# keep printing
print $_;
}
else {
$ul_id=$1;
# This is compressed now, so print expander
print $marker .
"<A name=\"ul_id_$ul_id\"></A>\n";
print $marker .
"<A $target href=\"$cgi_script_and_path_info?k=$k&x=" .
&new_expand_string($ul_id,"X") .
"&in=$infile&f=$framed#ul_id_$1\"> $icon_x</A>\n";
# stop printing
$printing=0;
}
}
else {
# print everything else except compressors and expanders
# which are generated fresh each time
if (! m/$marker/) {
print $_;
}
}
}
else {
# not printing, look for the end of the ul_id which stopped the
# print.
if (m&</ul> <!-- ul_id=$ul_id -->&) {
$printing=1;
}
}
}
exit;
###########################################################################
# Subroutines
###########################################################################
#
# Takes one arguement - the number in the character string to
# look at.
# Returns 1 if the list is expanded and 0 if it is compressed
# if the number is off the end of the expand string then it
# returns 1
#
sub check_expand_string {
local($u) = @_;
local($c);
if ($expand_string eq 'A') {
return 1;
}
elsif (length($expand_string)>$u) {
$c = substr($expand_string,$u,1);
if ($c eq 'X'){
return 1;
}
else {
return 0;
}
}
else {
return 0;
}
}
#
# Generate a new expand_string for a compressor or an expander link
# Takes two arguments, the number of the list and the new character
# to put in ('C' for compressor, 'X' for expander)
#
sub new_expand_string {
local($u,$c) = @_;
local($new_string,$l);
$l = length($expand_string);
if ($l > $u) {
$new_string = $expand_string;
substr($new_string,$u,1) = $c;
}
else {
if ($expand_string eq "A") {
$new_string = "X" . "X" x ($u-$l) . $c;
}
else {
$new_string = $expand_string . "C" x ($u-$l) . $c;
}
}
return $new_string;
}
#
# check that the input array %a has an element $s
#
sub check_input {
local($s,%a) = @_;
if (!exists($a{$s})) {
print "v2html-cgi: fatal error, didn't get required parameter $s.<P>\n";
if ($s eq 'k') {
print " This may be because the hierarchy was generated\n" .
" by v2html 2.0. If so regenerate using a newer version<P>\n";
}
exit;
}
}
#
# Read all CGI vars into an associative array.
# If multiple input fields have the same name, they are concatenated into
# one array element and delimited with the \0 character.
# This is a simple version, that assumes a request method of GET.
#
sub getcgivars {
local(%in) ;
local($name, $value) ;
# Resolve and unencode name/value pairs into %in
foreach (split('&', $ENV{'QUERY_STRING'})) {
s/\+/ /g ;
($name, $value)= split('=', $_, 2) ;
$name=~ s/%(..)/sprintf("%c",hex($1))/ge ;
$value=~ s/%(..)/sprintf("%c",hex($1))/ge ;
$in{$name}.= "\0" if defined($in{$name}) ; # concatenate multiple vars
$in{$name}.= $value ;
}
return %in ;
}
#
# Do security checks on the hierarchy file
# make sure we don't:
# serve files that are not v2html hierarchies
# serve files that users can't get access to through the http demon
# (by checking that the key is right)
#
sub security_check_hierarchy {
my ($first_line) = @_;
if ($first_line =~ /^<!-- v2html hierarchy/) {
if ($first_line =~ /^<!-- v2html hierarchy K=$k /) {
print $first_line;
}
else {
print $file_error_message;
# this less cryptic message could give intruders clues about your files
#print "$ENV{'PATH_TRANSLATED'}$infile: bad key<P>\n";
exit;
}
}
else {
print $file_error_message;
# this less cryptic message could give intruders clues about your files
#print "$ENV{'PATH_TRANSLATED'}$infile is not a v2html hierarchy file\n";
exit;
}
}
#
# Look for the briefcase icons - if they don't exist use [C] and [X]
#
sub find_icons {
if (( -r "$ENV{'PATH_TRANSLATED'}/v2html-c.gif" ) &&
( -r "$ENV{'PATH_TRANSLATED'}/v2html-x.gif" )) {
$icon_c = "<IMG align=bottom border=0 SRC=\"v2html-c.gif\">";
$icon_x = "<IMG align=bottom border=0 SRC=\"v2html-x.gif\">";
}
else {
$icon_c = " [C]";
$icon_x = " [X]";
}
}
This diff is collapsed.
This diff is collapsed.
#!/bin/bash
#!/bin/bash
# Update all Submodules to latest commit
cd $DESIGN_ROOT; git submodule foreach --recursive git pull
# for d in $DESIGN_ROOT/* ; do
# if [ -f "$d/.git" ]; then
# echo "Git Pulling $d"
# cd $d; git pull; cd ..
# fi
# done
\ No newline at end of file
#-----------------------------------------------------------------------------
# SoC Labs socsim script to run required simulation
# A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license.
#
# Contributors
#
# David Mapstone (d.a.mapstone@soton.ac.uk)
#
# Copyright 2023, SoC Labs (www.soclabs.org)
#-----------------------------------------------------------------------------
#!/usr/bin/env bash
# Check arguments passed to SoCSim
if [ $# -eq 0 ]
then
echo "No arguments supplied"
else
# If clean command passed in clean a specific directory or all
if [ ${1} == "clean" ]; then
if [ $# -eq 1 ]; then
echo "No clean arguments supplied"
else
if [ ${2} == "all" ]; then
# Clean all simualation directories
echo "Cleaning all Project Simulation Directories"
rm -rf $PROJECT_DIR/simulate/sim
mkdir -p $PROJECT_DIR/simulate/sim
else
# Remove specific simulaiton directory
SIM_DIR=$PROJECT_DIR/simulate/sim/${2}
if [ -d "$SIM_DIR" ]; then
rm -rf $SIM_DIR
else
echo "Simulation Directory '${2}' doesn't exist"
fi
fi
fi
fi
# Find a simulation script in the SoCSim environments of all subrepos
simscript=$(find ${SOCSIM_PATH//:/\ } -name "${1}.sh")
# Run Script if Found
$simscript $@
fi
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment