a36ec83974432dbee09b34f77e4d51fe45402f55
3 from litesata
.common
import *
4 from litesata
.core
.link
.crc
import *
6 from litesata
.test
.common
import *
9 def __init__(self
, length
, random
):
10 self
.crc
= LiteSATACRC()
14 def get_c_crc(self
, datas
):
17 stdin
+= "0x%08x " %data
19 with subprocess
.Popen("./crc", stdin
=subprocess
.PIPE
, stdout
=subprocess
.PIPE
) as process
:
20 process
.stdin
.write(stdin
.encode("ASCII"))
21 out
, err
= process
.communicate()
22 return int(out
.decode("ASCII"), 16)
24 def gen_simulation(self
, selfp
):
34 for i
in range(self
.length
):
35 data
= seed_to_data(i
, self
.random
)
42 sim_crc
= selfp
.crc
.value
49 # get C core reference
50 c_crc
= self
.get_c_crc(datas
)
53 s
, l
, e
= check(c_crc
, sim_crc
)
54 print("shift "+ str(s
) + " / length " + str(l
) + " / errors " + str(e
))
56 if __name__
== "__main__":
57 from migen
.sim
.generic
import run_simulation
59 run_simulation(TB(length
, True), ncycles
=length
+100, vcd_name
="my.vcd")