Skip to content

Instantly share code, notes, and snippets.

@Newlifer
Created April 7, 2018 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Newlifer/316c82e239b081b961e66c762c47f3b7 to your computer and use it in GitHub Desktop.
Save Newlifer/316c82e239b081b961e66c762c47f3b7 to your computer and use it in GitHub Desktop.
pnorm.sv
/*
* Простой алгоритм параллельной нормализации.
*/
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