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

Subversion Repositories yifive

[/] [yifive/] [trunk/] [caravel_yifive/] [verilog/] [rtl/] [syntacore/] [scr1/] [src/] [core/] [scr1_tapc_synchronizer.sv] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 dinesha
/// Copyright by Syntacore LLC © 2016-2020. See LICENSE for details
2
/// @file       
3
/// @brief      TAPC clock domain crossing synchronizer
4
///
5
 
6
`include "scr1_arch_description.svh"
7
 
8
`ifdef SCR1_DBG_EN
9
`include "scr1_tapc.svh"
10
`include "scr1_dm.svh"
11
 
12
module scr1_tapc_synchronizer (
13
    // System common signals
14
    input   logic                                   pwrup_rst_n,                // Power-Up Reset
15
    input   logic                                   dm_rst_n,                   // Debug Module Reset
16
    input   logic                                   clk,                        // System Clock (SysCLK)
17
 
18
    // JTAG common signals
19
    input   logic                                   tapc_trst_n,                // JTAG Test Reset (TRSTn)
20
    input   logic                                   tapc_tck,                   // JTAG Test Clock (TCK)
21
 
22
 
23
    // DMI/SCU scan-chains
24
    input  logic                                    tapc2tapcsync_scu_ch_sel_i, // SCU Chain Select input  (TCK domain)
25
    output logic                                    tapcsync2scu_ch_sel_o,      // SCU Chain Select output (SysCLK domain)
26
    input  logic                                    tapc2tapcsync_dmi_ch_sel_i, // DMI Chain Select input  (TCK domain)
27
    output logic                                    tapcsync2dmi_ch_sel_o,      // DMI Chain Select output (SysCLK domain)
28
 
29
    input  logic [SCR1_DBG_DMI_CH_ID_WIDTH-1:0]     tapc2tapcsync_ch_id_i,      // DMI/SCU Chain Identifier input  (TCK domain)
30
    output logic [SCR1_DBG_DMI_CH_ID_WIDTH-1:0]     tapcsync2core_ch_id_o,      // DMI/SCU Chain Identifier output (SysCLK domain)
31
 
32
    input  logic                                    tapc2tapcsync_ch_capture_i, // DMI/SCU Chain Capture input  (TCK domain)
33
    output logic                                    tapcsync2core_ch_capture_o, // DMI/SCU Chain Capture output (SysCLK domain)
34
 
35
    input  logic                                    tapc2tapcsync_ch_shift_i,   // DMI/SCU Chain Shift input  (TCK domain)
36
    output logic                                    tapcsync2core_ch_shift_o,   // DMI/SCU Chain Shift output (SysCLK domain)
37
 
38
    input  logic                                    tapc2tapcsync_ch_update_i,  // DMI/SCU Chain Update input  (TCK domain)
39
    output logic                                    tapcsync2core_ch_update_o,  // DMI/SCU Chain Update output (SysCLK domain)
40
 
41
    input  logic                                    tapc2tapcsync_ch_tdi_i,     // DMI/SCU Chain TDI input  (TCK domain)
42
    output logic                                    tapcsync2core_ch_tdi_o,     // DMI/SCU Chain TDI output (SysCLK domain)
43
 
44
    output logic                                    tapc2tapcsync_ch_tdo_i,     // DMI/SCU Chain TDO output (TCK domain)
45
    input  logic                                    tapcsync2core_ch_tdo_o      // DMI/SCU Chain TDO input  (SysCLK domain)
46
);
47
 
48
//-------------------------------------------------------------------------------
49
// Local signals declaration
50
//-------------------------------------------------------------------------------
51
 
52
logic           tck_divpos;
53
logic           tck_divneg;
54
logic           tck_rise_load;
55
logic           tck_rise_reset;
56
logic           tck_fall_load;
57
logic           tck_fall_reset;
58
logic [3:0]     tck_divpos_sync;
59
logic [3:0]     tck_divneg_sync;
60
logic [2:0]     dmi_ch_capture_sync;
61
logic [2:0]     dmi_ch_shift_sync;
62
logic [2:0]     dmi_ch_tdi_sync;
63
 
64
//-------------------------------------------------------------------------------
65
// Logic
66
//-------------------------------------------------------------------------------
67
 
68
always_ff @(posedge tapc_tck, negedge tapc_trst_n) begin
69
    if (~tapc_trst_n) begin
70
        tck_divpos      <= 1'b0;
71
    end else begin
72
        tck_divpos      <= ~tck_divpos;
73
    end
74
end
75
 
76
always_ff @(negedge tapc_tck, negedge tapc_trst_n) begin
77
    if (~tapc_trst_n) begin
78
        tck_divneg      <= 1'b0;
79
    end else begin
80
        tck_divneg      <= ~tck_divneg;
81
    end
82
end
83
 
84
always_ff @(posedge clk, negedge pwrup_rst_n) begin
85
    if (~pwrup_rst_n) begin
86
        tck_divpos_sync <= 4'd0;
87
        tck_divneg_sync <= 4'd0;
88
    end else begin
89
        tck_divpos_sync <= {tck_divpos_sync[2:0], tck_divpos};
90
        tck_divneg_sync <= {tck_divneg_sync[2:0], tck_divneg};
91
    end
92
end
93
 
94
assign tck_rise_load  = tck_divpos_sync[2] ^ tck_divpos_sync[1];
95
assign tck_rise_reset = tck_divpos_sync[3] ^ tck_divpos_sync[2];
96
assign tck_fall_load  = tck_divneg_sync[2] ^ tck_divneg_sync[1];
97
assign tck_fall_reset = tck_divneg_sync[3] ^ tck_divneg_sync[2];
98
 
99
always_ff @(posedge clk, negedge pwrup_rst_n) begin
100
    if (~pwrup_rst_n) begin
101
            tapcsync2core_ch_update_o   <= '0;
102
    end else begin
103
        if  (tck_fall_load) begin
104
            tapcsync2core_ch_update_o   <= tapc2tapcsync_ch_update_i;
105
        end else if (tck_fall_reset) begin
106
            tapcsync2core_ch_update_o   <= '0;
107
        end
108
    end
109
end
110
 
111
always_ff @(negedge tapc_tck, negedge tapc_trst_n) begin
112
    if (~tapc_trst_n) begin
113
        dmi_ch_capture_sync[0] <= '0;
114
        dmi_ch_shift_sync[0]   <= '0;
115
    end else begin
116
        dmi_ch_capture_sync[0] <= tapc2tapcsync_ch_capture_i;
117
        dmi_ch_shift_sync[0]   <= tapc2tapcsync_ch_shift_i;
118
    end
119
end
120
 
121
always_ff @(posedge clk, negedge pwrup_rst_n) begin
122
    if (~pwrup_rst_n) begin
123
        dmi_ch_capture_sync[2:1] <= '0;
124
        dmi_ch_shift_sync[2:1]   <= '0;
125
    end else begin
126
        dmi_ch_capture_sync[2:1] <= {dmi_ch_capture_sync[1], dmi_ch_capture_sync[0]};
127
        dmi_ch_shift_sync[2:1]   <= {dmi_ch_shift_sync[1], dmi_ch_shift_sync[0]};
128
    end
129
end
130
 
131
always_ff @(posedge clk, negedge pwrup_rst_n) begin
132
    if (~pwrup_rst_n) begin
133
        dmi_ch_tdi_sync     <= '0;
134
    end else begin
135
        dmi_ch_tdi_sync     <= {dmi_ch_tdi_sync[1:0], tapc2tapcsync_ch_tdi_i};
136
    end
137
end
138
 
139
always_ff @(posedge clk, negedge pwrup_rst_n) begin
140
    if (~pwrup_rst_n) begin
141
            tapcsync2core_ch_capture_o <= '0;
142
            tapcsync2core_ch_shift_o   <= '0;
143
            tapcsync2core_ch_tdi_o     <= '0;
144
    end else begin
145
        if (tck_rise_load) begin
146
            tapcsync2core_ch_capture_o <= dmi_ch_capture_sync[2];
147
            tapcsync2core_ch_shift_o   <= dmi_ch_shift_sync[2];
148
            tapcsync2core_ch_tdi_o     <= dmi_ch_tdi_sync[2];
149
        end else if (tck_rise_reset) begin
150
            tapcsync2core_ch_capture_o <= '0;
151
            tapcsync2core_ch_shift_o   <= '0;
152
            tapcsync2core_ch_tdi_o     <= '0;
153
        end
154
    end
155
end
156
 
157
always_ff @(posedge clk, negedge dm_rst_n) begin
158
    if (~dm_rst_n) begin
159
            tapcsync2dmi_ch_sel_o     <= '0;
160
            tapcsync2core_ch_id_o      <= '0;
161
    end else begin
162
        if (tck_rise_load) begin
163
            tapcsync2dmi_ch_sel_o     <= tapc2tapcsync_dmi_ch_sel_i;
164
            tapcsync2core_ch_id_o      <= tapc2tapcsync_ch_id_i;
165
        end
166
    end
167
end
168
 
169
always_ff @(posedge clk, negedge pwrup_rst_n) begin
170
    if (~pwrup_rst_n) begin
171
            tapcsync2scu_ch_sel_o     <= '0;
172
    end else begin
173
        if (tck_rise_load) begin
174
            tapcsync2scu_ch_sel_o     <= tapc2tapcsync_scu_ch_sel_i;
175
        end
176
    end
177
end
178
 
179
assign tapc2tapcsync_ch_tdo_i = tapcsync2core_ch_tdo_o;
180
 
181
endmodule : scr1_tapc_synchronizer
182
 
183
`endif // SCR1_DBG_EN

powered by: WebSVN 2.1.0

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