-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_soc.py
More file actions
42 lines (36 loc) · 1.09 KB
/
test_soc.py
File metadata and controls
42 lines (36 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import random
import cocotb
from cocotb.clock import Clock
from cocotb.triggers import Timer, ClockCycles
# Just executes whatever is in test.mem so you can inspect the waveform
# https://riscvasm.lucasteske.dev/# is useful for assembling hex for the file.
@cocotb.test()
async def test_start(nv):
clock = Clock(nv.clk, 83, units="ns")
cocotb.start_soon(clock.start())
nv.rstn.value = 0
nv.uart_rxd.value = 1
await ClockCycles(nv.clk, 2)
nv.rstn.value = 1
await Timer(1, "us")
bit_time = 1000000000 // 28800
nv.uart_rxd.value = 0
await Timer(bit_time, "ns")
# Send 0x5A
await Timer(bit_time, "ns")
nv.uart_rxd.value = 1
await Timer(bit_time, "ns")
nv.uart_rxd.value = 0
await Timer(bit_time, "ns")
nv.uart_rxd.value = 1
await Timer(bit_time, "ns")
await Timer(bit_time, "ns")
nv.uart_rxd.value = 0
await Timer(bit_time, "ns")
nv.uart_rxd.value = 1
await Timer(bit_time, "ns")
nv.uart_rxd.value = 0
await Timer(bit_time, "ns")
nv.uart_rxd.value = 1
await Timer(bit_time, "ns")
await Timer(1000, "us")