OpenCores
URL https://opencores.org/ocsvn/fpga-cf/fpga-cf/trunk

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [hdl/] [port_clkcntl/] [port_clkcntl.v] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 peteralieb
module port_clkcntl (
2
// Clock control module for PATLPP port interface
3
 
4
        // Inputs:
5
        clk,
6
        rst,
7
        en,                             // Module Enable
8
        in_data,                        // Input Data
9
        in_sof,                 // Input Start of Frame
10
        in_eof,                 // Input End of Frame
11
        in_src_rdy,             // Input Source Ready
12
        out_dst_rdy,    // Output Destination Ready
13
 
14
        usr_clk_in,             // User clock in
15
 
16
        // Outputs:
17
        out_data,               // Output Data
18
        out_sof,                        // Output Start of Frame
19
        out_eof,                        // Output End of Frame
20
        out_src_rdy,    // Output Source Ready
21
        in_dst_rdy,             // Input Destination Ready
22
 
23 8 peteralieb
        usr_clk_out,    // User clock out
24
        usr_rst_out             // User reset signal
25 2 peteralieb
);
26
 
27
// Port mode declarations:
28
        // Inputs:
29
input   clk;
30
input   rst;
31
input   en;
32
input   [7:0]    in_data;
33
input   in_sof;
34
input   in_eof;
35
input   in_src_rdy;
36
input   out_dst_rdy;
37
input usr_clk_in;
38
 
39
        // Outputs:
40
output  [7:0]    out_data;
41
output  out_sof;
42
output  out_eof;
43
output  out_src_rdy;
44
output  in_dst_rdy;
45
output  usr_clk_out;
46 8 peteralieb
output  usr_rst_out;
47 2 peteralieb
 
48
// Control Register Masks
49
`define START           1
50
`define FREERUN 2
51
reg     [7:0]            control_reg;
52
// Termination Count Register
53
reg     [31:0]   termination_count_reg;
54
reg     [31:0]   termination_count_reg_r;
55
 
56
assign in_dst_rdy = 1;
57
assign out_data = 0;
58
assign out_sof = 0;
59
assign out_eof = 0;
60
assign out_src_rdy = 0;
61 8 peteralieb
assign usr_rst_out = control_reg[2];
62 2 peteralieb
 
63
always @(posedge clk or posedge rst)
64
begin
65
        if (rst)
66
        begin
67
                control_reg <= 8'b00000000;
68
                termination_count_reg_r <= 32'd0;
69
        end
70
        else if (en & in_src_rdy & in_eof)
71
        begin
72
                control_reg <= in_data;
73
                termination_count_reg_r <= termination_count_reg;
74
        end
75
end
76
 
77
 
78
always @(posedge clk or posedge rst)
79
begin
80
        if (rst)
81
        begin
82
                termination_count_reg <= 0;
83
        end
84
        else if (en & in_src_rdy & ~in_eof)
85
        begin
86
                termination_count_reg[31:24] <= termination_count_reg[23:16];
87
                termination_count_reg[23:16] <= termination_count_reg[15:8];
88
                termination_count_reg[15:8] <= termination_count_reg[7:0];
89
                termination_count_reg[7:0] <= in_data;
90
        end
91
end
92
 
93
// The follow code was adapted from a clock control circuit by Brad Hutchings
94
 
95
clockcntl theclockcntl (
96
        .reset (rst),
97
        .userResetInternal (rst),
98
        .baseClock (usr_clk_in),
99
        .terminationCountRegister (termination_count_reg_r),
100
        .configurationRegister (control_reg),
101
        .gatedClock (usr_clk_out)
102
        );
103
 
104
endmodule

powered by: WebSVN 2.1.0

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