Created
April 7, 2018 16:20
-
-
Save Newlifer/316c82e239b081b961e66c762c47f3b7 to your computer and use it in GitHub Desktop.
pnorm.sv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Простой алгоритм параллельной нормализации. | |
*/ | |
module main(); | |
integer values[3]; | |
bit sum; | |
integer counter; // ticks count | |
initial begin | |
values[0] = 4'b0011; | |
values[1] = 4'b0001; | |
values[2] = 4'b0101; | |
sum = 0; | |
counter = 0; | |
$display("Before: %b", sum); | |
while(sum == 0) begin | |
foreach(values[i]) begin | |
values[i] = values[i] << (values[i][3] ^ 1'b1); | |
sum = sum ~& values[i][3]; | |
end | |
counter += 1; | |
end | |
$display("Done"); | |
foreach(values[i]) begin | |
$display("%b", values[i]); | |
end | |
$display("With ticks: %d", counter); | |
end | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment