How to sign-extend a number in Verilog

前端 未结 3 601
礼貌的吻别
礼貌的吻别 2021-02-08 00:51

I\'m working on a simple sign-extender in Verilog for a processor I\'m creating for Computer Architecture.

Here\'s what I\'ve got so far: [EDIT: Changed the selection st

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-08 01:44

    You nearly got it...

    always @( posedge clk ) begin
        extended[15:0] <= { {8{extend[7]}}, extend[7:0] };
    end
    

    You're also missing a clock edge for the '40' test. Try this, & let me know how you get on...

提交回复
热议问题