mirror of
https://github.com/annoyatron255/yosys4gal.git
synced 2025-01-04 08:18:23 +00:00
Add OLMC on internal combinational nodes
This commit is contained in:
parent
8c695d0fb3
commit
e9a9c68f88
|
@ -1,28 +1,9 @@
|
||||||
module NDFF_P (
|
module NDFF_P (C, D, Q);
|
||||||
input C, D,
|
input C, D;
|
||||||
output Q
|
output Q;
|
||||||
);
|
|
||||||
|
|
||||||
wire Y;
|
wire Y;
|
||||||
|
|
||||||
$_NOT_ not_inst (.A(D), .Y(Y));
|
|
||||||
DFF_P dff_inst (.D(Y), .C(C), .Q(Q));
|
|
||||||
|
|
||||||
|
$_NOT_ not_inst (.A(D), .Y(Y));
|
||||||
|
DFF_P dff_inst (.D(Y), .C(C), .Q(Q));
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
/*module GAL_MACROCELL #(
|
|
||||||
parameter ACTIVE_HIGH = 0,
|
|
||||||
parameter REGISTERED = 0,
|
|
||||||
)(
|
|
||||||
input clk,
|
|
||||||
|
|
||||||
input data,
|
|
||||||
|
|
||||||
input in,
|
|
||||||
output out,
|
|
||||||
);
|
|
||||||
|
|
||||||
$_NOT_ not_inst (.A(D), .Y(Y));
|
|
||||||
DFF_P dff_inst (.D(Y), .C(C), .Q(Q));
|
|
||||||
|
|
||||||
endmodule*/
|
|
||||||
|
|
|
@ -1,20 +1,15 @@
|
||||||
module REG_OUT_P (
|
module REG_OUT_P (C, A, Y);
|
||||||
input C, A,
|
input C, A;
|
||||||
output Y
|
output Y;
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
DFF_P dff_p_inst (.C(C), .D(A), .Q(Y));
|
|
||||||
GAL_OUTPUT gal_output_inst (.A(Y));
|
|
||||||
|
|
||||||
|
DFF_P dff_p_inst (.C(C), .D(A), .Q(Y));
|
||||||
|
GAL_OUTPUT gal_output_inst (.A(Y));
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module REG_OUT_N (
|
module REG_OUT_N (C, A, Y);
|
||||||
input C, A,
|
input C, A;
|
||||||
output Y
|
output Y;
|
||||||
);
|
|
||||||
|
|
||||||
NDFF_P dff_p_inst (.C(C), .D(A), .Q(Y));
|
|
||||||
GAL_OUTPUT gal_output_inst (.A(X));
|
|
||||||
|
|
||||||
|
NDFF_P dff_p_inst (.C(C), .D(A), .Q(Y));
|
||||||
|
GAL_OUTPUT gal_output_inst (.A(X));
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
@ -40,7 +40,7 @@ if {$num_regs > 0} { set num_inputs_regs [expr $num_inputs_regs - 1] }
|
||||||
#abc -sop -I 8 -P 8
|
#abc -sop -I 8 -P 8
|
||||||
#abc -script "+strash;,dretime;,collapse;,write_pla,test.pla" -sop
|
#abc -script "+strash;,dretime;,collapse;,write_pla,test.pla" -sop
|
||||||
# Force one-level SOP
|
# Force one-level SOP
|
||||||
abc -script "abc.script" -sop
|
#abc -script "abc.script" -sop
|
||||||
|
|
||||||
# Resynth all too big SOPs together in multi-level SOP
|
# Resynth all too big SOPs together in multi-level SOP
|
||||||
#select "t:\$sop" r:DEPTH>8 %i
|
#select "t:\$sop" r:DEPTH>8 %i
|
||||||
|
@ -48,19 +48,19 @@ abc -script "abc.script" -sop
|
||||||
#yosys proc
|
#yosys proc
|
||||||
#techmap
|
#techmap
|
||||||
#select *
|
#select *
|
||||||
#abc -sop -I $num_inputs_regs -P 8
|
abc -sop -I $num_inputs_regs -P 7
|
||||||
|
|
||||||
opt
|
opt
|
||||||
clean -purge
|
clean -purge
|
||||||
|
|
||||||
show -width
|
#show -width
|
||||||
|
|
||||||
## Tech mapping
|
## Tech mapping
|
||||||
# Logic
|
# PLAs
|
||||||
techmap -map techmaps/pla.v -D PLA_MAX_PRODUCTS=10000
|
techmap -map techmaps/pla.v -D PLA_MAX_PRODUCTS=7
|
||||||
|
|
||||||
# Sequential OLMC
|
# Sequential OLMC
|
||||||
extract -map extractions/ndff.v
|
extract -constports -map extractions/ndff.v
|
||||||
extract -constports -map extractions/olmc.v
|
extract -constports -map extractions/olmc.v
|
||||||
techmap -map techmaps/olmc_seq.v
|
techmap -map techmaps/olmc_seq.v
|
||||||
|
|
||||||
|
@ -68,6 +68,9 @@ techmap -map techmaps/olmc_seq.v
|
||||||
iopadmap -bits -outpad GAL_COMB_OUTPUT_P A:Y */t:GAL_SOP "%x:+\[Y\]" */t:GAL_SOP %d o:* %i
|
iopadmap -bits -outpad GAL_COMB_OUTPUT_P A:Y */t:GAL_SOP "%x:+\[Y\]" */t:GAL_SOP %d o:* %i
|
||||||
techmap -map techmaps/olmc_comb.v o:* %x o:* %d
|
techmap -map techmaps/olmc_comb.v o:* %x o:* %d
|
||||||
|
|
||||||
|
# Add OLMC for internal GAL_SOPs
|
||||||
|
techmap -max_iter 1 -map techmaps/pla_olmc_int.v */t:GAL_OLMC %ci2 */t:GAL_SOP %i */t:GAL_SOP %D
|
||||||
|
|
||||||
clean -purge
|
clean -purge
|
||||||
|
|
||||||
## Write output files and graph
|
## Write output files and graph
|
||||||
|
|
102
techmaps/pla.v
102
techmaps/pla.v
|
@ -4,62 +4,60 @@ $fatal(1, "Macro PLA_MAX_PRODUCTS must be defined");
|
||||||
|
|
||||||
(* techmap_celltype = "$sop $__sop" *)
|
(* techmap_celltype = "$sop $__sop" *)
|
||||||
module _80_sop (A, Y);
|
module _80_sop (A, Y);
|
||||||
|
parameter WIDTH = 0;
|
||||||
|
parameter DEPTH = 0;
|
||||||
|
parameter TABLE = 0;
|
||||||
|
|
||||||
parameter WIDTH = 0;
|
input [WIDTH-1:0] A;
|
||||||
parameter DEPTH = 0;
|
output reg Y;
|
||||||
parameter TABLE = 0;
|
|
||||||
|
|
||||||
input [WIDTH-1:0] A;
|
// Add a blank variable to TABLE
|
||||||
output reg Y;
|
function [2*(WIDTH+1)*DEPTH-1:0] add_var_table;
|
||||||
|
integer i, j;
|
||||||
// Add a blank variable to TABLE
|
for (i = 0; i < DEPTH; i=i+1) begin
|
||||||
function [2*(WIDTH+1)*DEPTH-1:0] add_var_table;
|
for (j = 0; j < WIDTH + 1; j=j+1) begin
|
||||||
integer i, j;
|
if (j < WIDTH) begin
|
||||||
for (i = 0; i < DEPTH; i=i+1) begin
|
add_var_table[2*(WIDTH+1)*i + 2*j + 0] = TABLE[2*WIDTH*i + 2*j + 0];
|
||||||
for (j = 0; j < WIDTH + 1; j=j+1) begin
|
add_var_table[2*(WIDTH+1)*i + 2*j + 1] = TABLE[2*WIDTH*i + 2*j + 1];
|
||||||
if (j < WIDTH) begin
|
end else begin
|
||||||
add_var_table[2*(WIDTH+1)*i + 2*j + 0] = TABLE[2*WIDTH*i + 2*j + 0];
|
add_var_table[2*(WIDTH+1)*i + 2*j + 0] = 1'b0;
|
||||||
add_var_table[2*(WIDTH+1)*i + 2*j + 1] = TABLE[2*WIDTH*i + 2*j + 1];
|
add_var_table[2*(WIDTH+1)*i + 2*j + 1] = 1'b0;
|
||||||
end else begin
|
end
|
||||||
add_var_table[2*(WIDTH+1)*i + 2*j + 0] = 1'b0;
|
|
||||||
add_var_table[2*(WIDTH+1)*i + 2*j + 1] = 1'b0;
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
endfunction
|
||||||
endfunction
|
|
||||||
|
|
||||||
generate
|
generate
|
||||||
genvar i, j;
|
genvar i, j;
|
||||||
if (DEPTH <= `PLA_MAX_PRODUCTS) begin // Convert to GAL_SOP object if it fits
|
if (DEPTH <= `PLA_MAX_PRODUCTS) begin // Convert to GAL_SOP object if it fits
|
||||||
GAL_SOP #(
|
GAL_SOP #(
|
||||||
.WIDTH(WIDTH),
|
.WIDTH(WIDTH),
|
||||||
.DEPTH(DEPTH),
|
.DEPTH(DEPTH),
|
||||||
.TABLE(TABLE))
|
.TABLE(TABLE)
|
||||||
_TECHMAP_REPLACE_ (
|
) _TECHMAP_REPLACE_ (
|
||||||
.A(A),
|
.A(A),
|
||||||
.Y(Y)
|
.Y(Y)
|
||||||
);
|
);
|
||||||
end else begin // Otherwise split into two new SOP objects
|
end else begin // Otherwise split into two new SOP objects
|
||||||
wire partial;
|
wire partial;
|
||||||
\$__sop #(
|
\$__sop #(
|
||||||
.WIDTH(WIDTH),
|
.WIDTH(WIDTH),
|
||||||
.DEPTH(`PLA_MAX_PRODUCTS),
|
.DEPTH(`PLA_MAX_PRODUCTS),
|
||||||
.TABLE(TABLE[2*WIDTH*`PLA_MAX_PRODUCTS-1:0])
|
.TABLE(TABLE[2*WIDTH*`PLA_MAX_PRODUCTS-1:0])
|
||||||
) sop_partial (
|
) sop_partial (
|
||||||
.A(A),
|
.A(A),
|
||||||
.Y(partial)
|
.Y(partial)
|
||||||
);
|
);
|
||||||
|
|
||||||
localparam EXTRA_VAR_TABLE = add_var_table();
|
|
||||||
\$__sop #(
|
|
||||||
.WIDTH(WIDTH+1),
|
|
||||||
.DEPTH(DEPTH-`PLA_MAX_PRODUCTS+1),
|
|
||||||
.TABLE({EXTRA_VAR_TABLE[2*(WIDTH+1)*DEPTH-1:2*(WIDTH+1)*`PLA_MAX_PRODUCTS], {2'b10, {{WIDTH}{2'b00}}}})
|
|
||||||
) sop_rest (
|
|
||||||
.A({partial, A}),
|
|
||||||
.Y(Y)
|
|
||||||
);
|
|
||||||
end
|
|
||||||
endgenerate
|
|
||||||
|
|
||||||
|
localparam EXTRA_VAR_TABLE = add_var_table();
|
||||||
|
\$__sop #(
|
||||||
|
.WIDTH(WIDTH+1),
|
||||||
|
.DEPTH(DEPTH-`PLA_MAX_PRODUCTS+1),
|
||||||
|
.TABLE({EXTRA_VAR_TABLE[2*(WIDTH+1)*DEPTH-1:2*(WIDTH+1)*`PLA_MAX_PRODUCTS], {2'b10, {{WIDTH}{2'b00}}}})
|
||||||
|
) sop_rest (
|
||||||
|
.A({partial, A}),
|
||||||
|
.Y(Y)
|
||||||
|
);
|
||||||
|
end
|
||||||
|
endgenerate
|
||||||
endmodule
|
endmodule
|
||||||
|
|
32
techmaps/pla_olmc_int.v
Normal file
32
techmaps/pla_olmc_int.v
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
(* techmap_celltype = "GAL_SOP" *)
|
||||||
|
module _80_GAL_SOP (A, Y);
|
||||||
|
parameter WIDTH = 0;
|
||||||
|
parameter DEPTH = 0;
|
||||||
|
parameter TABLE = 0;
|
||||||
|
|
||||||
|
input [WIDTH-1:0] A;
|
||||||
|
output Y;
|
||||||
|
|
||||||
|
generate
|
||||||
|
wire internal;
|
||||||
|
|
||||||
|
GAL_OLMC #(
|
||||||
|
.REGISTERED(1'b0),
|
||||||
|
.INVERTED(1'b0)
|
||||||
|
) olmc_inst (
|
||||||
|
.C(1'bX),
|
||||||
|
.E(1'b1),
|
||||||
|
.A(internal),
|
||||||
|
.Y(Y)
|
||||||
|
);
|
||||||
|
|
||||||
|
GAL_SOP #(
|
||||||
|
.WIDTH(WIDTH),
|
||||||
|
.DEPTH(DEPTH),
|
||||||
|
.TABLE(TABLE)
|
||||||
|
) _TECHMAP_REPLACE_ (
|
||||||
|
.A(A),
|
||||||
|
.Y(internal)
|
||||||
|
);
|
||||||
|
endgenerate
|
||||||
|
endmodule
|
Loading…
Reference in a new issue