Skip to content

Commit bd2321e

Browse files
committed
Fixed DSLX issues
1 parent 8fa23b3 commit bd2321e

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

hdlagent/agent.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ def get_verilog_file_name(original_file_name):
952952
elif '.pyrtl' in file_name_str:
953953
return file_name_str.replace('.pyrtl', '.v')
954954
elif '.x' in file_name_str:
955-
return file_name_str.replace('.dslx', '.v')
955+
return file_name_str.replace('.x', '.v')
956956
else:
957957
return file_name_str
958958

@@ -1211,7 +1211,8 @@ def lec_loop(self, prompt: str, compiled: bool = False, lec_iterations: int = 1,
12111211
for i in range(lec_iterations):
12121212
if update and len(self.compile_conversation) == 0:
12131213
if self.test_code_compile() is None:
1214-
self.verilog = self.code # Ensure self.verilog is set
1214+
# self.verilog = self.code # Ensure self.verilog is set
1215+
self.verilog = Agent.get_verilog_file_name(self.code)
12151216
gold, gate = self.reformat_verilog(self.name, self.gold, self.verilog, self.io)
12161217
lec_out = self.test_lec(gold, gate, lec_feedback_limit)
12171218
print("LEC is done Now in update!!!!!!")
@@ -1227,7 +1228,8 @@ def lec_loop(self, prompt: str, compiled: bool = False, lec_iterations: int = 1,
12271228
print("[DEBUG] LEC passed during update.")
12281229
return self.finish_run()
12291230

1230-
self.verilog = self.code # Ensure self.verilog is set
1231+
# self.verilog = self.code # Ensure self.verilog is set
1232+
self.verilog = Agent.get_verilog_file_name(self.code)
12311233
gold, gate = self.reformat_verilog(self.name, self.gold, self.verilog, self.io)
12321234
lec_out = self.test_lec(gold, gate, lec_feedback_limit)
12331235
print("LEC is done Now!!!!!!")

hdlagent/resources/DSLX/DSLX_agent.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ def custom_reformat_verilog(name: str, ref_file: str, in_file: str, io_list):
1010
outputs = []
1111
inputs = []
1212

13+
print(f"[DEBUG] custom_reformat_verilog called with:")
14+
print(f" name: {name}")
15+
print(f" ref_file: {ref_file}")
16+
print(f" in_file: {in_file}")
17+
print(f" io_list: {io_list}")
18+
1319
for io in io_list:
1420
#print(io)
1521
if io[0] == "output":
@@ -30,19 +36,29 @@ def custom_reformat_verilog(name: str, ref_file: str, in_file: str, io_list):
3036
# if input_name != in_file_input_name:
3137
# in_file_content = in_file_content.replace()
3238

39+
# Debug: Show original content
40+
print(f"[DEBUG] Original Verilog content:\n{in_file_content}\n{'-'*50}")
41+
3342
if len(outputs) == 1:
3443
output_name = outputs[0][3]
35-
# Rename all lines that may have the output_name as a local wire
36-
in_file_content = in_file_content.replace(f"{output_name}\n", f"{output_name}_w\n")
37-
in_file_content = in_file_content.replace(f"{output_name};", f"{output_name}_w;")
38-
in_file_content = in_file_content.replace("{" + output_name + "};", "{" + output_name + "_w};")
39-
in_file_content = in_file_content.replace(f" {output_name} ", f" {output_name}_w ")
40-
in_file_content = in_file_content.replace(f"({output_name});", f"({output_name}_w);")
41-
# Rename output as desired output_name
42-
in_file_content = in_file_content.replace("out\n", output_name + "\n")
43-
in_file_content = in_file_content.replace("out;", output_name + ";")
44-
in_file_content = in_file_content.replace(" out ", " " + output_name + " ")
45-
in_file_content = in_file_content.replace("(out);", "(" + output_name + ");")
44+
# Rename internal wires that might conflict with the output name
45+
in_file_content = in_file_content.replace(f'wire [63:0] {output_name};', f'wire [63:0] {output_name}_w;')
46+
in_file_content = in_file_content.replace(f'assign {output_name} =', f'assign {output_name}_w =')
47+
# Replace 'out' with the correct output name
48+
pattern = r'\bout\b'
49+
in_file_content = re.sub(pattern, output_name, in_file_content)
50+
51+
# # Rename all lines that may have the output_name as a local wire
52+
# in_file_content = in_file_content.replace(f"{output_name}\n", f"{output_name}_w\n")
53+
# in_file_content = in_file_content.replace(f"{output_name};", f"{output_name}_w;")
54+
# in_file_content = in_file_content.replace("{" + output_name + "};", "{" + output_name + "_w};")
55+
# in_file_content = in_file_content.replace(f" {output_name} ", f" {output_name}_w ")
56+
# in_file_content = in_file_content.replace(f"({output_name});", f"({output_name}_w);")
57+
# # Rename output as desired output_name
58+
# in_file_content = in_file_content.replace("out\n", output_name + "\n")
59+
# in_file_content = in_file_content.replace("out;", output_name + ";")
60+
# in_file_content = in_file_content.replace(" out ", " " + output_name + " ")
61+
# in_file_content = in_file_content.replace("(out);", "(" + output_name + ");")
4662
else:
4763
# Replace modules header 'out' with outputs directly
4864
output_declarations = ""

0 commit comments

Comments
 (0)