diff options
author | Sumanto Kar | 2025-05-30 18:51:24 +0530 |
---|---|---|
committer | GitHub | 2025-05-30 18:51:24 +0530 |
commit | 14fe57b50273e1991ecbff070a980206ab1a1db7 (patch) | |
tree | 5217503e0adb242218f2d2878da86460f117173d | |
parent | d186a100dffba2477342fa44f885ea541c1284bb (diff) | |
parent | 25feefbe5463215cdd5c5f9dbd56d869fa7d21c1 (diff) | |
download | eSim-14fe57b50273e1991ecbff070a980206ab1a1db7.tar.gz eSim-14fe57b50273e1991ecbff070a980206ab1a1db7.tar.bz2 eSim-14fe57b50273e1991ecbff070a980206ab1a1db7.zip |
Merge pull request #345 from VaradhaCodes/fix-kicad-grid
Fix pin misalignment in Verilog-generated KiCad symbols in eSim 2.4
-rw-r--r-- | src/maker/createkicad.py | 17 |
1 files changed, 12 insertions, 5 deletions
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) |