Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
# Update instruction counts
s.num_total_inst += 1
if s.isa.stats_en:
s.num_inst += 1
# Set trace string in case the fetch yields
s.trace = " "*29
# Fetch instruction
s.pc = s.isa.PC.uint()
s.inst = PisaInst( s.imem[ s.pc : s.pc+4 ] )
# Set trace string in case the execution function yeilds
s.trace = "#".ljust(29)
# Execute instruction
s.isa.execute( s.inst )
# Ensure that the stats_en and status ports are current
if not s.test_en:
s.stats_en.next = s.isa.stats_en
s.status.next = s.isa.status
# Trace instruction
if s.ifetch_wait > 0:
s.trace_X = "~w{}".format(s.ifetch_wait).ljust(29)
if not s.imemresp_q.empty():
inst = PisaInst(s.imemresp_q.first())
s.ifetch_wait -= 1
s.trace_X = "~w{}".format(s.ifetch_wait).ljust(29)
s.imemresp_q.deq()
elif not s.pc_queue_FX.empty() \
and not s.imemresp_q.empty() \
and not s.inst_queue_XW.full() \
and not s.wb_queue_XW.full():
s.stall_X = False
inst = PisaInst(s.imemresp_q.first())
s.execute_dispatch[inst.name]( s, inst )
if not s.stall_X:
if not s.pc_queue_FX.empty():
s.pc_queue_FX.deq()
s.imemresp_q.deq()
s.inst_queue_XW.enq( inst )
s.trace_X = str(inst).ljust(29)
else:
s.trace_X = ( "#" + s.stall_type_X ).ljust(29)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# F: Fetch Pipeline Stage
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
s.trace_F = " ".ljust(8)
if not s.stall_W:
s.inst_queue_XW.deq()
s.wb_queue_XW.deq()
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# X: Execute Pipeline Stage
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
s.trace_X = " "*29
if s.ifetch_wait > 0:
s.trace_X = "~w{}".format(s.ifetch_wait).ljust(29)
if not s.imemresp_q.empty():
inst = PisaInst(s.imemresp_q.first())
s.ifetch_wait -= 1
s.trace_X = "~w{}".format(s.ifetch_wait).ljust(29)
s.imemresp_q.deq()
elif not s.pc_queue_FX.empty() \
and not s.imemresp_q.empty() \
and not s.inst_queue_XW.full() \
and not s.wb_queue_XW.full():
s.stall_X = False
inst = PisaInst(s.imemresp_q.first())
s.execute_dispatch[inst.name]( s, inst )
if not s.stall_X:
if not s.pc_queue_FX.empty():
s.pc_queue_FX.deq()