Registers¶
SR-type latches are represented by $sr cells. These cells have input ports
SET and CLR and an output port Q. They have the following
parameters:
WIDTHThe width of inputs
SETandCLRand outputQ.SET_POLARITYThe set input bits are active-high if this parameter has the value
1'b1and active-low if this parameter is1'b0.CLR_POLARITYThe reset input bits are active-high if this parameter has the value
1'b1and active-low if this parameter is1'b0.
Both set and reset inputs have separate bits for every output bit. When both the
set and reset inputs of an $sr cell are active for a given bit index, the
reset input takes precedence.
D-type flip-flops are represented by $dff cells. These cells have a clock port
CLK, an input port D and an output port Q. The following parameters
are available for $dff cells:
WIDTHThe width of input
Dand outputQ.CLK_POLARITYClock is active on the positive edge if this parameter has the value
1'b1and on the negative edge if this parameter is1'b0.
D-type flip-flops with asynchronous reset are represented by $adff cells. As
the $dff cells they have CLK, D and Q ports. In addition they also
have a single-bit ARST input port for the reset pin and the following
additional two parameters:
ARST_POLARITYThe asynchronous reset is active-high if this parameter has the value
1'b1and active-low if this parameter is1'b0.ARST_VALUEThe state of
Qwill be set to this value when the reset is active.
Usually these cells are generated by the proc pass using the information in
the designs RTLIL::Process objects.
D-type flip-flops with synchronous reset are represented by $sdff cells. As
the $dff cells they have CLK, D and Q ports. In addition they also
have a single-bit SRST input port for the reset pin and the following
additional two parameters:
SRST_POLARITYThe synchronous reset is active-high if this parameter has the value
1'b1and active-low if this parameter is1'b0.SRST_VALUEThe state of
Qwill be set to this value when the reset is active.
Note that the $adff and $sdff cells can only be used when the reset value is
constant.
D-type flip-flops with asynchronous load are represented by $aldff cells. As
the $dff cells they have CLK, D and Q ports. In addition they also
have a single-bit ALOAD input port for the async load enable pin, a AD
input port with the same width as data for the async load data, and the
following additional parameter:
ALOAD_POLARITYThe asynchronous load is active-high if this parameter has the value
1'b1and active-low if this parameter is1'b0.
D-type flip-flops with asynchronous set and reset are represented by $dffsr
cells. As the $dff cells they have CLK, D and Q ports. In addition
they also have multi-bit SET and CLR input ports and the corresponding
polarity parameters, like $sr cells.
D-type flip-flops with enable are represented by $dffe, $adffe, $aldffe,
$dffsre, $sdffe, and $sdffce cells, which are enhanced variants of $dff,
$adff, $aldff, $dffsr, $sdff (with reset over enable) and $sdff (with
enable over reset) cells, respectively. They have the same ports and parameters
as their base cell. In addition they also have a single-bit EN input port
for the enable pin and the following parameter:
EN_POLARITYThe enable input is active-high if this parameter has the value
1'b1and active-low if this parameter is1'b0.
D-type latches are represented by $dlatch cells. These cells have an enable
port EN, an input port D, and an output port Q. The following
parameters are available for $dlatch cells:
WIDTHThe width of input
Dand outputQ.EN_POLARITYThe enable input is active-high if this parameter has the value
1'b1and active-low if this parameter is1'b0.
The latch is transparent when the EN input is active.
D-type latches with reset are represented by $adlatch cells. In addition to
$dlatch ports and parameters, they also have a single-bit ARST input port
for the reset pin and the following additional parameters:
ARST_POLARITYThe asynchronous reset is active-high if this parameter has the value
1'b1and active-low if this parameter is1'b0.ARST_VALUEThe state of
Qwill be set to this value when the reset is active.
D-type latches with set and reset are represented by $dlatchsr cells. In
addition to $dlatch ports and parameters, they also have multi-bit SET and
CLR input ports and the corresponding polarity parameters, like $sr cells.
- yosys> help $adff¶
- Simulation model (verilog)¶
2431module \$adff (CLK, ARST, D, Q); 2432 2433 parameter WIDTH = 0; 2434 parameter CLK_POLARITY = 1'b1; 2435 parameter ARST_POLARITY = 1'b1; 2436 parameter ARST_VALUE = 0; 2437 2438 input CLK, ARST; 2439 input [WIDTH-1:0] D; 2440 output reg [WIDTH-1:0] Q; 2441 wire pos_clk = CLK == CLK_POLARITY; 2442 wire pos_arst = ARST == ARST_POLARITY; 2443 2444 always @(posedge pos_clk, posedge pos_arst) begin 2445 if (pos_arst) 2446 Q <= ARST_VALUE; 2447 else 2448 Q <= D; 2449 end 2450 2451endmodule
- yosys> help $adffe¶
- Simulation model (verilog)¶
2506module \$adffe (CLK, ARST, EN, D, Q); 2507 2508 parameter WIDTH = 0; 2509 parameter CLK_POLARITY = 1'b1; 2510 parameter EN_POLARITY = 1'b1; 2511 parameter ARST_POLARITY = 1'b1; 2512 parameter ARST_VALUE = 0; 2513 2514 input CLK, ARST, EN; 2515 input [WIDTH-1:0] D; 2516 output reg [WIDTH-1:0] Q; 2517 wire pos_clk = CLK == CLK_POLARITY; 2518 wire pos_arst = ARST == ARST_POLARITY; 2519 2520 always @(posedge pos_clk, posedge pos_arst) begin 2521 if (pos_arst) 2522 Q <= ARST_VALUE; 2523 else if (EN == EN_POLARITY) 2524 Q <= D; 2525 end 2526 2527endmodule
- yosys> help $adlatch¶
- Simulation model (verilog)¶
2631module \$adlatch (EN, ARST, D, Q); 2632 2633 parameter WIDTH = 0; 2634 parameter EN_POLARITY = 1'b1; 2635 parameter ARST_POLARITY = 1'b1; 2636 parameter ARST_VALUE = 0; 2637 2638 input EN, ARST; 2639 input [WIDTH-1:0] D; 2640 output reg [WIDTH-1:0] Q; 2641 2642 always @* begin 2643 if (ARST == ARST_POLARITY) 2644 Q = ARST_VALUE; 2645 else if (EN == EN_POLARITY) 2646 Q = D; 2647 end 2648 2649endmodule
- yosys> help $aldff¶
- Simulation model (verilog)¶
2456module \$aldff (CLK, ALOAD, AD, D, Q); 2457 2458 parameter WIDTH = 0; 2459 parameter CLK_POLARITY = 1'b1; 2460 parameter ALOAD_POLARITY = 1'b1; 2461 2462 input CLK, ALOAD; 2463 input [WIDTH-1:0] AD; 2464 input [WIDTH-1:0] D; 2465 output reg [WIDTH-1:0] Q; 2466 wire pos_clk = CLK == CLK_POLARITY; 2467 wire pos_aload = ALOAD == ALOAD_POLARITY; 2468 2469 always @(posedge pos_clk, posedge pos_aload) begin 2470 if (pos_aload) 2471 Q <= AD; 2472 else 2473 Q <= D; 2474 end 2475 2476endmodule
- yosys> help $aldffe¶
- Simulation model (verilog)¶
2532module \$aldffe (CLK, ALOAD, AD, EN, D, Q); 2533 2534 parameter WIDTH = 0; 2535 parameter CLK_POLARITY = 1'b1; 2536 parameter EN_POLARITY = 1'b1; 2537 parameter ALOAD_POLARITY = 1'b1; 2538 2539 input CLK, ALOAD, EN; 2540 input [WIDTH-1:0] D; 2541 input [WIDTH-1:0] AD; 2542 output reg [WIDTH-1:0] Q; 2543 wire pos_clk = CLK == CLK_POLARITY; 2544 wire pos_aload = ALOAD == ALOAD_POLARITY; 2545 2546 always @(posedge pos_clk, posedge pos_aload) begin 2547 if (pos_aload) 2548 Q <= AD; 2549 else if (EN == EN_POLARITY) 2550 Q <= D; 2551 end 2552 2553endmodule
- yosys> help $dff¶
- Simulation model (verilog)¶
2323module \$dff (CLK, D, Q); 2324 2325 parameter WIDTH = 0; 2326 parameter CLK_POLARITY = 1'b1; 2327 2328 input CLK; 2329 input [WIDTH-1:0] D; 2330 output reg [WIDTH-1:0] Q; 2331 wire pos_clk = CLK == CLK_POLARITY; 2332 2333 always @(posedge pos_clk) begin 2334 Q <= D; 2335 end 2336 2337endmodule
- yosys> help $dffe¶
- Simulation model (verilog)¶
2342module \$dffe (CLK, EN, D, Q); 2343 2344 parameter WIDTH = 0; 2345 parameter CLK_POLARITY = 1'b1; 2346 parameter EN_POLARITY = 1'b1; 2347 2348 input CLK, EN; 2349 input [WIDTH-1:0] D; 2350 output reg [WIDTH-1:0] Q; 2351 wire pos_clk = CLK == CLK_POLARITY; 2352 2353 always @(posedge pos_clk) begin 2354 if (EN == EN_POLARITY) Q <= D; 2355 end 2356 2357endmodule
- yosys> help $dffsr¶
- Simulation model (verilog)¶
2363module \$dffsr (CLK, SET, CLR, D, Q); 2364 2365 parameter WIDTH = 0; 2366 parameter CLK_POLARITY = 1'b1; 2367 parameter SET_POLARITY = 1'b1; 2368 parameter CLR_POLARITY = 1'b1; 2369 2370 input CLK; 2371 input [WIDTH-1:0] SET, CLR, D; 2372 output reg [WIDTH-1:0] Q; 2373 2374 wire pos_clk = CLK == CLK_POLARITY; 2375 wire [WIDTH-1:0] pos_set = SET_POLARITY ? SET : ~SET; 2376 wire [WIDTH-1:0] pos_clr = CLR_POLARITY ? CLR : ~CLR; 2377 2378 genvar i; 2379 generate 2380 for (i = 0; i < WIDTH; i = i+1) begin:bitslices 2381 always @(posedge pos_set[i], posedge pos_clr[i], posedge pos_clk) 2382 if (pos_clr[i]) 2383 Q[i] <= 0; 2384 else if (pos_set[i]) 2385 Q[i] <= 1; 2386 else 2387 Q[i] <= D[i]; 2388 end 2389 endgenerate 2390 2391endmodule
- yosys> help $dffsre¶
- Simulation model (verilog)¶
2396module \$dffsre (CLK, SET, CLR, EN, D, Q); 2397 2398 parameter WIDTH = 0; 2399 parameter CLK_POLARITY = 1'b1; 2400 parameter SET_POLARITY = 1'b1; 2401 parameter CLR_POLARITY = 1'b1; 2402 parameter EN_POLARITY = 1'b1; 2403 2404 input CLK, EN; 2405 input [WIDTH-1:0] SET, CLR, D; 2406 output reg [WIDTH-1:0] Q; 2407 2408 wire pos_clk = CLK == CLK_POLARITY; 2409 wire [WIDTH-1:0] pos_set = SET_POLARITY ? SET : ~SET; 2410 wire [WIDTH-1:0] pos_clr = CLR_POLARITY ? CLR : ~CLR; 2411 2412 genvar i; 2413 generate 2414 for (i = 0; i < WIDTH; i = i+1) begin:bitslices 2415 always @(posedge pos_set[i], posedge pos_clr[i], posedge pos_clk) 2416 if (pos_clr[i]) 2417 Q[i] <= 0; 2418 else if (pos_set[i]) 2419 Q[i] <= 1; 2420 else if (EN == EN_POLARITY) 2421 Q[i] <= D[i]; 2422 end 2423 endgenerate 2424 2425endmodule
- yosys> help $dlatch¶
- Simulation model (verilog)¶
2612module \$dlatch (EN, D, Q); 2613 2614 parameter WIDTH = 0; 2615 parameter EN_POLARITY = 1'b1; 2616 2617 input EN; 2618 input [WIDTH-1:0] D; 2619 output reg [WIDTH-1:0] Q; 2620 2621 always @* begin 2622 if (EN == EN_POLARITY) 2623 Q = D; 2624 end 2625 2626endmodule
- yosys> help $dlatchsr¶
- Simulation model (verilog)¶
2655module \$dlatchsr (EN, SET, CLR, D, Q); 2656 2657 parameter WIDTH = 0; 2658 parameter EN_POLARITY = 1'b1; 2659 parameter SET_POLARITY = 1'b1; 2660 parameter CLR_POLARITY = 1'b1; 2661 2662 input EN; 2663 input [WIDTH-1:0] SET, CLR, D; 2664 output reg [WIDTH-1:0] Q; 2665 2666 wire pos_en = EN == EN_POLARITY; 2667 wire [WIDTH-1:0] pos_set = SET_POLARITY ? SET : ~SET; 2668 wire [WIDTH-1:0] pos_clr = CLR_POLARITY ? CLR : ~CLR; 2669 2670 genvar i; 2671 generate 2672 for (i = 0; i < WIDTH; i = i+1) begin:bitslices 2673 always @* 2674 if (pos_clr[i]) 2675 Q[i] = 0; 2676 else if (pos_set[i]) 2677 Q[i] = 1; 2678 else if (pos_en) 2679 Q[i] = D[i]; 2680 end 2681 endgenerate 2682 2683endmodule
- yosys> help $sdff¶
- Simulation model (verilog)¶
2481module \$sdff (CLK, SRST, D, Q); 2482 2483 parameter WIDTH = 0; 2484 parameter CLK_POLARITY = 1'b1; 2485 parameter SRST_POLARITY = 1'b1; 2486 parameter SRST_VALUE = 0; 2487 2488 input CLK, SRST; 2489 input [WIDTH-1:0] D; 2490 output reg [WIDTH-1:0] Q; 2491 wire pos_clk = CLK == CLK_POLARITY; 2492 wire pos_srst = SRST == SRST_POLARITY; 2493 2494 always @(posedge pos_clk) begin 2495 if (pos_srst) 2496 Q <= SRST_VALUE; 2497 else 2498 Q <= D; 2499 end 2500 2501endmodule
- yosys> help $sdffce¶
- Simulation model (verilog)¶
2584module \$sdffce (CLK, SRST, EN, D, Q); 2585 2586 parameter WIDTH = 0; 2587 parameter CLK_POLARITY = 1'b1; 2588 parameter EN_POLARITY = 1'b1; 2589 parameter SRST_POLARITY = 1'b1; 2590 parameter SRST_VALUE = 0; 2591 2592 input CLK, SRST, EN; 2593 input [WIDTH-1:0] D; 2594 output reg [WIDTH-1:0] Q; 2595 wire pos_clk = CLK == CLK_POLARITY; 2596 wire pos_srst = SRST == SRST_POLARITY; 2597 2598 always @(posedge pos_clk) begin 2599 if (EN == EN_POLARITY) begin 2600 if (pos_srst) 2601 Q <= SRST_VALUE; 2602 else 2603 Q <= D; 2604 end 2605 end 2606 2607endmodule
- yosys> help $sdffe¶
- Simulation model (verilog)¶
2558module \$sdffe (CLK, SRST, EN, D, Q); 2559 2560 parameter WIDTH = 0; 2561 parameter CLK_POLARITY = 1'b1; 2562 parameter EN_POLARITY = 1'b1; 2563 parameter SRST_POLARITY = 1'b1; 2564 parameter SRST_VALUE = 0; 2565 2566 input CLK, SRST, EN; 2567 input [WIDTH-1:0] D; 2568 output reg [WIDTH-1:0] Q; 2569 wire pos_clk = CLK == CLK_POLARITY; 2570 wire pos_srst = SRST == SRST_POLARITY; 2571 2572 always @(posedge pos_clk) begin 2573 if (pos_srst) 2574 Q <= SRST_VALUE; 2575 else if (EN == EN_POLARITY) 2576 Q <= D; 2577 end 2578 2579endmodule
- yosys> help $sr¶
- Simulation model (verilog)¶
2273module \$sr (SET, CLR, Q); 2274 2275 parameter WIDTH = 0; 2276 parameter SET_POLARITY = 1'b1; 2277 parameter CLR_POLARITY = 1'b1; 2278 2279 input [WIDTH-1:0] SET, CLR; 2280 output reg [WIDTH-1:0] Q; 2281 2282 wire [WIDTH-1:0] pos_set = SET_POLARITY ? SET : ~SET; 2283 wire [WIDTH-1:0] pos_clr = CLR_POLARITY ? CLR : ~CLR; 2284 2285 genvar i; 2286 generate 2287 for (i = 0; i < WIDTH; i = i+1) begin:bitslices 2288 always @* 2289 if (pos_clr[i]) 2290 Q[i] <= 0; 2291 else if (pos_set[i]) 2292 Q[i] <= 1; 2293 end 2294 endgenerate 2295 2296endmodule