我不明白以下Verilog代码 [英] i can't understand the following verilog code

查看:178
本文介绍了我不明白以下Verilog代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解此代码末尾的两行

i can't understand the two lines at the end of this code

input [15:0] offset ;
output [31:0] pc;
output [31:0] pc_plus_4;
reg [31:0] pc;
wire [31:0] pcinc ;

assign pcinc = pc +4 ;
assign pc_plus_4 = {pc[31],pcinc};

assign branch_aadr = {0,pcinc + {{13{offset[15]}},offset[15:0],2'b00}};


推荐答案

如果您不熟悉花括号 {} ,它们是串联运算符。您可以在Verilog的IEEE Std中了解它们(例如1800-2009,第11.4.12节)。

If you are unfamiliar with curly braces {}, they are concatenation operators. You can read about them in the IEEE Std for Verilog (for example, 1800-2009, Section 11.4.12).

assign pc_plus_4 = {pc[31],pcinc};

这会将 pc 的MSB与所有 pcinc 位组合成 pc_plus_4 信号。但是,在这种情况下,由于 pcinc pc_plus_4 都是32位宽,因此 pc [ 31] 被忽略。一个好的整理工具会通知您RHS为33位,LHS为32位,并且最高有效位将丢失。该行可以更简单地编码为:

This concatenates the MSB of pc with all bits of pcinc to assemble the pc_plus_4 signal. However, in this case, since pcinc and pc_plus_4 are both 32 bits wide, pc[31] is ignored. A good linting tool will notify you that the RHS is 33 bits and the LHS is 32 bits, and that the most significant bit will be lost. The line can be more simply coded as:

assign pc_plus_4 = pcinc;

最后一行是我正在使用的一个模拟器的编译错误。您未明确声明 branch_aadr 信号的宽度,并且未指定 0 常量的宽度。

The last line is a compile error for one simulator I'm using. You did not explicitly declare the width of the branch_aadr signal, and the width of the 0 constant is unspecified.

这篇关于我不明白以下Verilog代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆