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");
89 always @(posedge CLK or RST) begin
90 count <= count - 1'd1;
101 $display("Invalid RESET_MODE on GP_COUNT8");
111 module GP_COUNT14_ADV(input CLK, input RST, output reg OUT,
112 input UP, input KEEP, output reg[7:0] POUT);
114 parameter RESET_MODE = "RISING";
115 parameter RESET_VALUE = "ZERO";
117 parameter COUNT_TO = 14'h1;
118 parameter CLKIN_DIVIDE = 1;
121 if(CLKIN_DIVIDE != 1) begin
122 $display("ERROR: CLKIN_DIVIDE values other than 1 not implemented");
127 reg[13:0] count = COUNT_TO;
129 //Combinatorially output underflow flag whenever we wrap low
132 OUT <= (count == 14'h3fff);
134 OUT <= (count == 14'h0);
138 //POR or SYSRST reset value is COUNT_TO. Datasheet is unclear but conversations w/ Silego confirm.
139 //Runtime reset value is clearly 0 except in count/FSM cells where it's configurable but we leave at 0 for now.
144 always @(posedge CLK or posedge RST) begin
150 count <= count + 1'd1;
152 count <= count - 1'd1;
155 if(count == 0 && !UP)
157 if(count == 14'h3fff && UP)
162 if(RESET_VALUE == "ZERO")
172 always @(posedge CLK or negedge RST) begin
178 count <= count + 1'd1;
180 count <= count - 1'd1;
183 if(count == 0 && !UP)
185 if(count == 14'h3fff && UP)
190 if(RESET_VALUE == "ZERO")
201 $display("Both-edge reset mode for GP_COUNT14_ADV not implemented");
207 always @(posedge CLK or RST) begin
213 count <= count + 1'd1;
215 count <= count - 1'd1;
218 if(count == 0 && !UP)
220 if(count == 14'h3fff && UP)
225 if(RESET_VALUE == "ZERO")
236 $display("Invalid RESET_MODE on GP_COUNT14_ADV");
246 module GP_COUNT8_ADV(input CLK, input RST, output reg OUT,
247 input UP, input KEEP, output reg[7:0] POUT);
249 parameter RESET_MODE = "RISING";
250 parameter RESET_VALUE = "ZERO";
252 parameter COUNT_TO = 8'h1;
253 parameter CLKIN_DIVIDE = 1;
255 reg[7:0] count = COUNT_TO;
258 if(CLKIN_DIVIDE != 1) begin
259 $display("ERROR: CLKIN_DIVIDE values other than 1 not implemented");
264 //Combinatorially output underflow flag whenever we wrap low
267 OUT <= (count == 8'hff);
269 OUT <= (count == 8'h0);
273 //POR or SYSRST reset value is COUNT_TO. Datasheet is unclear but conversations w/ Silego confirm.
274 //Runtime reset value is clearly 0 except in count/FSM cells where it's configurable but we leave at 0 for now.
279 always @(posedge CLK or posedge RST) begin
285 count <= count + 1'd1;
287 count <= count - 1'd1;
290 if(count == 0 && !UP)
292 if(count == 8'hff && UP)
297 if(RESET_VALUE == "ZERO")
307 always @(posedge CLK or negedge RST) begin
313 count <= count + 1'd1;
315 count <= count - 1'd1;
318 if(count == 0 && !UP)
320 if(count == 8'hff && UP)
325 if(RESET_VALUE == "ZERO")
336 $display("Both-edge reset mode for GP_COUNT8_ADV not implemented");
342 always @(posedge CLK or RST) begin
348 count <= count + 1'd1;
350 count <= count - 1'd1;
353 if(count == 0 && !UP)
355 if(count == 8'hff && UP)
360 if(RESET_VALUE == "ZERO")
371 $display("Invalid RESET_MODE on GP_COUNT8_ADV");
385 output reg[7:0] POUT);
387 parameter RESET_MODE = "RISING";
389 parameter COUNT_TO = 8'h1;
390 parameter CLKIN_DIVIDE = 1;
393 if(CLKIN_DIVIDE != 1) begin
394 $display("ERROR: CLKIN_DIVIDE values other than 1 not implemented");
399 reg[7:0] count = COUNT_TO;
401 //Combinatorially output underflow flag whenever we wrap low
403 OUT <= (count == 8'h0);
407 //POR or SYSRST reset value is COUNT_TO. Datasheet is unclear but conversations w/ Silego confirm.
408 //Runtime reset value is clearly 0 except in count/FSM cells where it's configurable but we leave at 0 for now.
413 always @(posedge CLK or posedge RST) begin
414 count <= count - 1'd1;
424 always @(posedge CLK or negedge RST) begin
425 count <= count - 1'd1;
436 $display("Both-edge reset mode for GP_COUNT8 not implemented");
442 always @(posedge CLK or RST) begin
443 count <= count - 1'd1;
454 $display("Invalid RESET_MODE on GP_COUNT8");
464 module GP_DCMPREF(output reg[7:0]OUT);
465 parameter[7:0] REF_VAL = 8'h00;
466 initial OUT = REF_VAL;
469 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);
497 module GP_DELAY(input IN, output reg OUT);
499 parameter DELAY_STEPS = 1;
500 parameter GLITCH_FILTER = 0;
506 if(GLITCH_FILTER) begin
508 $display("ERROR: GP_DELAY glitch filter mode not implemented");
513 //TODO: These delays are PTV dependent! For now, hard code 3v3 timing
514 //Change simulation-mode delay depending on global Vdd range (how to specify this?)
522 $display("ERROR: GP_DELAY must have DELAY_STEPS in range [1,4]");
532 module GP_DFF(input D, CLK, output reg Q);
533 parameter [0:0] INIT = 1'bx;
535 always @(posedge CLK) begin
540 module GP_DFFI(input D, CLK, output reg nQ);
541 parameter [0:0] INIT = 1'bx;
543 always @(posedge CLK) begin
548 module GP_DFFR(input D, CLK, nRST, output reg Q);
549 parameter [0:0] INIT = 1'bx;
551 always @(posedge CLK, negedge nRST) begin
559 module GP_DFFRI(input D, CLK, nRST, output reg nQ);
560 parameter [0:0] INIT = 1'bx;
562 always @(posedge CLK, negedge nRST) begin
570 module GP_DFFS(input D, CLK, nSET, output reg Q);
571 parameter [0:0] INIT = 1'bx;
573 always @(posedge CLK, negedge nSET) begin
581 module GP_DFFSI(input D, CLK, nSET, output reg nQ);
582 parameter [0:0] INIT = 1'bx;
584 always @(posedge CLK, negedge nSET) begin
592 module GP_DFFSR(input D, CLK, nSR, output reg Q);
593 parameter [0:0] INIT = 1'bx;
594 parameter [0:0] SRMODE = 1'bx;
596 always @(posedge CLK, negedge nSR) begin
604 module GP_DFFSRI(input D, CLK, nSR, output reg nQ);
605 parameter [0:0] INIT = 1'bx;
606 parameter [0:0] SRMODE = 1'bx;
608 always @(posedge CLK, negedge nSR) begin
616 module GP_DLATCH(input D, input nCLK, output reg Q);
617 parameter [0:0] INIT = 1'bx;
625 module GP_DLATCHI(input D, input nCLK, output reg nQ);
626 parameter [0:0] INIT = 1'bx;
634 module GP_DLATCHR(input D, input nCLK, input nRST, output reg Q);
635 parameter [0:0] INIT = 1'bx;
645 module GP_DLATCHRI(input D, input nCLK, input nRST, output reg nQ);
646 parameter [0:0] INIT = 1'bx;
656 module GP_DLATCHS(input D, input nCLK, input nSET, output reg Q);
657 parameter [0:0] INIT = 1'bx;
667 module GP_DLATCHSI(input D, input nCLK, input nSET, output reg nQ);
668 parameter [0:0] INIT = 1'bx;
678 module GP_DLATCHSR(input D, input nCLK, input nSR, output reg Q);
679 parameter [0:0] INIT = 1'bx;
680 parameter[0:0] SRMODE = 1'bx;
690 module GP_DLATCHSRI(input D, input nCLK, input nSR, output reg nQ);
691 parameter [0:0] INIT = 1'bx;
692 parameter[0:0] SRMODE = 1'bx;
702 module GP_IBUF(input IN, output OUT);
706 module GP_IOBUF(input IN, input OE, output OUT, inout IO);
708 assign IO = OE ? IN : 1'bz;
711 module GP_INV(input IN, output OUT);
715 module GP_OBUF(input IN, output OUT);
719 module GP_OBUFT(input IN, input OE, output OUT);
720 assign OUT = OE ? IN : 1'bz;
723 module GP_PGEN(input wire nRST, input wire CLK, output reg OUT);
725 parameter PATTERN_DATA = 16'h0;
726 parameter PATTERN_LEN = 5'd16;
729 always @(posedge CLK) begin
731 OUT <= PATTERN_DATA[0];
735 OUT <= PATTERN_DATA[count];
737 if( (count + 1) == PATTERN_LEN)
744 module GP_SHREG(input nRST, input CLK, input IN, output OUTA, output OUTB);
746 parameter OUTA_TAP = 1;
747 parameter OUTA_INVERT = 0;
748 parameter OUTB_TAP = 1;
752 always @(posedge CLK, negedge nRST) begin
758 shreg <= {shreg[14:0], IN};
762 assign OUTA = (OUTA_INVERT) ? ~shreg[OUTA_TAP - 1] : shreg[OUTA_TAP - 1];
763 assign OUTB = shreg[OUTB_TAP - 1];
767 module GP_VDD(output OUT);
771 module GP_VSS(output OUT);