verilog - How to eliminate Verilog instance syntax error
问题描述
This code is of 4:1 mux from three 2:1 muxes, and I am getting this syntax error. How do I eliminate this error?
ERROR:HDLCompiler:806 - "D:\Verilog\muxx\mux4.v" Line 12: Syntax error near "[".
ERROR:HDLCompiler:806 - "D:\Verilog\muxx\mux4.v" Line 13: Syntax error near "[".
ERROR:HDLCompiler:806 - "D:\Verilog\muxx\mux4.v" Line 14: Syntax error near "[".
module fmux(
input [3:0] a,
input [1:0] s,
output o
);
wire x,y;
muxx m0(.a[0](a[0]), .a[1](a[1]), .s(s[0]), .o(x)); //error
muxx m1(.a[0](a[2]), .a[1](a[3]), .s(s[0]), .o(y)); //error
muxx m2(.a[0](x), .a[1](y), .s(s[1]), .o(o)); //error
endmodule
解决方案
语法错误指向.a[0]
.
假设您的muxx
端口如下所示,那么您可以按如下方式进行连接:
module muxx (
input [1:0] a,
input s,
output o
);
endmodule
module fmux (
input [3:0] a,
input [1:0] s,
output o
);
wire x,y;
muxx m0 (.a(a[1:0]), .s(s[0]), .o(x));
muxx m1 (.a(a[3:2]), .s(s[0]), .o(y));
muxx m2 (.a({y, x}), .s(s[1]), .o(o));
endmodule
推荐阅读
- wordpress - 如何在代码的自定义部分中显示 WP 排队脚本或样式?(除了页眉和页脚)
- javascript - 该函数在 JSX 类组件中的什么位置?
- python - 在 Python 2 中获得类似 Python 3 html unescape 的行为
- typescript - 如何将 Typescript 函数重载与具有多个参数的函数一起使用?
- javascript - 你能帮我修复vue中的道具吗?
- node.js - 无法使用快速服务器中的 vbs 脚本专注于窗口
- javascript - django-js-routes 解析器找不到 url
- c# - Dotnet 5.0 数据保护(到 Azure Vault 的持久密钥)解包密钥随机失败:“[未知] 验证令牌时出错:'S2S12086'”
- python - 如何检查列是否存在
- laravel - Laravel 8 - 我正在使用多输入文件,无法将多个图像存储在不同的行(DB)