source: XOpenSparcT1/trunk/T1-common/common/swrvr_clib.v @ 6

Revision 6, 21.1 KB checked in by pntsvt00, 13 years ago (diff)

versione iniziale opensparc

Line 
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T1 Processor File: swrvr_clib.v
4// Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
5// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6//
7// The above named program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public
9// License version 2 as published by the Free Software Foundation.
10//
11// The above named program is distributed in the hope that it will be
12// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public
17// License along with this work; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19//
20// ========== Copyright Header End ============================================
21///////////////////////////////////////////////////////////////////////
22/*
23//
24//  Module Name: swrvr_clib.v
25//      Description: Design control behavioural library
26*/                 
27
28`ifdef FPGA_SYN 
29`define NO_SCAN
30`endif
31
32// POSITVE-EDGE TRIGGERED FLOP with SCAN
33module dff_s (din, clk, q, se, si, so);
34// synopsys template
35
36parameter SIZE = 1;
37
38input   [SIZE-1:0]      din ;   // data in
39input                   clk ;   // clk or scan clk
40
41output  [SIZE-1:0]      q ;     // output
42
43input                   se ;    // scan-enable
44input   [SIZE-1:0]      si ;    // scan-input
45output  [SIZE-1:0]      so ;    // scan-output
46
47reg     [SIZE-1:0]      q ;
48
49`ifdef NO_SCAN
50always @ (posedge clk)
51  q[SIZE-1:0]  <= din[SIZE-1:0] ;
52`else
53
54always @ (posedge clk)
55
56        q[SIZE-1:0]  <= (se) ? si[SIZE-1:0]  : din[SIZE-1:0] ;
57
58assign so[SIZE-1:0] = q[SIZE-1:0] ;
59
60`endif
61
62endmodule // dff_s
63
64// POSITVE-EDGE TRIGGERED FLOP with SCAN for Shadow-scan
65module dff_sscan (din, clk, q, se, si, so);
66// synopsys template
67
68parameter SIZE = 1;
69
70input   [SIZE-1:0]      din ;   // data in
71input                   clk ;   // clk or scan clk
72
73output  [SIZE-1:0]      q ;     // output
74
75input                   se ;    // scan-enable
76input   [SIZE-1:0]      si ;    // scan-input
77output  [SIZE-1:0]      so ;    // scan-output
78
79reg     [SIZE-1:0]      q ;
80
81`ifdef CONNECT_SHADOW_SCAN
82
83always @ (posedge clk)
84
85        q[SIZE-1:0]  <= (se) ? si[SIZE-1:0]  : din[SIZE-1:0] ;
86
87assign so[SIZE-1:0] = q[SIZE-1:0] ;
88
89`else
90always @ (posedge clk)
91  q[SIZE-1:0]  <= din[SIZE-1:0] ;
92
93assign so={SIZE{1'b0}};
94`endif
95
96endmodule // dff_sscan
97
98// POSITVE-EDGE TRIGGERED FLOP without SCAN
99module dff_ns (din, clk, q);
100// synopsys template
101
102parameter SIZE = 1;
103
104input   [SIZE-1:0]      din ;   // data in
105input                   clk ;   // clk
106
107output  [SIZE-1:0]      q ;     // output
108
109reg     [SIZE-1:0]      q ;
110
111always @ (posedge clk)
112
113        q[SIZE-1:0]  <= din[SIZE-1:0] ;
114
115endmodule // dff_ns
116
117// POSITIVE-EDGE TRIGGERED FLOP with SCAN, RESET
118module dffr_s (din, clk, rst, q, se, si, so);
119// synopsys template
120
121parameter SIZE = 1;
122
123input   [SIZE-1:0]      din ;   // data in
124input                   clk ;   // clk or scan clk
125input                   rst ;   // reset
126
127output  [SIZE-1:0]      q ;     // output
128
129input                   se ;    // scan-enable
130input   [SIZE-1:0]      si ;    // scan-input
131output  [SIZE-1:0]      so ;    // scan-output
132
133reg     [SIZE-1:0]      q ;
134
135`ifdef NO_SCAN
136always @ (posedge clk)
137        q[SIZE-1:0]  <= ((rst) ? {SIZE{1'b0}}  : din[SIZE-1:0] );
138`else
139
140// Scan-Enable dominates
141always @ (posedge clk)
142
143        q[SIZE-1:0]  <= se ? si[SIZE-1:0] : ((rst) ? {SIZE{1'b0}}  : din[SIZE-1:0] );
144
145assign so[SIZE-1:0] = q[SIZE-1:0] ;
146`endif
147
148endmodule // dffr_s
149
150// POSITIVE-EDGE TRIGGERED FLOP with SCAN, RESET_L
151module dffrl_s (din, clk, rst_l, q, se, si, so);
152// synopsys template
153
154parameter SIZE = 1;
155
156input   [SIZE-1:0]      din ;   // data in
157input                   clk ;   // clk or scan clk
158input                   rst_l ; // reset
159
160output  [SIZE-1:0]      q ;     // output
161
162input                   se ;    // scan-enable
163input   [SIZE-1:0]      si ;    // scan-input
164output  [SIZE-1:0]      so ;    // scan-output
165
166reg     [SIZE-1:0]      q ;
167
168`ifdef NO_SCAN
169always @ (posedge clk)
170        q[SIZE-1:0]  <= rst_l ? din[SIZE-1:0] : {SIZE{1'b0}};
171`else
172
173// Reset dominates
174always @ (posedge clk)
175
176        q[SIZE-1:0]  <= rst_l ? ((se) ? si[SIZE-1:0]  : din[SIZE-1:0] ) : {SIZE{1'b0}};
177
178assign so[SIZE-1:0] = q[SIZE-1:0] ;
179`endif
180
181endmodule // dffrl_s
182
183// POSITIVE-EDGE TRIGGERED FLOP with RESET, without SCAN
184module dffr_ns (din, clk, rst, q);
185// synopsys template
186
187parameter SIZE = 1;
188
189input   [SIZE-1:0]      din ;   // data in
190input                   clk ;   // clk
191input                   rst ;   // reset
192
193output  [SIZE-1:0]      q ;     // output
194
195reg     [SIZE-1:0]      q ;
196
197// synopsys sync_set_reset "rst"
198always @ (posedge clk)
199  q[SIZE-1:0] <= rst ? {SIZE{1'b0}} : din[SIZE-1:0];
200   
201endmodule // dffr_ns
202
203// POSITIVE-EDGE TRIGGERED FLOP with RESET_L, without SCAN
204module dffrl_ns (din, clk, rst_l, q);
205// synopsys template
206
207parameter SIZE = 1;
208
209input   [SIZE-1:0]      din ;   // data in
210input                   clk ;   // clk
211input                   rst_l ; // reset
212
213output  [SIZE-1:0]      q ;     // output
214
215reg     [SIZE-1:0]      q ;
216
217// synopsys sync_set_reset "rst_l"
218always @ (posedge clk)
219  q[SIZE-1:0] <= rst_l ? din[SIZE-1:0] : {SIZE{1'b0}};
220
221endmodule // dffrl_ns
222
223// POSITIVE-EDGE TRIGGERED FLOP with SCAN and FUNCTIONAL ENABLE
224module dffe_s (din, en, clk, q, se, si, so);
225// synopsys template
226
227parameter SIZE = 1;
228
229input   [SIZE-1:0]      din ;   // data in
230input                   en ;    // functional enable
231input                   clk ;   // clk or scan clk
232
233output  [SIZE-1:0]      q ;     // output
234
235input                   se ;    // scan-enable
236input   [SIZE-1:0]      si ;    // scan-input
237output  [SIZE-1:0]      so ;    // scan-output
238
239reg     [SIZE-1:0]      q ;
240
241// Enable Interpretation. Ultimate interpretation depends on design
242//
243// en   se      out
244//------------------
245// x    1       sin ; scan dominates
246// 1    0       din
247// 0    0       q
248//
249
250`ifdef NO_SCAN
251always @ (posedge clk)
252        q[SIZE-1:0]  <= ((en) ? din[SIZE-1:0] : q[SIZE-1:0]) ;
253`else
254
255always @ (posedge clk)
256
257        q[SIZE-1:0]  <= (se) ? si[SIZE-1:0]  : ((en) ? din[SIZE-1:0] : q[SIZE-1:0]) ;
258
259assign so[SIZE-1:0] = q[SIZE-1:0] ;
260`endif
261
262endmodule // dffe_s
263
264// POSITIVE-EDGE TRIGGERED FLOP with enable, without SCAN
265module dffe_ns (din, en, clk, q);
266// synopsys template
267
268parameter SIZE = 1;
269
270input   [SIZE-1:0]      din ;   // data in
271input                   en ;    // functional enable
272input                   clk ;   // clk
273
274output  [SIZE-1:0]      q ;     // output
275
276reg     [SIZE-1:0]      q ;
277
278always @ (posedge clk)
279  q[SIZE-1:0] <= en ? din[SIZE-1:0] : q[SIZE-1:0];
280
281endmodule // dffe_ns
282
283// POSITIVE-EDGE TRIGGERED FLOP with RESET, FUNCTIONAL ENABLE, SCAN.
284module dffre_s (din, rst, en, clk, q, se, si, so);
285// synopsys template
286
287parameter SIZE = 1;
288
289input   [SIZE-1:0]      din ;   // data in
290input                   en ;    // functional enable
291input                   rst ;   // reset
292input                   clk ;   // clk or scan clk
293
294output  [SIZE-1:0]      q ;     // output
295
296input                   se ;    // scan-enable
297input   [SIZE-1:0]      si ;    // scan-input
298output  [SIZE-1:0]      so ;    // scan-output
299
300reg     [SIZE-1:0]      q ;
301
302// Enable Interpretation. Ultimate interpretation depends on design
303//
304// rst  en      se      out
305//------------------
306// 1    x       x       0   ; reset dominates
307// 0    x       1       sin ; scan dominates
308// 0    1       0       din
309// 0    0       0       q
310//
311
312`ifdef NO_SCAN
313always @ (posedge clk)
314        q[SIZE-1:0]  <= (rst ? {SIZE{1'b0}} : ((en) ? din[SIZE-1:0] : q[SIZE-1:0])) ;
315`else
316
317always @ (posedge clk)
318
319//      q[SIZE-1:0]  <= rst ? {SIZE{1'b0}} : ((se) ? si[SIZE-1:0]  : ((en) ? din[SIZE-1:0] : q[SIZE-1:0])) ;
320        q[SIZE-1:0]  <= se ? si[SIZE-1:0]  : (rst ? {SIZE{1'b0}} : ((en) ? din[SIZE-1:0] : q[SIZE-1:0])) ;
321
322assign so[SIZE-1:0] = q[SIZE-1:0] ;
323
324`endif
325
326endmodule // dffre_s
327
328// POSITIVE-EDGE TRIGGERED FLOP with RESET_L, FUNCTIONAL ENABLE, SCAN.
329module dffrle_s (din, rst_l, en, clk, q, se, si, so);
330// synopsys template
331
332parameter SIZE = 1;
333
334input   [SIZE-1:0]      din ;   // data in
335input                   en ;    // functional enable
336input                   rst_l ; // reset
337input                   clk ;   // clk or scan clk
338
339output  [SIZE-1:0]      q ;     // output
340
341input                   se ;    // scan-enable
342input   [SIZE-1:0]      si ;    // scan-input
343output  [SIZE-1:0]      so ;    // scan-output
344
345reg     [SIZE-1:0]      q ;
346
347// Enable Interpretation. Ultimate interpretation depends on design
348//
349// rst  en      se      out
350//------------------
351// 0    x       x       0   ; reset dominates
352// 1    x       1       sin ; scan dominates
353// 1    1       0       din
354// 1    0       0       q
355//
356
357`ifdef NO_SCAN
358always @ (posedge clk)
359         q[SIZE-1:0]  <= (rst_l ? ((en) ? din[SIZE-1:0] : q[SIZE-1:0]) : {SIZE{1'b0}}) ;
360`else
361
362always @ (posedge clk)
363
364//      q[SIZE-1:0]  <= rst_l ? ((se) ? si[SIZE-1:0]  : ((en) ? din[SIZE-1:0] : q[SIZE-1:0])) : {SIZE{1'b0}} ;
365        q[SIZE-1:0]  <= se ? si[SIZE-1:0]  : (rst_l ? ((en) ? din[SIZE-1:0] : q[SIZE-1:0]) : {SIZE{1'b0}}) ;
366
367assign so[SIZE-1:0] = q[SIZE-1:0] ;
368`endif
369
370endmodule // dffrle_s
371
372// POSITIVE-EDGE TRIGGERED FLOP with RESET, ENABLE, without SCAN.
373module dffre_ns (din, rst, en, clk, q);
374// synopsys template
375
376parameter SIZE = 1;
377
378input   [SIZE-1:0]      din ;   // data in
379input                   en ;    // functional enable
380input                   rst ;   // reset
381input                   clk ;   // clk
382
383output  [SIZE-1:0]      q ;     // output
384
385reg     [SIZE-1:0]      q ;
386
387// Enable Interpretation. Ultimate interpretation depends on design
388//
389// rst  en      out
390//------------------
391// 1    x       0   ; reset dominates
392// 0    1       din
393// 0    0       q
394//
395
396// synopsys sync_set_reset "rst"
397always @ (posedge clk)
398  q[SIZE-1:0] <= rst ? {SIZE{1'b0}} : ((en) ? din[SIZE-1:0] : q[SIZE-1:0]);
399
400endmodule // dffre_ns
401
402// POSITIVE-EDGE TRIGGERED FLOP with RESET_L, ENABLE, without SCAN.
403module dffrle_ns (din, rst_l, en, clk, q);
404// synopsys template
405
406parameter SIZE = 1;
407
408input   [SIZE-1:0]      din ;   // data in
409input                   en ;    // functional enable
410input                   rst_l ; // reset
411input                   clk ;   // clk
412
413output  [SIZE-1:0]      q ;     // output
414
415reg     [SIZE-1:0]      q ;
416
417// Enable Interpretation. Ultimate interpretation depends on design
418//
419// rst  en      out
420//------------------
421// 0    x       0   ; reset dominates
422// 1    1       din
423// 1    0       q
424//
425
426// synopsys sync_set_reset "rst_l"
427always @ (posedge clk)
428  q[SIZE-1:0] <= rst_l ? ((en) ? din[SIZE-1:0] : q[SIZE-1:0]) : {SIZE{1'b0}} ;
429
430endmodule // dffrle_ns
431
432// POSITIVE-EDGE TRIGGERED FLOP with SCAN, and ASYNC RESET
433module dffr_async (din, clk, rst, q, se, si, so);
434// synopsys template
435
436parameter SIZE = 1;
437
438input   [SIZE-1:0]      din ;   // data in
439input                   clk ;   // clk or scan clk
440input                   rst ;   // reset
441
442output  [SIZE-1:0]      q ;     // output
443
444input                   se ;    // scan-enable
445input   [SIZE-1:0]      si ;    // scan-input
446output  [SIZE-1:0]      so ;    // scan-output
447
448reg     [SIZE-1:0]      q ;
449
450`ifdef NO_SCAN
451always @ (posedge clk or posedge rst)
452        q[SIZE-1:0]  <= rst ? {SIZE{1'b0}} : din[SIZE-1:0];
453`else
454
455// Reset dominates
456always @ (posedge clk or posedge rst)
457  q[SIZE-1:0]  <= rst ? {SIZE{1'b0}} : ((se) ? si[SIZE-1:0]  : din[SIZE-1:0] );
458
459assign so[SIZE-1:0] = q[SIZE-1:0] ;
460
461`endif
462
463endmodule // dffr_async
464
465// POSITIVE-EDGE TRIGGERED FLOP with SCAN, and ASYNC RESET_L
466module dffrl_async (din, clk, rst_l, q, se, si, so);
467// synopsys template
468
469parameter SIZE = 1;
470
471input   [SIZE-1:0]      din ;   // data in
472input                   clk ;   // clk or scan clk
473input                   rst_l ;   // reset
474
475output  [SIZE-1:0]      q ;     // output
476
477input                   se ;    // scan-enable
478input   [SIZE-1:0]      si ;    // scan-input
479output  [SIZE-1:0]      so ;    // scan-output
480
481reg     [SIZE-1:0]      q ;
482
483`ifdef NO_SCAN
484always @ (posedge clk or negedge rst_l)
485        q[SIZE-1:0]  <= (!rst_l) ? {SIZE{1'b0}} : din[SIZE-1:0];
486`else
487
488// Reset dominates
489always @ (posedge clk or negedge rst_l)
490  q[SIZE-1:0]  <= (!rst_l) ? {SIZE{1'b0}} : ((se) ? si[SIZE-1:0]  : din[SIZE-1:0] );
491
492assign so[SIZE-1:0] = q[SIZE-1:0] ;
493
494`endif
495
496endmodule // dffrl_async
497
498// POSITIVE-EDGE TRIGGERED FLOP with ASYNC RESET, without SCAN
499//module dffr_async_ns (din, clk, rst, q);
500//// synopsys template
501//parameter SIZE = 1;
502//input   [SIZE-1:0]      din ;   // data in
503//input                   clk ;   // clk or scan clk
504//input                   rst ;   // reset
505//output  [SIZE-1:0]      q ;     // output
506//reg     [SIZE-1:0]      q ;
507// Reset dominates
508//// synopsys async_set_reset "rst"
509//always @ (posedge clk or posedge rst)
510//        if(rst) q[SIZE-1:0]  <= {SIZE{1'b0}};
511//        else if(clk) q[SIZE-1:0]  <= din[SIZE-1:0];
512//endmodule // dffr_async_ns
513
514// POSITIVE-EDGE TRIGGERED FLOP with ASYNC RESET_L, without SCAN
515module dffrl_async_ns (din, clk, rst_l, q);
516// synopsys template
517
518parameter SIZE = 1;
519
520input   [SIZE-1:0]      din ;   // data in
521input                   clk ;   // clk or scan clk
522input                   rst_l ;   // reset
523
524output  [SIZE-1:0]      q ;     // output
525
526// Reset dominates
527// synopsys async_set_reset "rst_l"
528 reg [SIZE-1:0] q;   
529always @ (posedge clk or negedge rst_l)
530  q[SIZE-1:0] <= ~rst_l ?  {SIZE{1'b0}} : ({SIZE{rst_l}} & din[SIZE-1:0]);
531
532//   reg  [SIZE-1:0]   qm, qs, qm_l, qs_l, qm_f, qs_f;
533//   wire              s_l;
534//   assign            s_l = 1'b1;
535//
536//   always @ (rst_l or qm)   qm_l = ~(qm & {SIZE{rst_l}});
537//   always @ (s_l or qs)   qs_l = ~(qs & {SIZE{s_l}});
538//   always @ (s_l or qm_l) qm_f = ~(qm_l & {SIZE{s_l}});
539//   always @ (rst_l or qs_l) qs_f = ~(qs_l & {SIZE{rst_l}});
540//
541//   always @ (clk or din or qm_f)
542//      qm <= clk ? qm_f : din;
543//
544//   always @ (clk or qm_l or qs_f)
545//      qs <= clk ? qm_l : qs_f;
546//
547//   assign q  = ~qs;
548
549endmodule // dffrl_async_ns
550
551// 2:1 MUX WITH DECODED SELECTS
552module mux2ds (dout, in0, in1, sel0, sel1) ;
553// synopsys template
554
555parameter SIZE = 1;
556
557output  [SIZE-1:0]      dout;
558input   [SIZE-1:0]      in0;
559input   [SIZE-1:0]      in1;
560input                   sel0;
561input                   sel1;
562
563// reg declaration does not imply state being maintained
564// across cycles. Used to construct case statement and
565// always updated by inputs every cycle.
566reg     [SIZE-1:0]      dout ;
567
568// priority encoding takes care of mutex'ing selects.
569`ifdef VERPLEX
570   $constraint cl_1h_chk2 ($one_hot ({sel1,sel0}));
571`endif
572
573wire [1:0] sel = {sel1, sel0}; // 0in one_hot
574   
575always @ (sel0 or sel1 or in0 or in1)
576
577        case ({sel1,sel0}) // synopsys infer_mux
578                2'b01 : dout = in0 ;
579                2'b10 : dout = in1 ;
580                2'b11 : dout = {SIZE{1'bx}} ;
581                2'b00 : dout = {SIZE{1'bx}} ;
582                        // 2'b00 : // E.g. 4state vs. 2state modelling.
583                        // begin
584                        //      `ifdef FOUR_STATE
585                        //              dout = {SIZE{1'bx}};
586                        //      `else
587                        //              begin
588                        //              dout = {SIZE{1'b0}};
589                        //              $error();
590                        //              end
591                        //      `endif
592                        // end
593                default : dout = {SIZE{1'bx}};
594        endcase
595
596endmodule // mux2ds
597
598// 3:1 MUX WITH DECODED SELECTS
599module mux3ds (dout, in0, in1, in2, sel0, sel1, sel2) ;
600// synopsys template
601
602parameter SIZE = 1;
603
604output  [SIZE-1:0]      dout;
605input   [SIZE-1:0]      in0;
606input   [SIZE-1:0]      in1;
607input   [SIZE-1:0]      in2;
608input                   sel0;
609input                   sel1;
610input                   sel2;
611
612// reg declaration does not imply state being maintained
613// across cycles. Used to construct case statement and
614// always updated by inputs every cycle.
615reg     [SIZE-1:0]      dout ;
616
617`ifdef VERPLEX
618   $constraint cl_1h_chk3 ($one_hot ({sel2,sel1,sel0}));
619`endif
620
621wire [2:0] sel = {sel2,sel1,sel0}; // 0in one_hot
622   
623// priority encoding takes care of mutex'ing selects.
624always @ (sel0 or sel1 or sel2 or in0 or in1 or in2)
625
626        case ({sel2,sel1,sel0}) 
627                3'b001 : dout = in0 ;
628                3'b010 : dout = in1 ;
629                3'b100 : dout = in2 ;
630                3'b000 : dout = {SIZE{1'bx}} ;
631                3'b011 : dout = {SIZE{1'bx}} ;
632                3'b101 : dout = {SIZE{1'bx}} ;
633                3'b110 : dout = {SIZE{1'bx}} ;
634                3'b111 : dout = {SIZE{1'bx}} ;
635                default : dout = {SIZE{1'bx}};
636                        // two state vs four state modelling will be added.
637        endcase
638
639endmodule // mux3ds
640
641// 4:1 MUX WITH DECODED SELECTS
642module mux4ds (dout, in0, in1, in2, in3, sel0, sel1, sel2, sel3) ;
643// synopsys template
644
645parameter SIZE = 1;
646
647output  [SIZE-1:0]      dout;
648input   [SIZE-1:0]      in0;
649input   [SIZE-1:0]      in1;
650input   [SIZE-1:0]      in2;
651input   [SIZE-1:0]      in3;
652input                   sel0;
653input                   sel1;
654input                   sel2;
655input                   sel3;
656
657// reg declaration does not imply state being maintained
658// across cycles. Used to construct case statement and
659// always updated by inputs every cycle.
660reg     [SIZE-1:0]      dout ;
661
662`ifdef VERPLEX
663   $constraint cl_1h_chk4 ($one_hot ({sel3,sel2,sel1,sel0}));
664`endif
665   
666wire [3:0] sel = {sel3,sel2,sel1,sel0}; // 0in one_hot
667   
668// priority encoding takes care of mutex'ing selects.
669always @ (sel0 or sel1 or sel2 or sel3 or in0 or in1 or in2 or in3)
670
671        case ({sel3,sel2,sel1,sel0}) 
672                4'b0001 : dout = in0 ;
673                4'b0010 : dout = in1 ;
674                4'b0100 : dout = in2 ;
675                4'b1000 : dout = in3 ;
676                4'b0000 : dout = {SIZE{1'bx}} ;
677                4'b0011 : dout = {SIZE{1'bx}} ;
678                4'b0101 : dout = {SIZE{1'bx}} ;
679                4'b0110 : dout = {SIZE{1'bx}} ;
680                4'b0111 : dout = {SIZE{1'bx}} ;
681                4'b1001 : dout = {SIZE{1'bx}} ;
682                4'b1010 : dout = {SIZE{1'bx}} ;
683                4'b1011 : dout = {SIZE{1'bx}} ;
684                4'b1100 : dout = {SIZE{1'bx}} ;
685                4'b1101 : dout = {SIZE{1'bx}} ;
686                4'b1110 : dout = {SIZE{1'bx}} ;
687                4'b1111 : dout = {SIZE{1'bx}} ;
688                default : dout = {SIZE{1'bx}};
689                        // two state vs four state modelling will be added.
690        endcase
691
692endmodule // mux4ds
693
694// SINK FOR UNLOADED INPUT PORTS
695module sink (in);
696// synopsys template
697
698parameter SIZE = 1;
699
700input [SIZE-1:0] in;
701
702`ifdef FPGA_SYN
703   // As of version 8.2 XST does not remove this module without the
704   // following additional dead code
705
706   wire    a;
707
708   assign               a = | in;
709
710`endif
711
712endmodule //sink
713
714// SOURCE FOR UNDRIVEN OUTPUT PORTS
715module source (out) ;
716// synopsys template
717
718parameter SIZE = 1;
719
720output  [SIZE-1:0] out;
721//
722// Once 4state/2state model established
723// then enable check.
724// `ifdef FOUR_STATE
725// leda check for x_or_z_in rhs_of assign turned off
726// assign  out = {SIZE{1'bx}};
727//`else
728assign  out = {SIZE{1'b0}};
729//`endif
730
731endmodule //source
732
733// 2:1 MUX WITH PRIORITY ENCODED SELECTS
734//module mux2es (dout, in0, in1, sel0, sel1) ;
735//
736//parameter SIZE = 1;
737//
738//output        [SIZE-1:0]      dout;
739//input [SIZE-1:0]      in0;
740//input [SIZE-1:0]      in1;
741//input                 sel0;
742//input                 sel1;
743//
744//// reg declaration does not imply state being maintained
745//// across cycles. Used to construct case statement and
746//// always updated by inputs every cycle.
747//reg   [SIZE-1:0]      dout ;
748//
749//// must take into account lack of mutex selects.
750//// there is no reason for handling of x and z conditions.
751//// This will be dictated by design.
752//always @ (sel0 or sel1 or in0 or in1)
753//
754//      case ({sel1,sel0})
755//              2'b1x : dout = in1 ; // 10(in1),11(z)
756//              2'b0x : dout = in0 ; // 01(in0),00(x)
757//      endcase
758//
759//endmodule // mux2es
760
761// CLK Header for gating off the clock of
762// a FF.
763// clk - output of the clk header
764// rclk - input clk
765// enb_l - Active low clock enable
766// tmb_l  - Active low clock enable ( in scan mode, this input is !se )
767
768module clken_buf (clk, rclk, enb_l, tmb_l);
769output clk;
770input  rclk, enb_l, tmb_l;
771reg    clken;
772
773`ifdef FPGA_SYN
774   assign clk = rclk;
775`else
776  always @ (rclk or enb_l or tmb_l)
777    if (!rclk)  //latch opens on rclk low phase
778      clken = !enb_l | !tmb_l;
779  assign clk = clken & rclk;
780`endif
781endmodule
782
783
784
785// The following flops are maintained and used in ENET , MAC IP  ONLY
786// -- Mimi X61467
787
788// POSITIVE-EDGE TRIGGERED FLOP with SET_L, without SCAN.
789
790module dffsl_ns (din, clk, set_l, q);
791// synopsys template
792parameter SIZE = 1;
793
794input   [SIZE-1:0]      din ;   // data in
795input                   clk ;   // clk or scan clk
796input                   set_l ; // set
797
798output  [SIZE-1:0]      q ;     // output
799
800reg     [SIZE-1:0]      q ;
801
802// synopsys sync_set_reset "set_l"
803always @ (posedge clk)
804  q[SIZE-1:0] <= set_l ? din[SIZE-1:0] : {SIZE{1'b1}};
805
806endmodule // dffsl_ns
807
808// POSITIVE-EDGE TRIGGERED FLOP with SET_L, without SCAN.
809
810module dffsl_async_ns (din, clk, set_l, q);
811// synopsys template
812parameter SIZE = 1;
813
814input   [SIZE-1:0]      din ;   // data in
815input                   clk ;   // clk or scan clk
816input                   set_l ; // set
817
818output  [SIZE-1:0]      q ;     // output
819
820reg     [SIZE-1:0]      q ;
821
822// synopsys async_set_reset "set_l"
823always @ (posedge clk or negedge set_l)
824  q[SIZE-1:0] <= ~set_l ? {SIZE{1'b1}} : ({SIZE{~set_l}} | din[SIZE-1:0]);
825
826endmodule // dffsl_async_ns
827
828// POSITIVE-EDGE TRIGGERED FLOP WITH SET_H , without SCAN.
829
830module dffr_ns_r1 (din, clk, rst, q);
831// synopsys template
832parameter SIZE = 1;
833
834input   [SIZE-1:0]      din ;   // data in
835input                   clk ;   // clk or scan clk
836input                   rst ;   // reset
837
838output  [SIZE-1:0]      q ;     // output
839
840reg     [SIZE-1:0]      q ;
841
842// Set to 1
843// synopsys sync_set_reset "rst"
844always @ (posedge clk)
845  q[SIZE-1:0] <= rst ? {SIZE{1'b1}} : din[SIZE-1:0];
846
847endmodule // dffr_ns_r1
848
849// POSITIVE-EDGE TRIGGERED ASYNC RESET_H FLOP , without SCAN.
850
851module dffr_async_ns (din, clk, rst, q);
852// synopsys template
853
854parameter SIZE = 1;
855
856input   [SIZE-1:0]      din ;   // data in
857input                   clk ;   // clk or scan clk
858input                   rst;   // reset
859
860output  [SIZE-1:0]      q ;     // output
861
862reg     [SIZE-1:0]      q ;
863
864// Reset dominates
865// synopsys async_set_reset "rst"
866always @ (posedge clk or posedge rst)
867  q[SIZE-1:0] <= rst ? {SIZE{1'b0}} : din[SIZE-1:0];
868
869endmodule // dffr_async_ns
870
871// POSITIVE-EDGE TRIGGERED ASYNC SET_H FLOP , without SCAN.
872
873module dffr_async_ns_r1 (din, clk, rst, q);
874// synopsys template
875
876parameter SIZE = 1;
877
878input   [SIZE-1:0]      din ;   // data in
879input                   clk ;   // clk or scan clk
880input                   rst;   // reset
881
882output  [SIZE-1:0]      q ;     // output
883
884reg     [SIZE-1:0]      q ;
885
886// Reset to 1
887// synopsys async_set_reset "rst"
888always @ (posedge clk or posedge rst)
889  q[SIZE-1:0] <= rst ? {SIZE{1'b1}} : din[SIZE-1:0];
890
891endmodule // dffr_async_ns_r1
892
893
894// NEGATIVE-EDGE TRIGGERED ASYNC SET_H FLOP , without SCAN.
895
896module dffr_async_ns_cl_r1 (din, clkl, rst, q);
897// synopsys template
898parameter SIZE = 1;
899
900input   [SIZE-1:0]      din ;   // data in
901input                   clkl ;  // clk or scan clk
902input                   rst ;   // reset
903
904output  [SIZE-1:0]      q ;     // output
905
906reg     [SIZE-1:0]      q ;
907
908// Set to 1
909// synopsys sync_set_reset "rst"
910always @ (negedge clkl or posedge rst)
911  q[SIZE-1:0] <= rst ? {SIZE{1'b1}} : din[SIZE-1:0];
912
913endmodule // dffr_async_ns_cl_r1
914
Note: See TracBrowser for help on using the repository browser.