【问题标题】:Stuck on assigning parts of an array to a number in Verilog坚持将数组的一部分分配给 Verilog 中的数字
【发布时间】:2017-11-16 20:02:35
【问题描述】:
input [31:0] instruction;
output [4:0] read_reg_1;

read_reg_1 <= instruction[6:10];

我想将数组元素 6 到 10(6-7-8-9-10) 分配为 read_reg_1 的 5 位数字

Error (10170): Verilog HDL syntax error at mips_fetch.v(8) near text "<=";  expecting ".", or "("

这是我在操作过程中遇到的错误。虽然我找不到解决方案或问题,但它似乎应该可以工作。

【问题讨论】:

    标签: arrays verilog quartus


    【解决方案1】:

    由于您在没有类型的情况下定义了read_reg_1,因此您的编译器默认假定它是wire,而不是reg,因此您不能使用&lt;= 分配给它。

    要么这样做:

    input wire [31:0] instruction;
    output reg [4:0]  read_reg_1;
    
    always @*
        read_reg_1 = instruction[6:10];
    

    或者这个:

    input  wire [31:0] instruction;
    output wire [4:0]  read_reg_1;
    
    assign read_reg_1 = instruction[6:10];
    

    或者这个:

    input wire [31:0] instruction;
    output reg [4:0]  read_reg_1;
    
    always @(posedge clk)
        read_reg_1 <= instruction[6:10];
    

    【讨论】:

      猜你喜欢
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-13
      • 1970-01-01
      • 1970-01-01
      • 2018-01-10
      相关资源
      最近更新 更多