Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
37
Task/N-queens-problem/SystemVerilog/n-queens-problem.v
Normal file
37
Task/N-queens-problem/SystemVerilog/n-queens-problem.v
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
program N_queens;
|
||||
|
||||
parameter SIZE_LOG2 = 3;
|
||||
parameter SIZE = 1 << SIZE_LOG2;
|
||||
|
||||
`define ABS_DIFF(a,b) (a>b?a-b:b-a)
|
||||
|
||||
class board;
|
||||
rand bit [SIZE_LOG2-1:0] row[SIZE];
|
||||
|
||||
constraint rook_moves {
|
||||
foreach (row[i]) foreach (row[j]) if (i < j) {
|
||||
row[i] != row[j];
|
||||
}
|
||||
}
|
||||
|
||||
constraint diagonal_moves {
|
||||
foreach (row[i]) foreach (row[j]) if (i < j) {
|
||||
`ABS_DIFF(row[i], row[j]) != `ABS_DIFF(i,j);
|
||||
}
|
||||
}
|
||||
|
||||
function void next;
|
||||
randomize;
|
||||
foreach (row[i]) begin
|
||||
automatic bit [SIZE-1:0] x = 1 << row[i];
|
||||
$display( " %b", x );
|
||||
end
|
||||
$display("--");
|
||||
endfunction
|
||||
|
||||
endclass
|
||||
|
||||
board b = new;
|
||||
initial repeat(1) b.next;
|
||||
|
||||
endprogram
|
||||
Loading…
Add table
Add a link
Reference in a new issue