-
Notifications
You must be signed in to change notification settings - Fork 0
/
MazeRunner_tb.sv
69 lines (54 loc) · 2.59 KB
/
MazeRunner_tb.sv
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
module MazeRunner_tb();
// << optional include or import >>
reg clk,RST_n;
reg send_cmd; // assert to send command to MazeRunner_tb
reg [15:0] cmd; // 16-bit command to send
reg [11:0] batt; // battery voltage 0xDA0 is nominal
logic cmd_sent;
logic resp_rdy; // MazeRunner has sent a pos acknowledge
logic [7:0] resp; // resp byte from MazeRunner (hopefully 0xA5)
logic hall_n; // magnet found?
/////////////////////////////////////////////////////////////////////////
// Signals interconnecting MazeRunner to RunnerPhysics and RemoteComm //
///////////////////////////////////////////////////////////////////////
wire TX_RX,RX_TX;
wire INRT_SS_n,INRT_SCLK,INRT_MOSI,INRT_MISO,INRT_INT;
wire lftPWM1,lftPWM2,rghtPWM1,rghtPWM2;
wire A2D_SS_n,A2D_SCLK,A2D_MOSI,A2D_MISO;
wire IR_lft_en,IR_cntr_en,IR_rght_en;
localparam FAST_SIM = 1'b1;
//////////////////////
// Instantiate DUT //
////////////////////
MazeRunner iDUT(.clk(clk),.RST_n(RST_n),.INRT_SS_n(INRT_SS_n),.INRT_SCLK(INRT_SCLK),
.INRT_MOSI(INRT_MOSI),.INRT_MISO(INRT_MISO),.INRT_INT(INRT_INT),
.A2D_SS_n(A2D_SS_n),.A2D_SCLK(A2D_SCLK),.A2D_MOSI(A2D_MOSI),
.A2D_MISO(A2D_MISO),.lftPWM1(lftPWM1),.lftPWM2(lftPWM2),
.rghtPWM1(rghtPWM1),.rghtPWM2(rghtPWM2),.RX(RX_TX),.TX(TX_RX),
.hall_n(hall_n),.piezo(),.piezo_n(),.IR_lft_en(IR_lft_en),
.IR_rght_en(IR_rght_en),.IR_cntr_en(IR_cntr_en),.LED());
///////////////////////////////////////////////////////////////////////////////////////
// Instantiate RemoteComm which models bluetooth module receiving & forwarding cmds //
/////////////////////////////////////////////////////////////////////////////////////
RemoteComm iCMD(.clk(clk), .rst_n(RST_n), .RX(TX_RX), .TX(RX_TX), .cmd(cmd), .send_cmd(send_cmd),
.cmd_sent(cmd_sent), .resp_rdy(resp_rdy), .resp(resp));
RunnerPhysics iPHYS(.clk(clk),.RST_n(RST_n),.SS_n(INRT_SS_n),.SCLK(INRT_SCLK),.MISO(INRT_MISO),
.MOSI(INRT_MOSI),.INT(INRT_INT),.lftPWM1(lftPWM1),.lftPWM2(lftPWM2),
.rghtPWM1(rghtPWM1),.rghtPWM2(rghtPWM2),
.IR_lft_en(IR_lft_en),.IR_cntr_en(IR_cntr_en),.IR_rght_en(IR_rght_en),
.A2D_SS_n(A2D_SS_n),.A2D_SCLK(A2D_SCLK),.A2D_MOSI(A2D_MOSI),
.A2D_MISO(A2D_MISO),.hall_n(hall_n),.batt(batt));
initial begin
batt = 12'hDA0; // this is value to use with RunnerPhysics
//<Our stuff here>//
clk = 0;
RST_n = 0;
repeat(2) @(negedge clk)
RST_n = 1;
batt = 12'h0FF;
send_cmd = 0;
cmd =
end
always
#5 clk = ~clk;
endmodule