From 055431e4bee9a273bd5cff72b4f600033d0d09fb Mon Sep 17 00:00:00 2001 From: Rahul Paknikar Date: Tue, 25 Jun 2019 09:40:43 +0530 Subject: Add files via upload --- src/model_generation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/model_generation.py') diff --git a/src/model_generation.py b/src/model_generation.py index 15dc3e6..9a1aec8 100644 --- a/src/model_generation.py +++ b/src/model_generation.py @@ -92,7 +92,9 @@ data=read_file.readlines() read_file.close() #Extracting input and output port list from data +print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" for line in data: + print line if re.match(r'^\s*$', line): pass #print "Blank Line" @@ -216,9 +218,9 @@ init_else=''' ''' els_evt_ptr=[] -els_evt_count1=[] +els_evt_count1=0 +els_evt_count2=0 for item in output_port: - els_evt_count2=0 els_evt_ptr.append("_op_"+item.split(":")[0]+" = cm_event_get_ptr("+str(els_evt_count1)+","+str(els_evt_count2)+");") els_evt_count2=els_evt_count2+1 els_evt_ptr.append("_op_"+item.split(":")[0]+"_old"+" = cm_event_get_ptr("+str(els_evt_count1)+","+str(els_evt_count2)+");") @@ -612,6 +614,7 @@ ifspec.close() print "Starting with testbench file" testbench=open(fname.split('.')[0]+'_tb.vhdl','w') +print fname.split('.')[0] + '_tb.vhdl' #comment comment_vhdl="--------------------------------------------------------------------------------\n--This testbench has been created by Ambikeshwar Srivastava, FOSSEE, IIT Bombay\n-------------------------------------------------------------------------------" #Adding header, entity and architecture statement -- cgit From 608762b6aa6f63858e67cdf13cbfd94f698f53c5 Mon Sep 17 00:00:00 2001 From: Rahul Paknikar Date: Sun, 7 Jul 2019 17:03:52 +0530 Subject: Std_Logic --- src/model_generation.py | 75 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 18 deletions(-) (limited to 'src/model_generation.py') diff --git a/src/model_generation.py b/src/model_generation.py index 9a1aec8..772cbb5 100644 --- a/src/model_generation.py +++ b/src/model_generation.py @@ -41,6 +41,7 @@ for item in vhdl_data: #print "Scan Data",scan_data port_info=[] +port_vector_info = [] for item in scan_data: print "Scan Data :",item @@ -67,7 +68,12 @@ for item in scan_data: lhs=temp.split(item)[0] rhs=temp.split(item)[1] bit_info=re.compile(r"\s*downto\s*",flags=re.I).split(rhs)[0] - port_info.append(lhs+":"+str(int(bit_info)+int(1))) + if bit_info: + port_info.append(lhs+":"+str(int(bit_info)+int(1))) + port_vector_info.append(1) + else: + port_info.append(lhs+":"+str(int(1))) + port_vector_info.append(0) print "Port Info :",port_info @@ -639,16 +645,32 @@ arch="architecture "+fname.split('.')[0]+"_tb_beh of "+fname.split('.')[0]+"_tb components=[] components.append("\tcomponent "+fname.split('.')[0]+" is\n\t\tport(\n\t\t\t\t") +port_vector_count = 0 + for item in input_port: - components.append(item.split(':')[0]+": in std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n\t\t\t\t") - #if item.split(":")[1] != '1': - # components.append(item.split(':')[0]+": in std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n\t\t\t\t") - #else: - # components.append(item.split(':')[0]+": in std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n\t\t\t\t") + if port_vector_info[port_vector_count]: + components.append(item.split(':')[0]+": in std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n\t\t\t\t") + else: + components.append(item.split(':')[0]+": in std_logic;\n\t\t\t\t") + + port_vector_count += 1 + #if item.split(":")[1] != '1': + # components.append(item.split(':')[0]+": in std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n\t\t\t\t") + #else: + # components.append(item.split(':')[0]+": in std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n\t\t\t\t") for item in output_port[:-1]: - components.append(item.split(':')[0]+": out std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n\t\t\t\t") -components.append(output_port[-1].split(':')[0]+": out std_logic_vector("+str(int(output_port[-1].split(':')[1])-int(1))+" downto 0)\n\t\t\t\t") + if port_vector_info[port_vector_count]: + components.append(item.split(':')[0]+": out std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n\t\t\t\t") + else: + components.append(item.split(':')[0]+": out std_logic;\n\t\t\t\t") + + port_vector_count += 1 + +if port_vector_info[port_vector_count]: + components.append(output_port[-1].split(':')[0]+": out std_logic_vector("+str(int(output_port[-1].split(':')[1])-int(1))+" downto 0)\n\t\t\t\t") +else: + components.append(output_port[-1].split(':')[0]+": out std_logic\n\t\t\t\t") #if item.split(":")[1] != '1': # components.append(item.split(':')[0]+": out std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0)\n\t\t\t\t") #else: @@ -661,8 +683,15 @@ components.append("\tend component;\n\n") signals=[] signals.append("\tsignal clk_s : std_logic := '0';\n") +port_vector_count = 0 + for item in input_port: - signals.append("\tsignal "+item.split(':')[0]+": std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n") + if port_vector_info[port_vector_count]: + signals.append("\tsignal "+item.split(':')[0]+": std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n") + else: + signals.append("\tsignal "+item.split(':')[0]+": std_logic;\n") + port_vector_count += 1 + #if item.split(":")[1] != '1': # signals.append("\tsignal "+item.split(':')[0]+": std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n") #else: @@ -670,7 +699,11 @@ for item in input_port: for item in output_port: - signals.append("\tsignal "+item.split(':')[0]+": std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n") + if port_vector_info[port_vector_count]: + signals.append("\tsignal "+item.split(':')[0]+": std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n") + else: + signals.append("\tsignal "+item.split(':')[0]+": std_logic;\n") + port_vector_count += 1 #if item.split(":")[1] != '1': # signals.append("\tsignal "+item.split(':')[0]+": std_logic_vector("+str(int(item.split(':')[1])-int(1))+" downto 0);\n") #else: @@ -711,17 +744,28 @@ process.append("\tbegin\n") process.append("\t\twhile true loop\n") process.append("\t\t\twait until clk_s = '0';\n\n") +port_vector_count = 0 + for item in input_port: process.append('\t\t\tobj_ref := Pack_String_To_Vhpi_String("'+item.split(':')[0]+'");\n') process.append('\t\t\tVhpi_Get_Port_Value(obj_ref,'+item.split(':')[0]+'_v,'+item.split(':')[1]+');\n') process.append('\t\t\tassert false report "Get port value '+item.split(':')[0]+' returns " &'+item.split(':')[0]+'_v severity note;\n') - process.append('\t\t\t'+item.split(':')[0]+' <= Unpack_String('+item.split(':')[0]+'_v,'+item.split(':')[1]+');\n') + if port_vector_info[port_vector_count]: + process.append('\t\t\t'+item.split(':')[0]+' <= Unpack_String('+item.split(':')[0]+'_v,'+item.split(':')[1]+');\n') + else: + process.append('\t\t\t'+item.split(':')[0]+' <= To_Std_Logic('+item.split(':')[0]+'_v'+');\n') + port_vector_count += 1 process.append("\n") process.append('\t\t\twait for 1 us;\n') for item in output_port: - process.append('\t\t\t'+item.split(':')[0]+'_v := Pack_String_To_Vhpi_String(Convert_SLV_To_String('+item.split(':')[0]+'));\n') + if port_vector_info[port_vector_count]: + process.append('\t\t\t'+item.split(':')[0]+'_v := Pack_String_To_Vhpi_String(Convert_SLV_To_String('+item.split(':')[0]+'));\n') + else: + process.append('\t\t\t'+item.split(':')[0]+'_v := Pack_String_To_Vhpi_String(To_String('+item.split(':')[0]+'));\n') + port_vector_count += 1 + process.append('\t\t\tobj_ref := Pack_String_To_Vhpi_String("'+item.split(':')[0]+'");\n') process.append('\t\t\tVhpi_Set_Port_Value(obj_ref,'+item.split(':')[0]+'_v,'+item.split(':')[1]+');\n') process.append('\t\t\tassert false report "Set port value '+item.split(':')[0]+' returns " &'+item.split(':')[0]+'_v severity note;\n') @@ -798,9 +842,4 @@ sock_pkg_create.write("\t\t\tbegin\n") sock_pkg_create.write("\t\t\t\tsock_id := $1;\n") sock_pkg_create.write("\t\t\t\treturn sock_id;\n") sock_pkg_create.write("\t\t\tend function;\n") -sock_pkg_create.write("\t\tend package body;\" > sock_pkg.vhdl") - - - - - +sock_pkg_create.write("\t\tend package body;\" > sock_pkg.vhdl") \ No newline at end of file -- cgit From e43b6221138d30d9b2ea37c708c9521d4ba926af Mon Sep 17 00:00:00 2001 From: fossee Date: Wed, 18 Sep 2019 17:25:18 +0530 Subject: support for multiple ghdl models --- src/model_generation.py | 87 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 8 deletions(-) (limited to 'src/model_generation.py') diff --git a/src/model_generation.py b/src/model_generation.py index 772cbb5..40a4b4a 100644 --- a/src/model_generation.py +++ b/src/model_generation.py @@ -143,7 +143,7 @@ cfunc=open('cfunc.mod','w') print "Building content for cfunc.mod file" comment='''/* This is cfunc.mod file auto generated by gen_con_info.py -Developed by Fahim at IIT Bombay */ \n +Developed by Fahim, Rahul at IIT Bombay */ \n ''' header=''' @@ -217,6 +217,8 @@ systime_info=''' fprintf(log_client,"Setup Client Server Connection at %s \\n",ctime(&systime)); ''' + + init_else=''' printf("Client-Inside else of INIT \\n"); fprintf(log_client,"Inside else of INIT \\n"); @@ -233,13 +235,80 @@ for item in output_port: els_evt_count1=els_evt_count1+1 -client_setup=''' - /* Client setup */ - //Default hostname assignment - host = gethostbyname("127.0.0.1"); +client_setup_ip=''' + /* Client Setup IP Addr */ + FILE *fptr; + int ip_count = 0; + char my_ip[20]; + + fptr = fopen("/tmp/NGHDL_COMMON_IP.txt", "r"); + if (fptr) + { + char line[20]; + while(fscanf(fptr, "%s", line) == 1) { + ip_count++; + } + + fclose(fptr); + } + + if (ip_count < 255) { + sprintf(my_ip, "127.0.0.%d", ip_count+1); + } else { + sprintf(my_ip, "127.0.%d.1", (ip_count+1)%256); + } + + fptr = fopen("/tmp/NGHDL_COMMON_IP.txt", "a"); + if (fptr) + { + fprintf(fptr, "%s\\n", my_ip); + fclose(fptr); + } else { + perror("fopen() - Common IP"); + exit(1); + } + + + char ip_filename[300]; +''' +client_setup_ip +='sprintf(ip_filename,"'+home+'/ngspice-nghdl/src/xspice/icm/ghdl/'+fname.split('.')[0]+'/DUTghdl/NGHDL_IP.txt");' +client_setup_ip +=''' + fptr = fopen(ip_filename, "w"); + if(fptr) + { + fprintf(fptr, "%s\\n", my_ip); + fclose(fptr); + } else { + perror("fopen() - IP file"); + exit(1); + } +''' + +client_fetch_ip=''' + /* Client Fetch IP Addr */ + + char lo_ip[20]; + char ip_filename[300]; +''' +client_fetch_ip +='sprintf(ip_filename,"'+home+'/ngspice-nghdl/src/xspice/icm/ghdl/'+fname.split('.')[0]+'/DUTghdl/NGHDL_IP.txt");\n' +client_fetch_ip +=''' + FILE* fp = fopen(ip_filename, "r"); + if (fp) + { + if (fscanf(fp, "%s", lo_ip) != EOF) + { + fclose(fp); + } + } else { + perror("fopen() - NGHDL_IP file"); + exit(1); + } + + host = gethostbyname(lo_ip); printf("Client-Creating Client Socket \\n"); fprintf(log_client,"Creating client socket \\n"); ''' + create_socket=''' //Creating socket for client if ((socket_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) @@ -471,10 +540,12 @@ for item in cm_event_get_ptr: cfunc.write("\n") cfunc.write(systime_info) cfunc.write("\n") -cfunc.write("\t\tchar command[1024];") +cfunc.write(client_setup_ip) +cfunc.write("\n") +cfunc.write("\t\tchar command[1024];\n") cfunc.write('\t\tsnprintf(command,1024,"'+home+'/ngspice-nghdl/src/xspice/icm/ghdl/'+fname.split('.')[0]+'/DUTghdl/start_server.sh %d &",sock_port);\n') cfunc.write('\t\tsystem(command);') -cfunc.write("\t}") +cfunc.write("\n\t}") cfunc.write("\n") cfunc.write("\telse\n\t{\n") @@ -484,7 +555,7 @@ for item in els_evt_ptr: cfunc.write("\t}") cfunc.write("\n\n") cfunc.write("\tif(flag==0)\n\t{") -cfunc.write(client_setup) +cfunc.write(client_fetch_ip) cfunc.write(create_socket) cfunc.write(connect_server) cfunc.write(time_limit) -- cgit From 7852873cf0bc8b8082ea847a868ab84930163667 Mon Sep 17 00:00:00 2001 From: rahul Date: Thu, 26 Sep 2019 15:21:18 +0530 Subject: multiple instances (static ip) --- src/model_generation.py | 87 ++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 48 deletions(-) (limited to 'src/model_generation.py') diff --git a/src/model_generation.py b/src/model_generation.py index 40a4b4a..4e986f6 100644 --- a/src/model_generation.py +++ b/src/model_generation.py @@ -239,7 +239,7 @@ client_setup_ip=''' /* Client Setup IP Addr */ FILE *fptr; int ip_count = 0; - char my_ip[20]; + char* my_ip = malloc(16); fptr = fopen("/tmp/NGHDL_COMMON_IP.txt", "r"); if (fptr) @@ -268,43 +268,15 @@ client_setup_ip=''' exit(1); } - - char ip_filename[300]; -''' -client_setup_ip +='sprintf(ip_filename,"'+home+'/ngspice-nghdl/src/xspice/icm/ghdl/'+fname.split('.')[0]+'/DUTghdl/NGHDL_IP.txt");' -client_setup_ip +=''' - fptr = fopen(ip_filename, "w"); - if(fptr) - { - fprintf(fptr, "%s\\n", my_ip); - fclose(fptr); - } else { - perror("fopen() - IP file"); - exit(1); - } + STATIC_VAR(my_ip) = my_ip; ''' client_fetch_ip=''' /* Client Fetch IP Addr */ - char lo_ip[20]; - char ip_filename[300]; -''' -client_fetch_ip +='sprintf(ip_filename,"'+home+'/ngspice-nghdl/src/xspice/icm/ghdl/'+fname.split('.')[0]+'/DUTghdl/NGHDL_IP.txt");\n' -client_fetch_ip +=''' - FILE* fp = fopen(ip_filename, "r"); - if (fp) - { - if (fscanf(fp, "%s", lo_ip) != EOF) - { - fclose(fp); - } - } else { - perror("fopen() - NGHDL_IP file"); - exit(1); - } - - host = gethostbyname(lo_ip); + char* my_ip = STATIC_VAR(my_ip); + + host = gethostbyname(my_ip); printf("Client-Creating Client Socket \\n"); fprintf(log_client,"Creating client socket \\n"); ''' @@ -543,7 +515,7 @@ cfunc.write("\n") cfunc.write(client_setup_ip) cfunc.write("\n") cfunc.write("\t\tchar command[1024];\n") -cfunc.write('\t\tsnprintf(command,1024,"'+home+'/ngspice-nghdl/src/xspice/icm/ghdl/'+fname.split('.')[0]+'/DUTghdl/start_server.sh %d &",sock_port);\n') +cfunc.write('\t\tsnprintf(command,1024,"'+home+'/ngspice-nghdl/src/xspice/icm/ghdl/'+fname.split('.')[0]+'/DUTghdl/start_server.sh %d %s &",sock_port, my_ip);') cfunc.write('\t\tsystem(command);') cfunc.write("\n\t}") cfunc.write("\n") @@ -669,6 +641,16 @@ Null_Allowed: yes no ''' +static__table=''' + +STATIC_VAR_TABLE: + +Static_Var_Name: my_ip +Data_Type: pointer +Description: "connect to ghdlserver through this ip" + +''' + #Writing all the content in ifspec file ifspec.write(ifspec_comment) @@ -684,6 +666,8 @@ for item in out_port_table: ifspec.write("\n") ifspec.write(parameter_table) +ifspec.write("\n") +ifspec.write(static_table) ifspec.close() @@ -693,7 +677,9 @@ print "Starting with testbench file" testbench=open(fname.split('.')[0]+'_tb.vhdl','w') print fname.split('.')[0] + '_tb.vhdl' #comment -comment_vhdl="--------------------------------------------------------------------------------\n--This testbench has been created by Ambikeshwar Srivastava, FOSSEE, IIT Bombay\n-------------------------------------------------------------------------------" +comment_vhdl="--------------------------------------------------------------------------------\n--This testbench has been created by Ambikeshwar Srivastava, FOSSEE, IIT Bombay\n--------------------------------------------------------------------------------\n" +comment_vhdl+="--------------------------------------------------------------------------------\n--Modified by Rahul Paknikar, FOSSEE, IIT Bombay" +comment_vhdl+="--retrieves the IP-Addr from sock_pkg and forwards it to the ghdlserver\n--------------------------------------------------------------------------------" #Adding header, entity and architecture statement tb_header=''' library ieee; @@ -799,7 +785,7 @@ map.append("\t\t\t);") tb_clk= "clk_s <= not clk_s after 5 us;\n\n" #Adding Process block for Vhpi process_Vhpi=[] -process_Vhpi.append("\tprocess\n\t\tvariable sock_port : integer;\n\t\tbegin\n\t\tsock_port := sock_pkg_fun;\n\t\tVhpi_Initialize(sock_port);\n\t\twait until clk_s = '1';\n\t\twhile true loop\n\t\t\twait until clk_s = '0';\n\t\t\tVhpi_Listen;\n\t\t\twait for 1 us;\n\t\t\tVhpi_Send;\n\t\tend loop;\n\t\twait;\n\tend process;\n\n") +process_Vhpi.append("\tprocess\n\t\tvariable sock_port : integer;\n\t\ttype string_ptr is access string;\n\t\tvariable sock_ip : string_ptr;\n\t\tbegin\n\t\tsock_port := sock_port_fun;\n\t\tsock_ip := new string'(sock_ip_fun);\n\t\tVhpi_Initialize(sock_port, Pack_String_To_Vhpi_String(sock_ip.all));\n\t\twait until clk_s = '1';\n\t\twhile true loop\n\t\t\twait until clk_s = '0';\n\t\t\tVhpi_Listen;\n\t\t\twait for 1 us;\n\t\t\tVhpi_Send;\n\t\tend loop;\n\t\twait;\n\tend process;\n\n") #Adding process block process=[] process.append("\tprocess\n\n") @@ -882,12 +868,9 @@ start_server = open('start_server.sh','w') start_server.write("#!/bin/bash\n\n") start_server.write("###This server run ghdl testebench for infinite time till ngspice send END signal to stop it\n\n") -start_server.write("#gcc -c ghdlserver.c\n") -start_server.write("#ghdl -a Utility_Package.vhdl &&\n") -start_server.write("#ghdl -a Vhpi_Package.vhdl &&\n") start_server.write("cd "+home+"/ngspice-nghdl/src/xspice/icm/ghdl/"+fname.split('.')[0]+"/DUTghdl/\n") start_server.write("chmod 775 sock_pkg_create.sh &&\n") -start_server.write("./sock_pkg_create.sh $1 &&\n") +start_server.write("./sock_pkg_create.sh $1 $2 &&\n") start_server.write("ghdl -a sock_pkg.vhdl &&\n") start_server.write("ghdl -a "+fname+" &&\n") start_server.write("ghdl -a "+fname.split('.')[0]+"_tb.vhdl &&\n") @@ -901,16 +884,24 @@ start_server.close() sock_pkg_create = open('sock_pkg_create.sh','w') sock_pkg_create.write("#!/bin/bash\n\n") -sock_pkg_create.write("##This file create sock_pkg_create.vhdl file and set the instance id from parameter based on parameter\n\n") +sock_pkg_create.write("##This file creates sock_pkg.vhdl file and sets the port and ip from parameters passed to it\n\n") sock_pkg_create.write("echo \"library ieee;\n") sock_pkg_create.write("package sock_pkg is\n") -sock_pkg_create.write("\tfunction sock_pkg_fun return integer;\n") +sock_pkg_create.write("\tfunction sock_port_fun return integer;\n") +sock_pkg_create.write("\tfunction sock_ip_fun return string;\n") sock_pkg_create.write("end;\n\n") -sock_pkg_create.write("\tpackage body sock_pkg is\n") -sock_pkg_create.write("\t function sock_pkg_fun return integer is") -sock_pkg_create.write("\t\tvariable sock_id : integer;\n") +sock_pkg_create.write("package body sock_pkg is\n") +sock_pkg_create.write("\tfunction sock_port_fun return integer is\n") +sock_pkg_create.write("\t\tvariable sock_port : integer;\n") +sock_pkg_create.write("\t\t\tbegin\n") +sock_pkg_create.write("\t\t\t\tsock_port := $1;\n") +sock_pkg_create.write("\t\t\t\treturn sock_port;\n") +sock_pkg_create.write("\t\t\tend function;\n\n") +sock_pkg_create.write("\tfunction sock_ip_fun return string is\n") +sock_pkg_create.write("\t\ttype string_ptr is access string;\n") +sock_pkg_create.write("\t\tvariable sock_ip : string_ptr;\n") sock_pkg_create.write("\t\t\tbegin\n") -sock_pkg_create.write("\t\t\t\tsock_id := $1;\n") -sock_pkg_create.write("\t\t\t\treturn sock_id;\n") -sock_pkg_create.write("\t\t\tend function;\n") +sock_pkg_create.write('\t\t\t\tsock_ip := new string\'(\\"$2\\");\n') +sock_pkg_create.write("\t\t\t\treturn sock_ip.all;\n") +sock_pkg_create.write("\t\t\tend function;\n\n") sock_pkg_create.write("\t\tend package body;\" > sock_pkg.vhdl") \ No newline at end of file -- cgit From 5424f679d05523323f9c1d7a9840c89d9dcccb1f Mon Sep 17 00:00:00 2001 From: rahul Date: Thu, 26 Sep 2019 15:34:50 +0530 Subject: multiple instances (static ip) --- src/model_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/model_generation.py') diff --git a/src/model_generation.py b/src/model_generation.py index 4e986f6..1600dc1 100644 --- a/src/model_generation.py +++ b/src/model_generation.py @@ -641,7 +641,7 @@ Null_Allowed: yes no ''' -static__table=''' +static_table=''' STATIC_VAR_TABLE: -- cgit From d8fccdec26e2233f4d013bb6516b785892eb0ea4 Mon Sep 17 00:00:00 2001 From: rahul Date: Fri, 27 Sep 2019 15:07:17 +0530 Subject: adjusted layout --- src/model_generation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/model_generation.py') diff --git a/src/model_generation.py b/src/model_generation.py index 1600dc1..3df4676 100644 --- a/src/model_generation.py +++ b/src/model_generation.py @@ -516,7 +516,7 @@ cfunc.write(client_setup_ip) cfunc.write("\n") cfunc.write("\t\tchar command[1024];\n") cfunc.write('\t\tsnprintf(command,1024,"'+home+'/ngspice-nghdl/src/xspice/icm/ghdl/'+fname.split('.')[0]+'/DUTghdl/start_server.sh %d %s &",sock_port, my_ip);') -cfunc.write('\t\tsystem(command);') +cfunc.write('\n\t\tsystem(command);') cfunc.write("\n\t}") cfunc.write("\n") cfunc.write("\telse\n\t{\n") @@ -678,8 +678,8 @@ testbench=open(fname.split('.')[0]+'_tb.vhdl','w') print fname.split('.')[0] + '_tb.vhdl' #comment comment_vhdl="--------------------------------------------------------------------------------\n--This testbench has been created by Ambikeshwar Srivastava, FOSSEE, IIT Bombay\n--------------------------------------------------------------------------------\n" -comment_vhdl+="--------------------------------------------------------------------------------\n--Modified by Rahul Paknikar, FOSSEE, IIT Bombay" -comment_vhdl+="--retrieves the IP-Addr from sock_pkg and forwards it to the ghdlserver\n--------------------------------------------------------------------------------" +comment_vhdl+="--------------------------------------------------------------------------------\n--Modified by Rahul Paknikar, FOSSEE, IIT Bombay\n" +comment_vhdl+="--retrieves the IP-Addr from sock_pkg and forwards it to the ghdlserver\n--------------------------------------------------------------------------------\n" #Adding header, entity and architecture statement tb_header=''' library ieee; -- cgit From d472bf02bbb957dafa1227277b0421f52c9d7375 Mon Sep 17 00:00:00 2001 From: rahul Date: Tue, 22 Oct 2019 11:28:44 +0530 Subject: Multiple models for each instance --- src/model_generation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/model_generation.py') diff --git a/src/model_generation.py b/src/model_generation.py index 3df4676..9615f8e 100644 --- a/src/model_generation.py +++ b/src/model_generation.py @@ -241,7 +241,10 @@ client_setup_ip=''' int ip_count = 0; char* my_ip = malloc(16); - fptr = fopen("/tmp/NGHDL_COMMON_IP.txt", "r"); + char ip_filename[40]; + sprintf(ip_filename, "/tmp/NGHDL_COMMON_IP_%d.txt", getpid()); + + fptr = fopen(ip_filename, "r"); if (fptr) { char line[20]; @@ -258,7 +261,7 @@ client_setup_ip=''' sprintf(my_ip, "127.0.%d.1", (ip_count+1)%256); } - fptr = fopen("/tmp/NGHDL_COMMON_IP.txt", "a"); + fptr = fopen(ip_filename, "a"); if (fptr) { fprintf(fptr, "%s\\n", my_ip); -- cgit From 68d0a7a3ebea687906d97d6e660a975540de968b Mon Sep 17 00:00:00 2001 From: rahul Date: Fri, 8 Nov 2019 16:32:46 +0530 Subject: close client socket at that instance --- src/model_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/model_generation.py') diff --git a/src/model_generation.py b/src/model_generation.py index 9615f8e..a9fda65 100644 --- a/src/model_generation.py +++ b/src/model_generation.py @@ -470,9 +470,9 @@ els_time_limit=''' fprintf(log_client,"Socket Id : %d & Message sent : %s for END signal \\n",socket_fd,send_data); } flag++; - close(socket_fd); } + close(socket_fd); ''' -- cgit From 613f5460afb2be89262ed19ef5f90fa3604bd368 Mon Sep 17 00:00:00 2001 From: rahul Date: Mon, 11 Nov 2019 11:45:14 +0530 Subject: modified cfunc --- src/model_generation.py | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src/model_generation.py') diff --git a/src/model_generation.py b/src/model_generation.py index a9fda65..dffd690 100644 --- a/src/model_generation.py +++ b/src/model_generation.py @@ -213,7 +213,7 @@ systime_info=''' time_t systime; systime = time(NULL); printf(ctime(&systime)); - printf("Client-Initialising ngspice \\n"); + printf("Client-Initialising GHDL..."); fprintf(log_client,"Setup Client Server Connection at %s \\n",ctime(&systime)); ''' @@ -280,34 +280,34 @@ client_fetch_ip=''' char* my_ip = STATIC_VAR(my_ip); host = gethostbyname(my_ip); - printf("Client-Creating Client Socket \\n"); - fprintf(log_client,"Creating client socket \\n"); + printf("\\n\\nClient-Creating Socket \\n"); + fprintf(log_client,"Creating client socket \\n"); ''' create_socket=''' - //Creating socket for client - if ((socket_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) - { - perror("Client-Error while creating client Socket \\n"); - fprintf(log_client,"Error while creating client sockte \\n"); - exit(1); - } - - printf("Client-Client Socket created successfully \\n"); - printf("Client- Socket Id : %d \\n",socket_fd); - fprintf(log_client,"Client-Client Socket created successfully \\n"); - fprintf(log_client,"Client- Socket Id : %d \\n",socket_fd); - - // memset(&server_addr, 0, sizeof(server_addr)); - server_addr.sin_family = AF_INET; - server_addr.sin_port = htons(sock_port); - server_addr.sin_addr = *((struct in_addr *)host->h_addr); - bzero(&(server_addr.sin_zero),8); + //Creating socket for client + if ((socket_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) + { + perror("Client-Error while creating client Socket \\n"); + fprintf(log_client,"Error while creating client socket \\n"); + exit(1); + } + + printf("Client-Client Socket created successfully \\n"); + printf("Client- Socket Id : %d \\n",socket_fd); + fprintf(log_client,"Client-Client Socket created successfully \\n"); + fprintf(log_client,"Client- Socket Id : %d \\n",socket_fd); + + // memset(&server_addr, 0, sizeof(server_addr)); + server_addr.sin_family = AF_INET; + server_addr.sin_port = htons(sock_port); + server_addr.sin_addr = *((struct in_addr *)host->h_addr); + bzero(&(server_addr.sin_zero),8); ''' connect_server=''' - printf("Client-Connecting to server \\n"); + printf("Client-Connecting to server \\n"); fprintf(log_client,"Client-Connecting to server \\n"); //Conneting to server -- cgit