Verilog,不能分配多个值

Verilog,不能分配多个值,verilog,Verilog,我是Verilog新手,我正在尝试制作一个CPLD加电保护逻辑,它实际上使用了一组定时器来验证状态机。我有一个带有1Mhz OSC的CPLD,我正在尝试制作一个15s定时器,我计算代码,但它有编译错误,说“不能分配多个值”。我知道这意味着信号网络由两个不同的信号控制,但它有一条错误线显示 错误(12014):扇出到“计时器[0]”的净“五十秒设备时钟输入”不能分配多个值 错误(12015):网络由“clk_div:d | clk_out”馈送 错误(12015):网络由“五十秒设备时钟输入”馈电

我是Verilog新手,我正在尝试制作一个CPLD加电保护逻辑,它实际上使用了一组定时器来验证状态机。我有一个带有1Mhz OSC的CPLD,我正在尝试制作一个15s定时器,我计算代码,但它有编译错误,说“不能分配多个值”。我知道这意味着信号网络由两个不同的信号控制,但它有一条错误线显示

错误(12014):扇出到“计时器[0]”的净“五十秒设备时钟输入”不能分配多个值 错误(12015):网络由“clk_div:d | clk_out”馈送 错误(12015):网络由“五十秒设备时钟输入”馈电

为什么“五十秒设备时钟输入”连接到自身??

  module PowerUpProtection(

    //---------------------------------------------------------------------------
    // Inputs
    //---------------------------------------------------------------------------
    input wire Fifty_m_second_Devide_Clock_input,
    input wire Clock,
    input wire Reset,
    input wire Input1_Check_precharge_status,
    input wire Input2_MainPowerSwitch_relay_status_Check,
    input wire Input3_powerUp_validation,

    //---------------------------------------------------------------------------

    //---------------------------------------------------------------------------
    // Outputs
    //---------------------------------------------------------------------------
    output reg Output1_Relay_Swtich_For_Main_PowerSource,
    output reg Output2_Switch_On_and_Charge_CAP,
    output reg Output3_Switch_On_and_power_SoM,
    output reg Output4_Press_and_hold_the_powerSource,
    output reg Output5_Switch_on_relay_when_CPLD_powerup
    //---------------------------------------------------------------------------
    );


    // this is a Module Instantiation, connect the inputs and output from different module within CPLD.
    clk_div d(
        .Clock  (Clock),
        .reset(Reset),
        .clk_out(Fifty_m_second_Devide_Clock_input)
    );
    //---------------------------------------------------------------------------


    //---------------------------------------------------------------------------
    // State Encoding 
    //---------------------------------------------------------------------------
    localparam STATE_0_Initial = 4'd0,
                  STATE_1_Press_and_hold = 4'd1,
                  STATE_2_Power_up = 4'd2,
                  STATE_3_Check_Switches = 4'd3,
                 STATE_4_SwtichSafe_StartPreCharging = 4'd4,
                  STATE_5_ERROR = 4'd5,
                  STATE_6_CAP_is_Charging = 4'd6,
                  STATE_7_Charging_End_SwitchOn_MainPower = 4'd7,
                  STATE_8_PowerSupply_Ready = 4'd8,
                  ERROR_9_TIME_OUT = 4'd9,
                  STATE_10_Precharge_Switch_is_broken = 4'd10,
                  STATE_11_Main_power_switch_is_broken = 4'd11,
                  STATE_12_Both_switches_are_broken = 4'd12,
                  STATE_13_PlaceHolder = 4'd13,
                  STATE_14_PlaceHolder = 4'd14,
                  STATE_15_PlaceHolder = 4'd15;       
    //---------------------------------------------------------------------------



    //---------------------------------------------------------------------------
    // State reg Declarations
    //---------------------------------------------------------------------------
    reg [3:0] CurrentState = 4'd0;
    reg [3:0] NextState = 4'd0;
    //---------------------------------------------------------------------------



    //---------------------------------------------------------------------------
    // Timer reg Declarations
    //---------------------------------------------------------------------------
    reg [8:0] Timer = 0;
    reg enable_the_counter = 0;  // the boolean to enbale the counter.
    reg clear_the_counter = 0;

    //---------------------------------------------------------------------------   

    //---------------------------------------------------------------------------
    // Outputs
    //---------------------------------------------------------------------------   
    always@(*) begin
        // clear for the initial state.
        reg Output1_Relay_Swtich_For_Main_PowerSource = 0;
        reg Output2_Switch_On_and_Charge_CAP = 0;
        reg Output3_Switch_On_and_power_SoM = 0;
        reg Output4_Press_and_hold_the_powerSource = 0;
        reg Output5_Switch_on_relay_when_CPLD_powerup = 0;

        case (CurrentState)
            STATE_1_Press_and_hold : begin
                Output4_Press_and_hold_the_powerSource = 1;
            end

            STATE_2_Power_up        : begin
                Output5_Switch_on_relay_when_CPLD_powerup = 1;
            end

            STATE_3_Check_Switches   : begin
                Output2_Switch_On_and_Charge_CAP = 1;
            end 

            STATE_4_SwtichSafe_StartPreCharging : begin
                Output2_Switch_On_and_Charge_CAP = 1;
            end

            STATE_5_ERROR : begin
                // to be determined
            end

            STATE_6_CAP_is_Charging :  begin 
                // wait for the charging to be complete
            end

            STATE_7_Charging_End_SwitchOn_MainPower : begin
                Output1_Relay_Swtich_For_Main_PowerSource =1;
            end

            STATE_8_PowerSupply_Ready : begin
                Output5_Switch_on_relay_when_CPLD_powerup = 0;
                Output3_Switch_On_and_power_SoM = 1;
            end
        endcase
    end
    //---------------------------------------------------------------------------   



    //---------------------------------------------------------------------------
    // Synchronous State-Transition always@(posedge Clock) block
    //---------------------------------------------------------------------------
    always@(posedge Clock) begin
        if (Reset) CurrentState <= STATE_0_Initial;
        else CurrentState <= NextState;
    end
    //---------------------------------------------------------------------------


    //---------------------------------------------------------------------------
    // conditional State-Trasnsition Always@(*) block
    //---------------------------------------------------------------------------
    always@(*) begin
        NextState = CurrentState;
        case (CurrentState)

            STATE_0_Initial :begin
                NextState = STATE_1_Press_and_hold;
            end

            STATE_1_Press_and_hold : begin
                if (Input3_powerUp_validation) NextState = STATE_2_Power_up;
            end

            STATE_2_Power_up : begin
                if (Input3_powerUp_validation) NextState = STATE_3_Check_Switches;
            end

            STATE_3_Check_Switches : begin 
                if (Input1_Check_precharge_status == 0 && Input2_MainPowerSwitch_relay_status_Check == 1 )
                    begin
                    NextState = STATE_4_SwtichSafe_StartPreCharging;
                    enable_the_counter = 1; //Start to count the time.
                    end

                else if (Input1_Check_precharge_status == 1 && Input2_MainPowerSwitch_relay_status_Check == 1)
                    begin
                    NextState = STATE_10_Precharge_Switch_is_broken;
                    end

                else if (Input1_Check_precharge_status == 0 && Input2_MainPowerSwitch_relay_status_Check == 0)
                    begin
                    NextState = STATE_11_Main_power_switch_is_broken;
                    end

                else
                    begin 
                    NextState = STATE_12_Both_switches_are_broken;
                    end

            end

            STATE_4_SwtichSafe_StartPreCharging : begin

                if (Input1_Check_precharge_status == 1 && Timer <= 300) //equals to 15 seconds
                    NextState = STATE_6_CAP_is_Charging;

                else if (Timer > 300)
                    NextState = STATE_5_ERROR;  //Time out Error
                    clear_the_counter = 1;
                    enable_the_counter = 0;
            end

            STATE_6_CAP_is_Charging : begin

                if (Input1_Check_precharge_status == 0 && Timer <= 300) 
                    begin
                        NextState = STATE_7_Charging_End_SwitchOn_MainPower;
                        clear_the_counter = 1; // timer is over, clear the  counter.
                        enable_the_counter =0;
                    end
                else if (Timer > 300)
                    begin
                        NextState = STATE_5_ERROR;  //Time out Error
                        clear_the_counter = 1;
                        enable_the_counter = 0;
                    end
            end 

            STATE_7_Charging_End_SwitchOn_MainPower : begin

                //enable the counter again, and count for 50 m seconds.
                enable_the_counter = 1;
                if (Input2_MainPowerSwitch_relay_status_Check ==1)
                        begin
                        if (Timer <=1)
                            NextState = STATE_7_Charging_End_SwitchOn_MainPower; // if time is not 50 ms yet, go back to itself current  state
                        else
                            NextState = STATE_5_ERROR;  //Time out Error
                            clear_the_counter = 1;
                            enable_the_counter = 0;
                        end
                else if (Input2_MainPowerSwitch_relay_status_Check == 0)  // if the switch is ready right away, that is best.

                        begin
                        NextState = STATE_8_PowerSupply_Ready; 
                        end
                else 
                        NextState = STATE_5_ERROR;  //Time out Error
                        clear_the_counter = 1;
                        enable_the_counter = 0;
            end

            //---------------------------------------------------------------------------
            // Place-Holder transition.
            //---------------------------------------------------------------------------
            STATE_13_PlaceHolder : begin
                NextState = STATE_5_ERROR;
            end

            STATE_14_PlaceHolder : begin
                NextState = STATE_5_ERROR;
            end
            STATE_15_PlaceHolder : begin
                NextState = STATE_5_ERROR;
            end


        endcase
    end 

    //---------------------------------------------------------------------------
    // 50 m Seconds counter block, make the osc into 20 HZ by implement the counter
    //---------------------------------------------------------------------------

    always@(posedge Fifty_m_second_Devide_Clock_input or posedge Reset or posedge clear_the_counter ) begin
        if (Reset == 1 || clear_the_counter == 1) 
            begin
                Timer = 0;
            end
        else
            begin 
                if (enable_the_counter) 
                Timer <= Timer + 1'b1;
            end
    end
    //---------------------------------------------------------------------------



endmodule





    //clock devider, the board has a 10 M hz osc, 
//so I create this code to count 200000 times 
//for each posedge and that equalle to 50 m-second.
// if count until 50 m-second, this clk_out will output one positive edge.

module clk_div(
    input Clock,
    input reset,
    output reg clk_out
    );
    parameter diver = 99999;
    reg [23:0] count;//just for 99999 or warning

    always@(posedge Clock or posedge reset)
    begin
        if(reset)
        begin
            count <= 0;
            clk_out <= 1'b0;
        end
        else if(count == diver)
        begin
            clk_out <= ~clk_out;
            count <= 0;
        end
        else
        begin
            count <= count + 1'b1;
        end
    end

endmodule
模块电源保护(
//---------------------------------------------------------------------------
//投入
//---------------------------------------------------------------------------
输入线五十毫秒设备时钟输入,
输入线时钟,
输入线复位,
输入线输入1检查预充电状态,
输入线输入2\u主电源开关\u继电器\u状态\u检查,
输入线输入3\u通电\u验证,
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//输出
//---------------------------------------------------------------------------
主电源的输出reg Output1继电器开关,
输出寄存器输出2开关打开和充电上限,
输出reg Output3_开关_打开_和_电源_SoM,
output reg Output4\u按下并按住电源,
CPLD通电时,继电器上的输出reg Output5开关
//---------------------------------------------------------------------------
);
//这是一个模块实例化,连接CPLD内不同模块的输入和输出。
钟楼分区d(
.时钟(时钟),
.重置(重置),
.时钟输出(五十秒设备时钟输入)
);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//状态编码
//---------------------------------------------------------------------------
localparam STATE_0_Initial=4'd0,
状态1按下并保持=4'd1,
状态2加电=4'd2,
状态检查开关=4'd3,
状态4安全启动保护=4'd4,
状态_5_错误=4'd5,
状态为充电=4'd6,
状态\u 7 \u充电\u结束\u接通\u主电源=4'd7,
状态_8_电源_就绪=4'd8,
错误\u 9\u超时=4'd9,
状态\u 10 \u预充电\u开关\u断开=4'd10,
状态11主电源开关断开=4'd11,
状态\u 12 \u两个\u开关\u断开=4'd12,
状态_13_占位符=4'd13,
状态_14_占位符=4'd14,
状态_15_占位符=4'd15;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//州注册声明
//---------------------------------------------------------------------------
reg[3:0]当前状态=4'd0;
reg[3:0]NextState=4'd0;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//计时器reg声明
//---------------------------------------------------------------------------
reg[8:0]定时器=0;
reg enable___计数器=0;//布尔值用于启用计数器。
reg clear___计数器=0;
//---------------------------------------------------------------------------   
//---------------------------------------------------------------------------
//输出
//---------------------------------------------------------------------------   
始终@(*)开始
//清除初始状态。
主电源的reg Output1继电器开关=0;
reg Output2开关打开,充电上限=0;
reg Output3_开关_打开_和_电源_SoM=0;
reg Output4\u按下并按住电源=0;
当CPLD通电=0时,reg Output5开关打开继电器;
案例(当前状态)
状态1按下并保持:开始
输出4_按下并保持电源=1;
结束
状态2加电:开始
当CPLD加电=1时,继电器上的输出5开关;
结束
状态3检查开关:开始
输出2打开开关,充电上限=1;
结束
国家安全局启动计划:开始
输出2打开开关,充电上限=1;
结束
状态_5_错误:开始
//待定
结束
状态6\u CAP\u正在充电:开始
//等待充电完成
结束
状态\u 7 \u充电\u结束\u打开\u主电源:开始
主电源的输出1继电器开关=1;
结束
状态\u 8\u电源供应\u准备就绪:开始
当CPLD通电=0时,继电器上的输出5开关;
输出3_开关_打开_和_电源_SoM=1;
结束
尾声
结束
//---------------------------------------------------------------------------   
//---------------------------------------------------------------------------
//同步状态转换始终@(posedge时钟)块
//---------------------------------------------------------------------------
始终@(posedge时钟)开始
如果(重置)电流