fix: synthesis bugs, arbitration race conditions, and scheduler logic #48
+59
−47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements critical fixes to the src directory to resolve synthesis failures, eliminate race conditions, and correct logic bugs that were preventing proper GPU instruction execution. The changes ensure the design adheres to standard SystemVerilog structural modeling rules and produces deterministic hardware.
Controller Arbitration Fix (
src/controller.sv
)
Issue: The previous arbitration logic used blocking assignments inside a sequential loop (channel_serving_consumer[j] = 1), causing "Multiple Driver" errors during synthesis where multiple channels could try to write to the same register bit in the same cycle.
Fix: Refactored the logic to use a combinatorial next_state variable pattern. Arbitration allows only one consumer-to-channel mapping per cycle, and the state register is updated strictly at the end of the clock edge.
Scheduler Stall & Logic Fixes (
src/scheduler.sv
)
Critical Fix: The PC update logic previously relied on next_pc[THREADS_PER_BLOCK-1]. In blocks with fewer than maximum threads (e.g., partial blocks), the last thread is inactive, causing the core to read a zero/invalid PC. The logic now uses Thread 0 (next_pc[0]), which is guaranteed to be active for any valid block.
Logic Fix: Fixed any_lsu_waiting being declared as a static variable inside an always block. It is now a proper temporary logic variable that resets every cycle.
Syntax: Removed an invalid trailing comma in the parameter list.
Core Structural Corrections (
src/core.sv
)
Issue: Internal signals driven by submodule output ports (like instruction, rs, rt) were declared as reg. This violates strict Verilog structural modeling.
Fix: Converted all such internal signals to wire to match their structural connections.
Deterministic Dispatch (
src/dispatch.sv
)
Fix: Replaced mixed blocking (=) and non-blocking (<=) assignments with consistent non-blocking assignments for state variables (blocks_dispatched, blocks_done) to ensure deterministic sequential behavior.
Syntax & Typos
src/dcr.sv
: Fixed variable name typo device_conrol_register → device_control_register. Removed trailing comma in port list.
src/gpu.sv
: Removed invalid trailing comma in core module instantiation.