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 2

Go to most recent revision | 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
        usr_clk_out             // User clock out
24
);
25
 
26
// Port mode declarations:
27
        // Inputs:
28
input   clk;
29
input   rst;
30
input   en;
31
input   [7:0]    in_data;
32
input   in_sof;
33
input   in_eof;
34
input   in_src_rdy;
35
input   out_dst_rdy;
36
input usr_clk_in;
37
 
38
        // Outputs:
39
output  [7:0]    out_data;
40
output  out_sof;
41
output  out_eof;
42
output  out_src_rdy;
43
output  in_dst_rdy;
44
output  usr_clk_out;
45
 
46
// Control Register Masks
47
`define START           1
48
`define FREERUN 2
49
reg     [7:0]            control_reg;
50
// Termination Count Register
51
reg     [31:0]   termination_count_reg;
52
reg     [31:0]   termination_count_reg_r;
53
 
54
assign in_dst_rdy = 1;
55
assign out_data = 0;
56
assign out_sof = 0;
57
assign out_eof = 0;
58
assign out_src_rdy = 0;
59
 
60
always @(posedge clk or posedge rst)
61
begin
62
        if (rst)
63
        begin
64
                control_reg <= 8'b00000000;
65
                termination_count_reg_r <= 32'd0;
66
        end
67
        else if (en & in_src_rdy & in_eof)
68
        begin
69
                control_reg <= in_data;
70
                termination_count_reg_r <= termination_count_reg;
71
        end
72
end
73
 
74
 
75
always @(posedge clk or posedge rst)
76
begin
77
        if (rst)
78
        begin
79
                termination_count_reg <= 0;
80
        end
81
        else if (en & in_src_rdy & ~in_eof)
82
        begin
83
                termination_count_reg[31:24] <= termination_count_reg[23:16];
84
                termination_count_reg[23:16] <= termination_count_reg[15:8];
85
                termination_count_reg[15:8] <= termination_count_reg[7:0];
86
                termination_count_reg[7:0] <= in_data;
87
        end
88
end
89
 
90
// The follow code was adapted from a clock control circuit by Brad Hutchings
91
 
92
clockcntl theclockcntl (
93
        .reset (rst),
94
        .userResetInternal (rst),
95
        .baseClock (usr_clk_in),
96
        .terminationCountRegister (termination_count_reg_r),
97
        .configurationRegister (control_reg),
98
        .gatedClock (usr_clk_out)
99
        );
100
 
101
endmodule

powered by: WebSVN 2.1.0

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