Bugs addsubz
2023. 6. 18. 19:09ㆍFPGA/HDLBits
728x90
Problem Statement
The following adder-subtractor with zero flag doesn't work. Fix the bug(s).
// synthesis verilog_input_version verilog_2001
module top_module (
input do_sub,
input [7:0] a,
input [7:0] b,
output reg [7:0] out,
output reg result_is_zero
);//
always @(*) begin
result_is_zero = 1'b0;
case (do_sub)
1'b0: out = a+b;
1'b1: out = a-b;
endcase
if (out == 1'b0)
result_is_zero = 1'b1;
end
endmodule

'FPGA > HDLBits' 카테고리의 다른 글
| Mt2015 muxdff (0) | 2023.06.19 |
|---|---|
| Exams/m2014 q4b (0) | 2023.06.19 |
| Bugs mux4 (0) | 2023.06.18 |
| Bugs nand3 (0) | 2023.06.18 |
| Exams/m2014 q4d (0) | 2023.06.18 |