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

Subversion Repositories hpdmc

[/] [hpdmc/] [trunk/] [hpdmc_ddr32/] [test/] [iddr.v] - Blame information for rev 21

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 lekernel
///////////////////////////////////////////////////////////////////////////////
2
// Copyright (c) 1995/2005 Xilinx, Inc.
3
// All Right Reserved.
4
///////////////////////////////////////////////////////////////////////////////
5
// Modified for HPDMC simulation, based on Xilinx 05/29/07 revision
6
///////////////////////////////////////////////////////////////////////////////
7
 
8
 
9
module IDDR #(
10
        parameter DDR_CLK_EDGE = "OPPOSITE_EDGE",
11
        parameter INIT_Q1 = 1'b0,
12
        parameter INIT_Q2 = 1'b0,
13
        parameter SRTYPE = "SYNC"
14
) (
15
        output Q1,
16
        output Q2,
17
        input C,
18
        input CE,
19
        input D,
20
        input R,
21
        input S
22
);
23
 
24
reg q1_out = INIT_Q1, q2_out = INIT_Q2;
25
reg q1_out_int, q2_out_int;
26
reg q1_out_pipelined, q2_out_same_edge_int;
27
 
28
wire c_in;
29
wire ce_in;
30
wire d_in;
31
wire gsr_in;
32
wire r_in;
33
wire s_in;
34
 
35
buf buf_c(c_in, C);
36
buf buf_ce(ce_in, CE);
37
buf buf_d(d_in, D);
38
buf buf_q1(Q1, q1_out);
39
buf buf_q2(Q2, q2_out);
40
buf buf_r(r_in, R);
41
buf buf_s(s_in, S);
42
 
43
initial begin
44
        if((INIT_Q1 != 0) && (INIT_Q1 != 1)) begin
45
                $display("Attribute Syntax Error : The attribute INIT_Q1 on IDDR instance %m is set to %d.  Legal values for this attribute are 0 or 1.", INIT_Q1);
46
                $finish;
47
        end
48
 
49
        if((INIT_Q2 != 0) && (INIT_Q2 != 1)) begin
50
                $display("Attribute Syntax Error : The attribute INIT_Q1 on IDDR instance %m is set to %d.  Legal values for this attribute are 0 or 1.", INIT_Q2);
51
                $finish;
52
        end
53
 
54
        if((DDR_CLK_EDGE != "OPPOSITE_EDGE") && (DDR_CLK_EDGE != "SAME_EDGE") && (DDR_CLK_EDGE != "SAME_EDGE_PIPELINED")) begin
55
                $display("Attribute Syntax Error : The attribute DDR_CLK_EDGE on IDDR instance %m is set to %s.  Legal values for this attribute are OPPOSITE_EDGE, SAME_EDGE or SAME_EDGE_PIPELINED.", DDR_CLK_EDGE);
56
                $finish;
57
        end
58
 
59
        if((SRTYPE != "ASYNC") && (SRTYPE != "SYNC")) begin
60
                $display("Attribute Syntax Error : The attribute SRTYPE on IDDR instance %m is set to %s.  Legal values for this attribute are ASYNC or SYNC.", SRTYPE);
61
                $finish;
62
        end
63
end
64
 
65
always @(r_in, s_in) begin
66
        if(r_in == 1'b1 && SRTYPE == "ASYNC") begin
67
                assign q1_out_int = 1'b0;
68
                assign q1_out_pipelined = 1'b0;
69
                assign q2_out_same_edge_int = 1'b0;
70
                assign q2_out_int = 1'b0;
71
        end else if(r_in == 1'b0 && s_in == 1'b1 && SRTYPE == "ASYNC") begin
72
                assign q1_out_int = 1'b1;
73
                assign q1_out_pipelined = 1'b1;
74
                assign q2_out_same_edge_int = 1'b1;
75
                assign q2_out_int = 1'b1;
76
        end else if((r_in == 1'b1 || s_in == 1'b1) && SRTYPE == "SYNC") begin
77
                deassign q1_out_int;
78
                deassign q1_out_pipelined;
79
                deassign q2_out_same_edge_int;
80
                deassign q2_out_int;
81
        end else if(r_in == 1'b0 && s_in == 1'b0) begin
82
                deassign q1_out_int;
83
                deassign q1_out_pipelined;
84
                deassign q2_out_same_edge_int;
85
                deassign q2_out_int;
86
        end
87
end
88
 
89
always @(posedge c_in) begin
90
        if(r_in == 1'b1) begin
91
                q1_out_int <= 1'b0;
92
                q1_out_pipelined <= 1'b0;
93
                q2_out_same_edge_int <= 1'b0;
94
        end else if(r_in == 1'b0 && s_in == 1'b1) begin
95
                q1_out_int <= 1'b1;
96
                q1_out_pipelined <= 1'b1;
97
                q2_out_same_edge_int <= 1'b1;
98
        end else if(ce_in == 1'b1 && r_in == 1'b0 && s_in == 1'b0) begin
99
                q1_out_int <= d_in;
100
                q1_out_pipelined <= q1_out_int;
101
                q2_out_same_edge_int <= q2_out_int;
102
        end
103
end
104
 
105
always @(negedge c_in) begin
106
        if(r_in == 1'b1)
107
                q2_out_int <= 1'b0;
108
        else if(r_in == 1'b0 && s_in == 1'b1)
109
                q2_out_int <= 1'b1;
110
        else if(ce_in == 1'b1 && r_in == 1'b0 && s_in == 1'b0)
111
                q2_out_int <= d_in;
112
end
113
 
114
always @(c_in, q1_out_int, q2_out_int, q2_out_same_edge_int, q1_out_pipelined) begin
115
        case(DDR_CLK_EDGE)
116
                "OPPOSITE_EDGE" : begin
117
                        q1_out <= q1_out_int;
118
                        q2_out <= q2_out_int;
119
                end
120
                "SAME_EDGE" : begin
121
                        q1_out <= q1_out_int;
122
                        q2_out <= q2_out_same_edge_int;
123
                end
124
                "SAME_EDGE_PIPELINED" : begin
125
                        q1_out <= q1_out_pipelined;
126
                        q2_out <= q2_out_same_edge_int;
127
                end
128
                default: begin
129
                        $display("Attribute Syntax Error : The attribute DDR_CLK_EDGE on IDDR instance %m is set to %s.  Legal values for this attribute are OPPOSITE_EDGE, SAME_EDGE or SAME_EDGE_PIPELINED.", DDR_CLK_EDGE);
130
                        $finish;
131
                end
132
        endcase
133
end
134
 
135
endmodule

powered by: WebSVN 2.1.0

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