diff options
Diffstat (limited to 'src/maker')
-rwxr-xr-x | src/maker/ModelGeneration.py | 8 | ||||
-rwxr-xr-x | src/maker/NgVeri.py | 23 | ||||
-rw-r--r-- | src/maker/createkicad.py | 17 |
3 files changed, 34 insertions, 14 deletions
diff --git a/src/maker/ModelGeneration.py b/src/maker/ModelGeneration.py index 7dce1de7..f6afd5c0 100755 --- a/src/maker/ModelGeneration.py +++ b/src/maker/ModelGeneration.py @@ -167,6 +167,12 @@ class ModelGeneration(QtWidgets.QWidget): code = code.replace("wire", " ") code = code.replace("reg", " ") + + header_re = re.compile(r'module\s+\w+\s*\((.*?)\)\s*;', re.S) + def _split_ports(match): + # add a newline after every comma that is inside the header + return match.group(0).replace(',', ',\n') + code = header_re.sub(_split_ports, code) vlog_ex = vlog.VerilogExtractor() vlog_mods = vlog_ex.extract_objects_from_source(code) f = open(self.modelpath + "connection_info.txt", 'w') @@ -718,7 +724,7 @@ and set the load for input ports */ int foo_''' + self.fname.split('.')[0] + '''(int init,int count) { int argc=1; - char* argv[]={"fullverbose"}; + const char* argv[]={"fullverbose"}; Verilated::commandArgs(argc, argv); static VerilatedContext* contextp = new VerilatedContext; static V''' + self.fname.split('.')[0] + "* " + \ diff --git a/src/maker/NgVeri.py b/src/maker/NgVeri.py index c5756e7d..1678248f 100755 --- a/src/maker/NgVeri.py +++ b/src/maker/NgVeri.py @@ -338,14 +338,21 @@ class NgVeri(QtWidgets.QWidget): QtWidgets.QMessageBox.Cancel) if ret == QtWidgets.QMessageBox.Ok: - file = open(init_path + "library/tlv/lint_off.txt", 'r') - data = file.readlines() - file.close() - - data.remove(text + "\n") - file = open(init_path + "library/tlv/lint_off.txt", 'w') - for item in data: - file.write(item) + try: + file_path = os.path.join(init_path, "library/tlv/lint_off.txt") + with open(file_path, 'r') as file: + data = file.readlines() + data = [line for line in data if line.strip() != text] + with open(file_path, 'w') as file: + file.writelines(data) + + except Exception as e: + QtWidgets.QMessageBox.warning( + None, + "Warning", + f"Could not remove lint_off entry '{text}'", + QtWidgets.QMessageBox.Ok + ) def add_lint_off(self): ''' diff --git a/src/maker/createkicad.py b/src/maker/createkicad.py index 3f30e835..ccc19719 100644 --- a/src/maker/createkicad.py +++ b/src/maker/createkicad.py @@ -189,9 +189,14 @@ class AutoSchematic: def createSym(self): ''' creating the symbol + (pins snapped to KiCad-6 grid) ''' - self.dist_port = 2.54 # Distance between two ports (mil) - self.inc_size = 2.54 # Increment size of a block (mil) + self.grid = 0.635 + self.dist_port = 4 * self.grid # Distance between two ports # 100 mil (= 2.54 mm) + self.inc_size = self.dist_port # Increment size of a block (mil) + def snap(val): + snapped = round(float(val) / self.grid) * self.grid + return f"{snapped:.3f}" cwd = os.getcwd() os.chdir(self.lib_loc) print("Changing directory to ", self.lib_loc) @@ -250,7 +255,7 @@ class AutoSchematic: draw_pos = \ [w.replace('comp_name', f"{self.modelname}_0_1") for w in draw_pos] - draw_pos[8] = str(float(draw_pos[8]) + # previously it is (-) + draw_pos[8] = snap(float(draw_pos[8]) + # previously it is (-) float(self.findBlockSize() * self.inc_size)) draw_pos_rec = draw_pos[8] @@ -265,6 +270,8 @@ class AutoSchematic: input_port = input_port.split() output_port = self.template["output_port"] output_port = output_port.split() + input_port[3] = snap(float(input_port[3])) + output_port[3] = snap(float(output_port[3])) inputs = self.portInfo[0: self.input_length] outputs = self.portInfo[self.input_length:] inputName = [] @@ -298,7 +305,7 @@ class AutoSchematic: input_port[9] = f"\"{inputName[i]}\"" input_port[13] = f"\"{str(i + 1)}\"" input_port[4] = \ - str(float(input_port[4]) - float(self.dist_port)) + snap(float(input_port[4]) - float(self.dist_port)) input_list = ' '.join(input_port) port_list.append(input_list) j = j + 1 @@ -307,7 +314,7 @@ class AutoSchematic: output_port[9] = f"\"{outputName[i - inputs]}\"" output_port[13] = f"\"{str(i + 1)}\"" output_port[4] = \ - str(float(output_port[4]) - float(self.dist_port)) + snap(float(output_port[4]) - float(self.dist_port)) output_list = ' '.join(output_port) port_list.append(output_list) |