4 This file contains simulation models for GreenPAK cells which are possible to fully model using synthesizeable
5 behavioral Verilog constructs only.
8 module GP_2LUT(input IN0, IN1, output OUT);
9 parameter [3:0] INIT = 0;
10 assign OUT = INIT[{IN1, IN0}];
13 module GP_3LUT(input IN0, IN1, IN2, output OUT);
14 parameter [7:0] INIT = 0;
15 assign OUT = INIT[{IN2, IN1, IN0}];
25 parameter [15:0] INIT = 0;
26 assign OUT = INIT[{IN3, IN2, IN1, IN0}];
29 module GP_CLKBUF(input wire IN, output wire OUT);
33 module GP_COUNT14(input CLK, input wire RST, output reg OUT);
35 parameter RESET_MODE = "RISING";
37 parameter COUNT_TO = 14'h1;
38 parameter CLKIN_DIVIDE = 1;
40 reg[13:0] count = COUNT_TO;
43 if(CLKIN_DIVIDE != 1) begin
44 $display("ERROR: CLKIN_DIVIDE values other than 1 not implemented");
49 //Combinatorially output underflow flag whenever we wrap low
51 OUT <= (count == 14'h0);
54 //POR or SYSRST reset value is COUNT_TO. Datasheet is unclear but conversations w/ Silego confirm.
55 //Runtime reset value is clearly 0 except in count/FSM cells where it's configurable but we leave at 0 for now.
60 always @(posedge CLK or posedge RST) begin
61 count <= count - 1'd1;
71 always @(posedge CLK or negedge RST) begin
72 count <= count - 1'd1;
83 $display("Both-edge reset mode for GP_COUNT8 not implemented");
93 $display("Invalid RESET_MODE on GP_COUNT8");
103 module GP_COUNT14_ADV(input CLK, input RST, output reg OUT,
104 input UP, input KEEP, output reg[7:0] POUT);
106 parameter RESET_MODE = "RISING";
107 parameter RESET_VALUE = "ZERO";
109 parameter COUNT_TO = 14'h1;
110 parameter CLKIN_DIVIDE = 1;
113 if(CLKIN_DIVIDE != 1) begin
114 $display("ERROR: CLKIN_DIVIDE values other than 1 not implemented");
119 //Combinatorially output underflow flag whenever we wrap low
122 OUT <= (count == 14'h4000);
124 OUT <= (count == 14'h0);
128 //POR or SYSRST reset value is COUNT_TO. Datasheet is unclear but conversations w/ Silego confirm.
129 //Runtime reset value is clearly 0 except in count/FSM cells where it's configurable but we leave at 0 for now.
134 always @(posedge CLK or posedge RST) begin
140 count <= count + 1'd1;
142 count <= count - 1'd1;
145 if(count == 0 && !UP)
147 if(count == 14'h4000 && UP)
152 if(RESET_VALUE == "ZERO")
162 always @(posedge CLK or negedge RST) begin
168 count <= count + 1'd1;
170 count <= count - 1'd1;
173 if(count == 0 && !UP)
175 if(count == 14'h4000 && UP)
180 if(RESET_VALUE == "ZERO")
191 $display("Both-edge reset mode for GP_COUNT14_ADV not implemented");
201 $display("Invalid RESET_MODE on GP_COUNT14_ADV");
211 module GP_COUNT8_ADV(input CLK, input RST, output reg OUT,
212 input UP, input KEEP, output reg[7:0] POUT);
214 parameter RESET_MODE = "RISING";
215 parameter RESET_VALUE = "ZERO";
217 parameter COUNT_TO = 8'h1;
218 parameter CLKIN_DIVIDE = 1;
221 if(CLKIN_DIVIDE != 1) begin
222 $display("ERROR: CLKIN_DIVIDE values other than 1 not implemented");
227 //Combinatorially output underflow flag whenever we wrap low
230 OUT <= (count == 8'hff);
232 OUT <= (count == 8'h0);
236 //POR or SYSRST reset value is COUNT_TO. Datasheet is unclear but conversations w/ Silego confirm.
237 //Runtime reset value is clearly 0 except in count/FSM cells where it's configurable but we leave at 0 for now.
242 always @(posedge CLK or posedge RST) begin
248 count <= count + 1'd1;
250 count <= count - 1'd1;
253 if(count == 0 && !UP)
255 if(count == 8'hff && UP)
260 if(RESET_VALUE == "ZERO")
270 always @(posedge CLK or negedge RST) begin
276 count <= count + 1'd1;
278 count <= count - 1'd1;
281 if(count == 0 && !UP)
283 if(count == 8'hff && UP)
288 if(RESET_VALUE == "ZERO")
299 $display("Both-edge reset mode for GP_COUNT8_ADV not implemented");
309 $display("Invalid RESET_MODE on GP_COUNT8_ADV");
323 output reg[7:0] POUT);
325 parameter RESET_MODE = "RISING";
327 parameter COUNT_TO = 8'h1;
328 parameter CLKIN_DIVIDE = 1;
331 if(CLKIN_DIVIDE != 1) begin
332 $display("ERROR: CLKIN_DIVIDE values other than 1 not implemented");
337 reg[7:0] count = COUNT_TO;
339 //Combinatorially output underflow flag whenever we wrap low
341 OUT <= (count == 8'h0);
345 //POR or SYSRST reset value is COUNT_TO. Datasheet is unclear but conversations w/ Silego confirm.
346 //Runtime reset value is clearly 0 except in count/FSM cells where it's configurable but we leave at 0 for now.
351 always @(posedge CLK or posedge RST) begin
352 count <= count - 1'd1;
362 always @(posedge CLK or negedge RST) begin
363 count <= count - 1'd1;
374 $display("Both-edge reset mode for GP_COUNT8 not implemented");
384 $display("Invalid RESET_MODE on GP_COUNT8");
394 module GP_DCMPREF(output reg[7:0]OUT);
395 parameter[7:0] REF_VAL = 8'h00;
396 initial OUT = REF_VAL;
399 module GP_DCMPMUX(input[1:0] SEL, input[7:0] IN0, input[7:0] IN1, input[7:0] IN2, input[7:0] IN3, output reg[7:0] OUTA, output reg[7:0] OUTB);
427 module GP_DELAY(input IN, output reg OUT);
429 parameter DELAY_STEPS = 1;
430 parameter GLITCH_FILTER = 0;
436 if(GLITCH_FILTER) begin
438 $display("ERROR: GP_DELAY glitch filter mode not implemented");
443 //TODO: These delays are PTV dependent! For now, hard code 3v3 timing
444 //Change simulation-mode delay depending on global Vdd range (how to specify this?)
452 $display("ERROR: GP_DELAY must have DELAY_STEPS in range [1,4]");
462 module GP_DFF(input D, CLK, output reg Q);
463 parameter [0:0] INIT = 1'bx;
465 always @(posedge CLK) begin
470 module GP_DFFI(input D, CLK, output reg nQ);
471 parameter [0:0] INIT = 1'bx;
473 always @(posedge CLK) begin
478 module GP_DFFR(input D, CLK, nRST, output reg Q);
479 parameter [0:0] INIT = 1'bx;
481 always @(posedge CLK, negedge nRST) begin
489 module GP_DFFRI(input D, CLK, nRST, output reg nQ);
490 parameter [0:0] INIT = 1'bx;
492 always @(posedge CLK, negedge nRST) begin
500 module GP_DFFS(input D, CLK, nSET, output reg Q);
501 parameter [0:0] INIT = 1'bx;
503 always @(posedge CLK, negedge nSET) begin
511 module GP_DFFSI(input D, CLK, nSET, output reg nQ);
512 parameter [0:0] INIT = 1'bx;
514 always @(posedge CLK, negedge nSET) begin
522 module GP_DFFSR(input D, CLK, nSR, output reg Q);
523 parameter [0:0] INIT = 1'bx;
524 parameter [0:0] SRMODE = 1'bx;
526 always @(posedge CLK, negedge nSR) begin
534 module GP_DFFSRI(input D, CLK, nSR, output reg nQ);
535 parameter [0:0] INIT = 1'bx;
536 parameter [0:0] SRMODE = 1'bx;
538 always @(posedge CLK, negedge nSR) begin
546 module GP_DLATCH(input D, input nCLK, output reg Q);
547 parameter [0:0] INIT = 1'bx;
555 module GP_DLATCHI(input D, input nCLK, output reg nQ);
556 parameter [0:0] INIT = 1'bx;
564 module GP_DLATCHR(input D, input nCLK, input nRST, output reg Q);
565 parameter [0:0] INIT = 1'bx;
575 module GP_DLATCHRI(input D, input nCLK, input nRST, output reg nQ);
576 parameter [0:0] INIT = 1'bx;
586 module GP_DLATCHS(input D, input nCLK, input nSET, output reg Q);
587 parameter [0:0] INIT = 1'bx;
597 module GP_DLATCHSI(input D, input nCLK, input nSET, output reg nQ);
598 parameter [0:0] INIT = 1'bx;
608 module GP_DLATCHSR(input D, input nCLK, input nSR, output reg Q);
609 parameter [0:0] INIT = 1'bx;
610 parameter[0:0] SRMODE = 1'bx;
620 module GP_DLATCHSRI(input D, input nCLK, input nSR, output reg nQ);
621 parameter [0:0] INIT = 1'bx;
622 parameter[0:0] SRMODE = 1'bx;
632 module GP_IBUF(input IN, output OUT);
636 module GP_IOBUF(input IN, input OE, output OUT, inout IO);
638 assign IO = OE ? IN : 1'bz;
641 module GP_INV(input IN, output OUT);
645 module GP_OBUF(input IN, output OUT);
649 module GP_OBUFT(input IN, input OE, output OUT);
650 assign OUT = OE ? IN : 1'bz;
653 module GP_PGEN(input wire nRST, input wire CLK, output reg OUT);
655 parameter PATTERN_DATA = 16'h0;
656 parameter PATTERN_LEN = 5'd16;
659 always @(posedge CLK) begin
661 OUT <= PATTERN_DATA[0];
665 OUT <= PATTERN_DATA[count];
667 if( (count + 1) == PATTERN_LEN)
674 module GP_SHREG(input nRST, input CLK, input IN, output OUTA, output OUTB);
676 parameter OUTA_TAP = 1;
677 parameter OUTA_INVERT = 0;
678 parameter OUTB_TAP = 1;
682 always @(posedge CLK, negedge nRST) begin
688 shreg <= {shreg[14:0], IN};
692 assign OUTA = (OUTA_INVERT) ? ~shreg[OUTA_TAP - 1] : shreg[OUTA_TAP - 1];
693 assign OUTB = shreg[OUTB_TAP - 1];
697 module GP_VDD(output OUT);
701 module GP_VSS(output OUT);