dpdff0401.vmd
1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**************************************************************/
/* Verilog module of datapath cell dpdff0401 */
/* Designed by Linda J. Xu Compass Nov. 23, 1992 */
/* */
/* The following is the port description */
/* Data ports */
/* D0 : the input port */
/* D1 : the input port */
/* Q : the output port */
/* Control ports */
/* INST_CP : the clock signal */
/* INST : the select signal */
/* Parameters */
/* WORDSIZE : the word size of the datapath cell */
/* DELAY : the delay time from input to output */
/* */
/* When the clock signal changes from unknown to 1 or */
/* from 0 to unknown, the output will be unknown. */
/**************************************************************/
module dpdff0401(D0, D1, Q, INST_CP, INST);
parameter WORDSIZE = 8, DELAY = 4, BF = 1;
input [WORDSIZE-1:0] D0, D1;
output [WORDSIZE-1:0] Q;
input INST_CP, INST;
reg [WORDSIZE-1:0] Q;
reg flag;
initial Q = {WORDSIZE{1'bx}};
initial flag = 1'b0;
function [WORDSIZE-1:0] dff;
input [WORDSIZE-1:0] d0, d1;
begin
case (INST)
1'b 0 : dff = ~(~d0);
1'b 1 : dff = ~(~d1);
default dff = {WORDSIZE{1'b x}};
endcase
end
endfunction
always @ ( posedge INST_CP )
if ((INST_CP === 1'b1) && (flag === 1'b0))
Q = #DELAY dff(D0, D1);
else
begin
Q = {WORDSIZE{1'b x}};
flag = 1'b1;
end
always @ (negedge INST_CP)
if (INST_CP === 1'b0)
flag = 1'b0;
else
flag = 1'b1;
endmodule