【问题标题】:Verilog issue with case/always statement案例/始终声明的 Verilog 问题
【发布时间】:2016-02-02 21:08:14
【问题描述】:

我已经使用给出的示例代码为类编写了这个模块,但是我在尝试编译时遇到了错误 - 我认为这可能是由于我使用输入的方式(或者只是语法错误) ,所以我试图用数组来做 - 我的评论方法正确吗?我应该使用串联吗?

module ledSwitch(LEDR, SW);
    input [9:0] SW; //switches and led
    output [0] LEDR;
 
    mux7to1 u0(
        .s0(SW[0]),//input switches to mux
        .s1(SW[1]),
        .s2(SW[2]),
        .s3(SW[3]),
        .s4(SW[4]),
        .s5(SW[5]),
        .s6(SW[6]),
        .s7(SW[7]),
        .s8(SW[8]),
        .s9(SW[9]),
        //.inputs([SW[0], [SW[1], [SW[2], [SW[3], [SW[4], [SW[5], [SW[6]])
        //.muxSelect([SW[7], [SW[8], [SW[9])
        .l(LEDR[0]) //input led output to mux
        );
endmodule

module mux7to1(s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, l);
    input s0;
    input s1;
    input s2;
    input s3;
    input s4;
    input s5;
    input s6;
    input s7;
    input s8;
    input s9;
    //input inputs[6:0]
    //input muxSelect[2:0]

    output l;

    reg Out; //declare the output signal for the always block

    always@(*) //declare always block
    begin
        case ([s9, s8, s7])//muxSelect[2:0] //start case statement
            3'b000: Out = s0; //case 0, A
            3'b001: Out = s3; //case 1, D
            3'b010: Out = s1; //case 2, B
            3'b011: Out = s5 //case 3, F
            3'b100: Out = s0; //case 4, A
            3'b101: Out = s4; //case 5, E
            3'b110: Out = s2; //case 6, C
            3'b111: Out = s6; //case 7, G
            default: Out = 0; //Default        
        endcase
    end
    assign l = Out;
endmodule

这是错误信息:

信息:********************************************* ************************

信息:运行 Quartus II 64 位分析和综合

信息:版本 15.0.0 Build 145 04/22/2015 SJ 网页版

信息:处理开始时间:2016 年 2 月 2 日星期二 14:53:06

信息:命令:quartus_map --read_settings_files=on --write_settings_files=off Lab2_1 -c Lab2_1

警告 (20028):并行编译未获得许可并已被禁用

错误 (10170):Lab2_1.v(43) 附近文本“[”处的 Verilog HDL 语法错误;期待一个操作数

错误 (10170):Lab2_1.v(45) 靠近文本“3”的 Verilog HDL 语法错误;期待“结束”

错误 (10170):Lab2_1.v(46) 靠近文本“3”的 Verilog HDL 语法错误;期待“结束”

错误 (10170):Lab2_1.v(47) 靠近文本“3”的 Verilog HDL 语法错误;期待“结束”

错误 (10170):Lab2_1.v(48) 附近文本“3”处的 Verilog HDL 语法错误;期待“;”

错误 (10170):Lab2_1.v(49) 靠近文本“3”的 Verilog HDL 语法错误;期待“结束”

错误 (10170):Lab2_1.v(50) 靠近文本“3”的 Verilog HDL 语法错误;期待“结束”

错误 (10170):Lab2_1.v(51) 靠近文本“3”的 Verilog HDL 语法错误;期待“结束”

错误 (10170):Lab2_1.v(52) 的 Verilog HDL 语法错误,靠近文本“默认”;期待“结束”

错误 (10170):Lab2_1.v(53) 靠近文本“endcase”的 Verilog HDL 语法错误;期待“结束”

错误 (10112):由于先前的错误,在 Lab2_1.v(24) 中忽略了设计单元“mux7to1”

信息 (12021):在源文件 Lab2_1.v 中找到 0 个设计单元,包括 0 个实体

错误:Quartus II 64-Bit Analysis & Synthesis 不成功。 11 个错误,1 个警告

错误:峰值虚拟内存:959 兆字节

错误:处理结束:2016 年 2 月 2 日星期二 14:53:23

错误:经过时间:00:00:17

错误:总 CPU 时间(在所有处理器上):00:00:51

错误 (293001):Quartus II 完整编译不成功。 13 个错误,1 个警告

【问题讨论】:

    标签: verilog case-statement quartus


    【解决方案1】:

    您需要使用连接运算符:case ({s9, s8, s7})

    还有一些语法错误,例如缺少分号,需要更正。

    最后在ledSwitch模块中你需要正确定义输出。

    【讨论】:

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