Skip to content

Commit 9d04161

Browse files
committed
fix:Registers updates fetching
1 parent b411b2e commit 9d04161

File tree

3 files changed

+165
-5
lines changed

3 files changed

+165
-5
lines changed

demo/pipelined/pipeline-data.js

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,71 @@ const pipelineData = {
704704
"mem_to_reg": false,
705705
"mem_write": false,
706706
"alu_src": false,
707-
"reg_write": false
707+
"reg_write": false,
708+
"x0": 0,
709+
"x1": 0,
710+
"x2": 13,
711+
"x3": 0,
712+
"x4": 0,
713+
"x5": 0,
714+
"x6": 0,
715+
"x7": 0,
716+
"x8": 0,
717+
"x9": 0,
718+
"x10": 0,
719+
"x11": 0,
720+
"x12": 0,
721+
"x13": 0,
722+
"x14": 0,
723+
"x15": 0,
724+
"x16": 0,
725+
"x17": 0,
726+
"x18": 0,
727+
"x19": 0,
728+
"x20": 0,
729+
"x21": 0,
730+
"x22": 0,
731+
"x23": 0,
732+
"x24": 0,
733+
"x25": 0,
734+
"x26": 0,
735+
"x27": 0,
736+
"x28": 0,
737+
"x29": 0,
738+
"x30": 0,
739+
"x31": 0,
740+
"mem_0": 5,
741+
"mem_1": 0,
742+
"mem_2": 0,
743+
"mem_3": 0,
744+
"mem_4": 0,
745+
"mem_5": 0,
746+
"mem_6": 0,
747+
"mem_7": 0,
748+
"mem_8": 0,
749+
"mem_9": 0,
750+
"mem_10": 0,
751+
"mem_11": 0,
752+
"mem_12": 0,
753+
"mem_13": 0,
754+
"mem_14": 0,
755+
"mem_15": 0,
756+
"mem_16": 0,
757+
"mem_17": 0,
758+
"mem_18": 0,
759+
"mem_19": 0,
760+
"mem_20": 0,
761+
"mem_21": 0,
762+
"mem_22": 0,
763+
"mem_23": 0,
764+
"mem_24": 0,
765+
"mem_25": 0,
766+
"mem_26": 0,
767+
"mem_27": 0,
768+
"mem_28": 0,
769+
"mem_29": 0,
770+
"mem_30": 0,
771+
"mem_31": 0
708772
}
709773
]
710-
};
774+
};

pipelined/visualization/parse-pipeline.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def parse_pipeline_output(file_path):
99
cycles = []
1010
cycle_blocks = content.split("--------------------------------")
1111

12+
# Parse the cycle-by-cycle data
1213
for block in cycle_blocks:
1314
if "Time=" not in block:
1415
continue
@@ -187,10 +188,41 @@ def parse_pipeline_output(file_path):
187188
cycle_data["flush_occurred"] = True
188189
cycle_data["pipeline_recovery"] = True
189190

190-
191-
191+
192192
cycles.append(cycle_data)
193193

194+
# Parse final register and memory state
195+
final_registers = {}
196+
final_memory = {}
197+
198+
# Extract final register values
199+
reg_section = re.search(r"Register file contents:(.*?)Memory contents:", content, re.DOTALL)
200+
if reg_section:
201+
reg_content = reg_section.group(1)
202+
reg_matches = re.findall(r"x(\d+) = (-?\d+)", reg_content)
203+
for match in reg_matches:
204+
reg_num = int(match[0])
205+
reg_value = int(match[1])
206+
final_registers[f"x{reg_num}"] = reg_value
207+
208+
# Extract final memory values
209+
mem_section = re.search(r"Memory contents:(.*?)Data memory contents written", content, re.DOTALL)
210+
if mem_section:
211+
mem_content = mem_section.group(1)
212+
mem_matches = re.findall(r"mem\[(\d+)\] = (-?\d+)", mem_content)
213+
for match in mem_matches:
214+
mem_addr = int(match[0])
215+
mem_value = int(match[1])
216+
final_memory[f"mem_{mem_addr}"] = mem_value
217+
218+
# Add the final register and memory values to the last cycle
219+
if cycles and final_registers:
220+
for reg_name, reg_value in final_registers.items():
221+
cycles[-1][reg_name] = reg_value
222+
223+
if cycles and final_memory:
224+
for mem_name, mem_value in final_memory.items():
225+
cycles[-1][mem_name] = mem_value
194226

195227
return {"cycles": cycles}
196228

pipelined/visualization/pipeline-data.js

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,71 @@ const pipelineData = {
704704
"mem_to_reg": false,
705705
"mem_write": false,
706706
"alu_src": false,
707-
"reg_write": false
707+
"reg_write": false,
708+
"x0": 0,
709+
"x1": 0,
710+
"x2": 13,
711+
"x3": 0,
712+
"x4": 0,
713+
"x5": 0,
714+
"x6": 0,
715+
"x7": 0,
716+
"x8": 0,
717+
"x9": 0,
718+
"x10": 0,
719+
"x11": 0,
720+
"x12": 0,
721+
"x13": 0,
722+
"x14": 0,
723+
"x15": 0,
724+
"x16": 0,
725+
"x17": 0,
726+
"x18": 0,
727+
"x19": 0,
728+
"x20": 0,
729+
"x21": 0,
730+
"x22": 0,
731+
"x23": 0,
732+
"x24": 0,
733+
"x25": 0,
734+
"x26": 0,
735+
"x27": 0,
736+
"x28": 0,
737+
"x29": 0,
738+
"x30": 0,
739+
"x31": 0,
740+
"mem_0": 5,
741+
"mem_1": 0,
742+
"mem_2": 0,
743+
"mem_3": 0,
744+
"mem_4": 0,
745+
"mem_5": 0,
746+
"mem_6": 0,
747+
"mem_7": 0,
748+
"mem_8": 0,
749+
"mem_9": 0,
750+
"mem_10": 0,
751+
"mem_11": 0,
752+
"mem_12": 0,
753+
"mem_13": 0,
754+
"mem_14": 0,
755+
"mem_15": 0,
756+
"mem_16": 0,
757+
"mem_17": 0,
758+
"mem_18": 0,
759+
"mem_19": 0,
760+
"mem_20": 0,
761+
"mem_21": 0,
762+
"mem_22": 0,
763+
"mem_23": 0,
764+
"mem_24": 0,
765+
"mem_25": 0,
766+
"mem_26": 0,
767+
"mem_27": 0,
768+
"mem_28": 0,
769+
"mem_29": 0,
770+
"mem_30": 0,
771+
"mem_31": 0
708772
}
709773
]
710774
};

0 commit comments

Comments
 (0)