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

甚至连信号都省了
671

被折叠的 条评论
为什么被折叠?



