【问题标题】:Beginner's Question on Compiling Verilog in QuartusQuartus中编译Verilog的初学者问题
【发布时间】:2021-12-06 12:47:04
【问题描述】:

我正在学习 Verilog。我正在尝试创建一个代码,让 LED 以特定频率闪烁。我知道我使用的时钟是 100Mhz,所以我希望它以 1Hz 的周期运行。我为 27 位设置了一个注册表,这应该让我达到 1*10^8。

module main(
        input wire clk,         //100MHz//
        input wire reset_,
        output reg[1:0] LED1        //LED On/Off Two-States//
        );
        reg ON = 1'b1;      //INIT//
        reg[27:0] LEDStateCount;    //LED Counter - 27 Bit Stored//
        reg OFF;            //State of LED//
    
        assign LED1[0] = OFF;       
        assign LED1[1] = ON;
    
        always @(posedge clk or negedge reset_)begin
            if (!reset_)begin
                LEDStateCount <= 27'd0;    //On startup, clear value//
            end
            else if (LEDStateCount<LEDStateCount[27'd50000000])begin
                LEDStateCount <= LEDStateCount + 1;             //Accumulate to ~50,000,000//
                OFF <= LEDStateCount[27'd50000000];             //LED Off Until Value Reached//
            end
        end
    endmodule

在 Quartus 中编译时出现错误-

错误 (10219):Frequencytest.v(10) 处的 Verilog HDL 连续分配错误:分配左侧的对象“LED​​1”必须具有网络类型

错误 (10219):Frequencytest.v(11) 处的 Verilog HDL 连续分配错误:分配左侧的对象“LED​​1”必须具有网络类型

我相信这与我在注册注册时声明的内容有关。这是我在制作时参考的两页,

Badprog.com - LED Blinking In Verilog

Similar Thread with Blinking LED's

我确信除了少数语法错误之外,这段代码还有其他问题。

【问题讨论】:

    标签: verilog quartus


    【解决方案1】:

    错误告诉您不应将assign 用于reg 类型。要解决这个问题,请更改:

        output reg[1:0] LED1        //LED On/Off Two-States//
    

    到:

        output [1:0] LED1        //LED On/Off Two-States//
    

    我还收到了关于 LEDStateCount[27'd50000000] 两种用法的警告。

    Warning-[SIOB] Select index out of bounds
    "LEDStateCount[27'd50000000]"
      The select index is out of declared bounds : [27:0].
      In module : main.
    

    括号内的数字必须在 0 到 27 之间。不能是 50,000,000。

            else if (LEDStateCount<LEDStateCount[27'd50000000])begin
    

    应该是这样的:

            else if (LEDStateCount<27'd50000000)begin
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-17
      相关资源
      最近更新 更多