diff --git a/firmware/rtl/control_loop/control_loop.v b/firmware/rtl/control_loop/control_loop.v index 7ed3ce9..4518447 100644 --- a/firmware/rtl/control_loop/control_loop.v +++ b/firmware/rtl/control_loop/control_loop.v @@ -1,10 +1,3 @@ -/* TODO: The control loop outputs the adjustment value, not the - * total value to the DAC. Write code that gets the value from - * the DAC and writes the adjusted value to it. - * - * This can be in another module which only gets the value from - * the DAC on reset. - */ /************ Introduction to PI Controllers * The continuous form of a PI loop is * @@ -126,11 +119,8 @@ module control_loop * ERR_WID (ADC_WID + 1). */ parameter ERR_WID_SIZ = 6, - parameter ADC_POLARITY = 1, - parameter ADC_PHASE = 0, - parameter DAC_POLARITY = 0, - parameter DAC_PHASE = 1, - parameter DATA_WID = CONSTS_WID + parameter DATA_WID = CONSTS_WID, + parameter READ_DAC_DELAY = 5 ) ( input clk, @@ -139,7 +129,7 @@ module control_loop output adc_arm, input adc_finished, - output signed [DAC_WID-1:0] to_dac, + output reg signed [DAC_WID-1:0] to_dac, input signed [DAC_WID-1:0] from_dac, output dac_ss, output dac_arm, @@ -164,9 +154,21 @@ reg signed [ERR_WID-1:0] err_prev = 0; /****** State machine * - * -> CYCLE_START -> WAIT_ON_ADC -> WAIT_ON_MUL -\ - * \------\------------ WAIT_ON_DAC