mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-24 01:25:33 +00:00
Added $sr, $dffsr and $dlatch cell types
This commit is contained in:
parent
9bc703b964
commit
5998c101a4
3 changed files with 80 additions and 49 deletions
|
@ -642,26 +642,6 @@ endmodule
|
|||
|
||||
// --------------------------------------------------------
|
||||
|
||||
module \$sr (S, R, Q);
|
||||
|
||||
parameter WIDTH = 0;
|
||||
|
||||
input [WIDTH-1:0] S, R;
|
||||
output reg [WIDTH-1:0] Q;
|
||||
|
||||
integer i;
|
||||
always @(S, R)
|
||||
for (i = 0; i < WIDTH; i = i+1) begin
|
||||
if (R[i])
|
||||
Q[i] <= 0;
|
||||
else if (S[i])
|
||||
Q[i] <= 1;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
// --------------------------------------------------------
|
||||
|
||||
module \$lut (I, O);
|
||||
|
||||
parameter WIDTH = 0;
|
||||
|
@ -694,6 +674,33 @@ endmodule
|
|||
|
||||
// --------------------------------------------------------
|
||||
|
||||
module \$sr (SET, CLR, Q);
|
||||
|
||||
parameter WIDTH = 0;
|
||||
parameter SET_POLARITY = 1'b1;
|
||||
parameter CLR_POLARITY = 1'b1;
|
||||
|
||||
input [WIDTH-1:0] SET, CLR;
|
||||
output reg [WIDTH-1:0] Q;
|
||||
|
||||
wire [WIDTH-1:0] pos_set = SET_POLARITY ? SET : ~SET;
|
||||
wire [WIDTH-1:0] pos_clr = CLR_POLARITY ? CLR : ~CLR;
|
||||
|
||||
genvar i;
|
||||
generate
|
||||
for (i = 0; i < WIDTH; i = i+1) begin:bit
|
||||
always @(posedge pos_set[i], posedge pos_clr[i])
|
||||
if (pos_clr[i])
|
||||
Q[i] <= 0;
|
||||
else if (pos_set[i])
|
||||
Q[i] <= 1;
|
||||
end
|
||||
endgenerate
|
||||
|
||||
endmodule
|
||||
|
||||
// --------------------------------------------------------
|
||||
|
||||
module \$dff (CLK, D, Q);
|
||||
|
||||
parameter WIDTH = 0;
|
||||
|
@ -712,6 +719,38 @@ endmodule
|
|||
|
||||
// --------------------------------------------------------
|
||||
|
||||
module \$dffsr (CLK, SET, CLR, D, Q);
|
||||
|
||||
parameter WIDTH = 0;
|
||||
parameter CLK_POLARITY = 1'b1;
|
||||
parameter SET_POLARITY = 1'b1;
|
||||
parameter CLR_POLARITY = 1'b1;
|
||||
|
||||
input CLK;
|
||||
input [WIDTH-1:0] SET, CLR, D;
|
||||
output reg [WIDTH-1:0] Q;
|
||||
|
||||
wire pos_clk = CLK == CLK_POLARITY;
|
||||
wire [WIDTH-1:0] pos_set = SET_POLARITY ? SET : ~SET;
|
||||
wire [WIDTH-1:0] pos_clr = CLR_POLARITY ? CLR : ~CLR;
|
||||
|
||||
genvar i;
|
||||
generate
|
||||
for (i = 0; i < WIDTH; i = i+1) begin:bit
|
||||
always @(posedge pos_set[i], posedge pos_clr[i], posedge pos_clk)
|
||||
if (pos_clr[i])
|
||||
Q[i] <= 0;
|
||||
else if (pos_set[i])
|
||||
Q[i] <= 1;
|
||||
else
|
||||
Q[i] <= D[i];
|
||||
end
|
||||
endgenerate
|
||||
|
||||
endmodule
|
||||
|
||||
// --------------------------------------------------------
|
||||
|
||||
module \$adff (CLK, ARST, D, Q);
|
||||
|
||||
parameter WIDTH = 0;
|
||||
|
@ -736,6 +775,23 @@ endmodule
|
|||
|
||||
// --------------------------------------------------------
|
||||
|
||||
module \$dlatch (EN, D, Q);
|
||||
|
||||
parameter WIDTH = 0;
|
||||
parameter EN_POLARITY = 1'b1;
|
||||
|
||||
input EN;
|
||||
input [WIDTH-1:0] D;
|
||||
output reg [WIDTH-1:0] Q;
|
||||
|
||||
always @*
|
||||
if (EN == EN_POLARITY)
|
||||
Q <= D;
|
||||
|
||||
endmodule
|
||||
|
||||
// --------------------------------------------------------
|
||||
|
||||
module \$fsm (CLK, ARST, CTRL_IN, CTRL_OUT);
|
||||
|
||||
parameter NAME = "";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue