blob: 3961313ec05204f1cd2de4cbc1adc340238a27c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// nandgame condition checker
`timescale 1us/1us
`ifndef NANDGAME_CONDC
`define NANDGAME_CONDC
module cond_check #(
parameter DATA_WIDTH = 16
) (
// operand
input [(DATA_WIDTH-1):0] X_in,
// check whether operand < 0
input wire check_ltz_in,
// check whether operand == 0
input wire check_eqz_in,
// check whether operand > 0
input wire check_gtz_in,
// result of check
output wire result_out
);
wire is_neg_int;
assign is_neg_int = X_in[(DATA_WIDTH - 1)] == 1;
wire ltz_result_int, eqz_result_int, gtz_result_int;
assign ltz_result_int = check_ltz_in && is_neg_int;
assign gtz_result_int = check_gtz_in && !is_neg_int && !(X_in == 0);
assign eqz_result_int = check_eqz_in && (X_in == 0);
assign result_out = ltz_result_int || gtz_result_int || eqz_result_int;
endmodule
`endif
|