HDL—Verilog Language—Vectors—Replication operator
Build a circuit that sign-extends an 8-bit number to 32 bits. This requires a concatenation of 24 copies of the sign bit (i.e., replicate bit[7] 24 times) followed by the 8-bit number itself.
构建一个将8位数字符号扩展为32位的电路。这需要符号位的24个副本的级联(即,复制位[7]24次),然后是8位数字本身。
主要是学会使用重复信号的用法
{num{vector}}
就是把vector信号复制num份,然后拼起来。
所以题目也很简单,
module top_module (
input [7:0] in,
output [31:0] out );//// assign out = { replicate-sign-bit , the-input };
assign out = {{24{in[7]}},in};
endmodule

甚至连信号都省了
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
