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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [rtl/] [cdc/] [MCP.sv] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jamieiles
// Copyright Jamie Iles, 2017
2
//
3
// This file is part of s80x86.
4
//
5
// s80x86 is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// s80x86 is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with s80x86.  If not, see .
17
 
18
// Multi-cycle-path formulation with feedback as described in "Clock Domain
19
// Crossing (CDC) Design & Verification Techniques Using SystemVerilog" by
20
// Clifford E. Cummings.
21
module MCP #(parameter width = 8,
22
             parameter reset_val = 8'b0)
23
            (input logic reset,
24
             input logic clk_a,
25
             output logic a_ready,
26
             input logic a_send,
27
             input logic [width-1:0] a_datain,
28
             input logic clk_b,
29
             output logic [width-1:0] b_data,
30
             output logic b_load);
31
 
32
logic [width-1:0] tx_sample;
33
assign a_ready = a_ack | ~tx_busy;
34
reg a_en;
35
wire a_ack;
36
reg tx_busy;
37
wire a_load = a_send & a_ready;
38
wire b_ack;
39
assign b_data = tx_sample;
40
 
41
SyncPulse       BLoadPulse(.clk(clk_b),
42
                           .d(a_en),
43
                           .p(b_load),
44
                           .q(b_ack));
45
 
46
SyncPulse       AAckPulse(.clk(clk_a),
47
                          .d(b_ack),
48
                          .p(a_ack),
49
                          // verilator lint_off PINCONNECTEMPTY
50
                          .q()
51
                          // verilator lint_on PINCONNECTEMPTY
52
                          );
53
 
54
always_ff @(posedge clk_a)
55
    a_en <= a_en ^ a_load;
56
 
57
always_ff @(posedge clk_a or posedge reset) begin
58
    if (reset)
59
        tx_busy <= 1'b0;
60
    else begin
61
        if (a_ack)
62
            tx_busy <= 1'b0;
63
        if (a_send)
64
            tx_busy <= 1'b1;
65
    end
66
end
67
 
68
always_ff @(posedge clk_a or posedge reset)
69
    if (reset)
70
        tx_sample <= reset_val;
71
    else if (a_load)
72
        tx_sample <= a_datain;
73
 
74
endmodule

powered by: WebSVN 2.1.0

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