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

Subversion Repositories srdydrdy_lib

[/] [srdydrdy_lib/] [trunk/] [rtl/] [verilog/] [closure/] [sd_input.v] - Blame information for rev 17

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ghutchis
//----------------------------------------------------------------------
2
// Srdy/Drdy input block
3
//
4
// Halts timing on c_drdy.  Intended to be used on the input side of
5
// a design block.
6
//
7
// Naming convention: c = consumer, p = producer, i = internal interface
8
//----------------------------------------------------------------------
9
// Author: Guy Hutchison
10
//
11
// This block is uncopyrighted and released into the public domain.
12
//----------------------------------------------------------------------
13
 
14
// Clocking statement for synchronous blocks.  Default is for
15
// posedge clocking and positive async reset
16
`ifndef SDLIB_CLOCKING
17
 `define SDLIB_CLOCKING posedge clk or posedge reset
18
`endif
19
 
20
// delay unit for nonblocking assigns, default is to #1
21
`ifndef SDLIB_DELAY
22
 `define SDLIB_DELAY #1
23
`endif
24
 
25
module sd_input
26
  #(parameter width = 8)
27
  (
28
   input              clk,
29
   input              reset,
30
   input              c_srdy,
31
   output reg         c_drdy,
32
   input [width-1:0]  c_data,
33
 
34
   output reg         ip_srdy,
35
   input              ip_drdy,
36
   output reg [width-1:0] ip_data
37
   );
38
 
39
  reg     load;
40
  reg     drain;
41
  reg     occupied, nxt_occupied;
42
  reg [width-1:0] hold, nxt_hold;
43
  reg             nxt_c_drdy;
44
 
45
 
46
  always @*
47
    begin
48
      nxt_hold = hold;
49
      nxt_occupied = occupied;
50
 
51
      drain = occupied & ip_drdy;
52
      load = c_srdy & c_drdy & (!ip_drdy | drain);
53
      if (occupied)
54
        ip_data = hold;
55
      else
56
        ip_data = c_data;
57
 
58
      ip_srdy = (c_srdy & c_drdy) | occupied;
59
 
60
      if (load)
61
        begin
62
          nxt_hold = c_data;
63
          nxt_occupied =  1;
64
        end
65
      else if (drain)
66
        nxt_occupied = 0;
67
 
68
      nxt_c_drdy = (!occupied & !load) | (drain & !load);
69
    end
70
 
71
  always @(`SDLIB_CLOCKING)
72
    begin
73
      if (reset)
74
        begin
75
          hold     <= `SDLIB_DELAY 0;
76
          occupied <= `SDLIB_DELAY 0;
77
          c_drdy   <= `SDLIB_DELAY 0;
78
        end
79
      else
80
        begin
81
          hold     <= `SDLIB_DELAY nxt_hold;
82
          occupied <= `SDLIB_DELAY nxt_occupied;
83
          c_drdy   <= `SDLIB_DELAY nxt_c_drdy;
84
        end // else: !if(reset)
85
    end // always @ (posedge clk)  
86
 
87
endmodule

powered by: WebSVN 2.1.0

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