Download Arithmetic/Other/fixed_point_adder/verified_fixed_point_adder.v from chipagents/RTLLM-verified: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/datasets/chipagents/RTLLM-verified/resolve/main/Arithmetic/Other/fixed_point_adder/verified_fixed_point_adder.v
- Command line
-
hf download hf://datasets/chipagents/RTLLM-verified/Arithmetic/Other/fixed_point_adder/verified_fixed_point_adder.v
-
curl -L -o verified_fixed_point_adder.v https://huggingface.co/datasets/chipagents/RTLLM-verified/resolve/main/Arithmetic/Other/fixed_point_adder/verified_fixed_point_adder.v
1.08 kB
| module fixed_point_adder #( | |
| //Parameterized values | |
| parameter Q = 15, | |
| parameter N = 32 | |
| ) | |
| ( | |
| input [N-1:0] a, | |
| input [N-1:0] b, | |
| output [N-1:0] c | |
| ); | |
| reg [N-1:0] res; | |
| assign c = res; | |
| always @(a,b) begin | |
| // both negative or both positive | |
| if(a[N-1] == b[N-1]) begin | |
| res[N-2:0] = a[N-2:0] + b[N-2:0]; | |
| res[N-1] = a[N-1]; | |
| end | |
| // one of them is negative... | |
| else if(a[N-1] == 0 && b[N-1] == 1) begin | |
| if( a[N-2:0] > b[N-2:0] ) begin | |
| res[N-2:0] = a[N-2:0] - b[N-2:0]; | |
| res[N-1] = 0; | |
| end | |
| else begin | |
| res[N-2:0] = b[N-2:0] - a[N-2:0]; | |
| if (res[N-2:0] == 0) | |
| res[N-1] = 0; | |
| else | |
| res[N-1] = 1; | |
| end | |
| end | |
| else begin | |
| if( a[N-2:0] > b[N-2:0] ) begin | |
| res[N-2:0] = a[N-2:0] - b[N-2:0]; | |
| if (res[N-2:0] == 0) | |
| res[N-1] = 0; | |
| else | |
| res[N-1] = 1; | |
| end | |
| else begin | |
| res[N-2:0] = b[N-2:0] - a[N-2:0]; | |
| res[N-1] = 0; | |
| end | |
| end | |
| end | |
| endmodule |