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

Subversion Repositories test

[/] [test/] [trunk/] [bench/] [verilog/] [spi_slave_model.v] - Blame information for rev 53

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 36 mihal
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  spi_slave_model.v                                           ////
4
////                                                              ////
5
////  This file is part of the SPI IP core project                ////
6
////  http://www.opencores.org/projects/spi/                      ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Simon Srot (simons@opencores.org)                     ////
10
////                                                              ////
11
////  All additional information is avaliable in the Readme.txt   ////
12
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16
//// Copyright (C) 2002 Authors                                   ////
17
////                                                              ////
18
//// This source file may be used and distributed without         ////
19
//// restriction provided that this copyright statement is not    ////
20
//// removed from the file and that any derivative work contains  ////
21
//// the original copyright notice and the associated disclaimer. ////
22
////                                                              ////
23
//// This source file is free software; you can redistribute it   ////
24
//// and/or modify it under the terms of the GNU Lesser General   ////
25
//// Public License as published by the Free Software Foundation; ////
26
//// either version 2.1 of the License, or (at your option) any   ////
27
//// later version.                                               ////
28
////                                                              ////
29
//// This source is distributed in the hope that it will be       ////
30
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
31
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
32
//// PURPOSE.  See the GNU Lesser General Public License for more ////
33
//// details.                                                     ////
34
////                                                              ////
35
//// You should have received a copy of the GNU Lesser General    ////
36
//// Public License along with this source; if not, download it   ////
37
//// from http://www.opencores.org/lgpl.shtml                     ////
38
////                                                              ////
39
//////////////////////////////////////////////////////////////////////
40
 
41
`include "timescale.v"
42
 
43
module spi_slave_model (rst, ss, sclk, mosi, miso);
44
 
45
  input         rst;            // reset
46
  input         ss;             // slave select
47
  input         sclk;           // serial clock
48
  input         mosi;           // master out slave in
49
  output        miso;           // master in slave out
50
 
51
  reg           miso;
52
 
53
  reg           rx_negedge;     // slave receiving on negedge
54
  reg           tx_negedge;     // slave transmiting on negedge
55
  reg    [31:0] data;           // data register
56
 
57
  parameter     Tp = 1;
58
 
59
  always @(posedge(sclk && !rx_negedge) or negedge(sclk && rx_negedge) or rst)
60
  begin
61
    if (rst)
62
      data <= #Tp 32'b0;
63
    else if (!ss)
64
      data <= #Tp {data[30:0], mosi};
65
  end
66
 
67
  always @(posedge(sclk && !tx_negedge) or negedge(sclk && tx_negedge))
68
  begin
69
    miso <= #Tp data[31];
70
  end
71
 
72
endmodule
73
 

powered by: WebSVN 2.1.0

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