OpenCores
URL https://opencores.org/ocsvn/socgen/socgen/trunk

Subversion Repositories socgen

[/] [socgen/] [trunk/] [common/] [opencores.org/] [Testbench/] [bfms/] [spi_host/] [rtl/] [verilog/] [top.sim] - Blame information for rev 135

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 135 jt_eaton
module spi_host_def
2
 
3
(
4
input  wire         clk,
5
input  wire         reset,
6
input  wire         busy,
7
 
8
input  wire [7:0]   rx_data,
9
input  wire         rx_read,
10
input  wire         rx_full,
11
input  wire         rx_parity_error,
12
input  wire         rx_parity_rcv,
13
input  wire         rx_parity_cal,
14
input  wire         rx_frame_error,
15
inout  wire         tx_ack_error,
16
 
17
output  reg         rx_clr,
18
output reg [7:0]    tx_data,
19
output reg          tx_write
20
);
21
 
22
reg                 exp_tx_ack_err;
23
reg                 mask_tx_ack_err;
24
reg   [7:0]         exp_rcv_byte;
25
reg   [7:0]         mask_rcv_byte;
26
 
27
 
28
 
29
 
30
 
31
 
32
io_probe_in
33
#(  .MESG("spi_host tx_ack error")
34
 )
35
tx_ack_err_tpb
36
(
37
          .clk             ( clk             ),
38
          .expected_value  ( exp_tx_ack_err  ),
39
          .mask            ( mask_tx_ack_err ),
40
          .signal          ( tx_ack_error    )
41
);
42
 
43
 
44
 
45
 
46
 
47
 
48
 
49
 
50
 
51
io_probe_in
52
#(  .MESG("spi_host receive error"),
53
    .WIDTH        (8)
54
 )
55
rcv_byte_tpb
56
(
57
          .clk             ( clk           ),
58
          .expected_value  ( exp_rcv_byte  ),
59
          .mask            ( mask_rcv_byte ),
60
          .signal          ( rx_data       )
61
);
62
 
63
 
64
 
65
 
66
 
67
 
68
 
69
always@(posedge clk)
70
  if(reset)
71
    begin
72
    tx_data              <= 8'h00;
73
    tx_write             <= 1'b0;
74
    rx_clr               <= 1'b0;
75
    exp_tx_ack_err       <= 1'b0;
76
    mask_tx_ack_err      <= 1'b0;
77
    exp_rcv_byte         <= 8'h00;
78
    mask_rcv_byte        <= 8'h00;
79
    end
80
 
81
 
82
 
83
 
84
 
85
 
86
 
87
task automatic next;
88
  input [31:0] num;
89
  repeat (num)       @ (posedge clk);
90
endtask
91
 
92
task clear_rx_host;
93
 begin
94
 rx_clr               <= 1'b1;
95
 next(1);
96
 rx_clr               <= 1'b0;
97
 end
98
endtask
99
 
100
 
101
 
102
task rcv_byte;
103
  input [7:0] byte_in;
104
   begin
105
   exp_rcv_byte  <= byte_in;
106
 
107
   while(!rx_read)  next(1);
108
   $display("%t           checking    %h",$realtime,byte_in);
109
   mask_rcv_byte <= 8'hff;
110
   next(1);
111
   mask_rcv_byte <= 8'h00;
112
end
113
endtask
114
 
115
task send_byte;
116
  input [7:0] byte_out;
117
   begin
118
   $display("%t %m %2h",$realtime ,byte_out  );
119
   tx_data  <= byte_out;
120
   next(1);
121
   tx_write   <= 1'b1;
122
   next(1);
123
   tx_write   <= 1'b0;
124
   next(1);
125
   while(busy)   next(1);
126
   mask_tx_ack_err <= 1'b1;
127
   next(1);
128
   mask_tx_ack_err <= 1'b0;
129
   end
130
endtask // send_byte
131
 
132
 
133
 
134
 
135
 
136
endmodule
137
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.