Conditional
2023. 6. 24. 22:18ㆍFPGA/HDLBits
728x90
Given four unsigned numbers, find the minimum. Unsigned numbers can be compared with standard comparison operators (a < b). Use the conditional operator to make two-way min circuits, then compose a few of them to create a 4-way min circuit. You'll probably want some wire vectors for the intermediate results.
module top_module (
input [7:0] a, b, c, d,
output [7:0] min);//
wire [7:0] num1, num2;
assign num1 = (a > b) ? b: a;
assign num2 = (num1 > c) ? c : num1;
assign min = (num2 > d) ? d : num2;
endmodule
'FPGA > HDLBits' 카테고리의 다른 글
Adder100i (0) | 2023.06.25 |
---|---|
Reduction (0) | 2023.06.24 |
Always nolatches (0) | 2023.06.24 |
Always casez (0) | 2023.06.24 |
Always case2 (0) | 2023.06.24 |