灰尘驾车 2022-07-30 23:05 采纳率: 71.4%
浏览 59
已结题

关于verilog中的population count

module top_module(
input [254:0] in,
output [7:0] out );

always @(*) begin
    out = 0;
    for(int i = 0; i < 255; i++) begin
        if(in[i])
            out = out + 1;
        else
            out = out + 0;
    end
end

endmodule
这段代码在hdlbits(那个刷题的)上没有问题,但是在vivado和quartus上都有错误,都在for那一行错误为Error (10170): Verilog HDL syntax error at top_module.v(7) near text: "i"; expecting "=". Check for and fix any syntax errors that appear immediately before or at the specified keyword. The Intel FPGA Knowledge Database contains many articles with specific details on how to resolve this error. Visit the Knowledge Database at https://www.altera.com/support/support-resources/knowledge-base/search.html and search for this specific error message number.
Error (10170): Verilog HDL syntax error at top_module.v(7) near text: "<"; expecting "<=", or "=". Check for and fix any syntax errors that appear immediately before or at the specified keyword. The Intel FPGA Knowledge Database contains many articles with specific details on how to resolve this error. Visit the Knowledge Database at <a href="https://www.altera.com/support/support-resources/knowledge-base/search.html" id="textarea_1659193290120_1659193514199_1">https://www.altera.com/support/support-resources/knowledge-base/search.html and search for this specific error message number.
Error (10112): Ignored design unit "top_module" at top_module.v(1) due to previous errors

  • 写回答

2条回答 默认 最新

  • 老皮芽子 2022-08-01 08:37
    关注
    
    module top_module(
    input [254:0] in,
    output [7:0] out );
    integer    i;
    always @(*) begin
        out = 0;
        for(i = 0; i < 255; i=i+1) begin
            if(in[i])
                out = out + 1;
            else
                out = out + 0;
        end
    end
    endmodule
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 8月9日
  • 已采纳回答 8月1日
  • 创建了问题 7月30日

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog