mirror of
https://github.com/YosysHQ/sby.git
synced 2025-04-05 22:14:08 +00:00
Add djb2hash example
Signed-off-by: Claire Wolf <claire@symbioticeda.com>
This commit is contained in:
parent
a4885ce494
commit
3ec2b6b4e4
1
docs/examples/puzzles/.gitignore
vendored
1
docs/examples/puzzles/.gitignore
vendored
|
@ -2,3 +2,4 @@
|
|||
/primegen_primegen
|
||||
/primegen_primes_pass
|
||||
/primegen_primes_fail
|
||||
/djb2hash
|
||||
|
|
14
docs/examples/puzzles/djb2hash.sby
Normal file
14
docs/examples/puzzles/djb2hash.sby
Normal file
|
@ -0,0 +1,14 @@
|
|||
[options]
|
||||
mode bmc
|
||||
expect fail
|
||||
|
||||
[engines]
|
||||
smtbmc yices
|
||||
|
||||
[script]
|
||||
read -noverific
|
||||
read -sv djb2hash.sv
|
||||
prep -top djb2hash
|
||||
|
||||
[files]
|
||||
djb2hash.sv
|
13
docs/examples/puzzles/djb2hash.sv
Normal file
13
docs/examples/puzzles/djb2hash.sv
Normal file
|
@ -0,0 +1,13 @@
|
|||
// find a hash collision for DJB2 hash where it visits the same state twice
|
||||
module djb2hash (input clock);
|
||||
(* keep *) rand const reg [31:0] magic;
|
||||
(* keep *) rand reg [7:0] inputval;
|
||||
(* keep *) reg [31:0] state = 5381;
|
||||
(* keep *) integer cnt = 0;
|
||||
|
||||
always @(posedge clock) begin
|
||||
state <= ((state << 5) + state) ^ inputval;
|
||||
if (state == magic) cnt <= cnt + 1;
|
||||
assert (cnt < 2);
|
||||
end
|
||||
endmodule
|
Loading…
Reference in a new issue