Hiya...
I'm using Altera Quartus II, Pluto II (see fpga4fun.com, its one of their boards - GREAT site! - it's an Altera Cyclone), Verilog, you know the deal ;)
I'm trying to integrate all my modules (for the purposes of this I have a compass module, which reads a direction over I2C, and a motor controller - PWM, reversible).
These are held within a module called 'scanner'.
Snippet'ed code in question:
-----------------start of code--------------
input clk; input clk100khz; output hwSonarTrigger; input hwFrontEcho; input hwRearEcho; inout hwCompassSCL; inout hwCompassSDA; output hwSpinA; output hwSpinB; output [1:0] state; // for debugging purposes
// ...snip...
wire [7:0] compassDirection; wire compassDirectionUpdated;
reg [7:0] spinSpeed; reg spinDirection; reg spinEnabled;
// ...snip...
reg [7:0] baseCompassDirection;
wire [7:0] clockwiseDistance = baseCompassDirection - compassDirection; wire [1:0] antiClockwiseDistance = compassDirection - baseCompassDirection;
reg [1:0] state = 0;
// basic operation: // state 0 initialises, resets, forwards to state 1 // state 1 waits until a compass direction has been obtained, records the direction in baseCompassDirection, and moves into state 2 // state 2 compares the stored compass direction against the measured, and sets the motor controller to correct for movement
always @(posedge clk) begin if ( state == 0 ) begin spinEnabled