1
0
Fork 0
mirror of https://github.com/annoyatron255/yosys4gal.git synced 2025-01-01 23:08:24 +00:00

Add OLMC on internal combinational nodes

This commit is contained in:
annoyatron255 2024-04-04 13:54:11 -05:00
parent 8c695d0fb3
commit e9a9c68f88
No known key found for this signature in database
GPG key ID: 95283811BE4E93F8
5 changed files with 107 additions and 98 deletions

View file

@ -1,28 +1,9 @@
module NDFF_P (
input C, D,
output Q
);
module NDFF_P (C, D, Q);
input C, D;
output Q;
wire Y;
$_NOT_ not_inst (.A(D), .Y(Y));
DFF_P dff_inst (.D(Y), .C(C), .Q(Q));
wire Y;
$_NOT_ not_inst (.A(D), .Y(Y));
DFF_P dff_inst (.D(Y), .C(C), .Q(Q));
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*/

View file

@ -1,20 +1,15 @@
module REG_OUT_P (
input C, A,
output Y
);
DFF_P dff_p_inst (.C(C), .D(A), .Q(Y));
GAL_OUTPUT gal_output_inst (.A(Y));
module REG_OUT_P (C, A, Y);
input C, A;
output Y;
DFF_P dff_p_inst (.C(C), .D(A), .Q(Y));
GAL_OUTPUT gal_output_inst (.A(Y));
endmodule
module REG_OUT_N (
input C, A,
output Y
);
NDFF_P dff_p_inst (.C(C), .D(A), .Q(Y));
GAL_OUTPUT gal_output_inst (.A(X));
module REG_OUT_N (C, A, Y);
input C, A;
output Y;
NDFF_P dff_p_inst (.C(C), .D(A), .Q(Y));
GAL_OUTPUT gal_output_inst (.A(X));
endmodule

View file

@ -40,7 +40,7 @@ if {$num_regs > 0} { set num_inputs_regs [expr $num_inputs_regs - 1] }
#abc -sop -I 8 -P 8
#abc -script "+strash;,dretime;,collapse;,write_pla,test.pla" -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
#select "t:\$sop" r:DEPTH>8 %i
@ -48,19 +48,19 @@ abc -script "abc.script" -sop
#yosys proc
#techmap
#select *
#abc -sop -I $num_inputs_regs -P 8
abc -sop -I $num_inputs_regs -P 7
opt
clean -purge
show -width
#show -width
## Tech mapping
# Logic
techmap -map techmaps/pla.v -D PLA_MAX_PRODUCTS=10000
# PLAs
techmap -map techmaps/pla.v -D PLA_MAX_PRODUCTS=7
# Sequential OLMC
extract -map extractions/ndff.v
extract -constports -map extractions/ndff.v
extract -constports -map extractions/olmc.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
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
## Write output files and graph

View file

@ -4,62 +4,60 @@ $fatal(1, "Macro PLA_MAX_PRODUCTS must be defined");
(* techmap_celltype = "$sop $__sop" *)
module _80_sop (A, Y);
parameter WIDTH = 0;
parameter DEPTH = 0;
parameter TABLE = 0;
parameter WIDTH = 0;
parameter DEPTH = 0;
parameter TABLE = 0;
input [WIDTH-1:0] A;
output reg Y;
input [WIDTH-1:0] A;
output reg Y;
// Add a blank variable to TABLE
function [2*(WIDTH+1)*DEPTH-1:0] add_var_table;
integer i, j;
for (i = 0; i < DEPTH; i=i+1) begin
for (j = 0; j < WIDTH + 1; j=j+1) begin
if (j < WIDTH) 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 + 1] = TABLE[2*WIDTH*i + 2*j + 1];
end else begin
add_var_table[2*(WIDTH+1)*i + 2*j + 0] = 1'b0;
add_var_table[2*(WIDTH+1)*i + 2*j + 1] = 1'b0;
// Add a blank variable to TABLE
function [2*(WIDTH+1)*DEPTH-1:0] add_var_table;
integer i, j;
for (i = 0; i < DEPTH; i=i+1) begin
for (j = 0; j < WIDTH + 1; j=j+1) begin
if (j < WIDTH) 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 + 1] = TABLE[2*WIDTH*i + 2*j + 1];
end else begin
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
endfunction
endfunction
generate
genvar i, j;
if (DEPTH <= `PLA_MAX_PRODUCTS) begin // Convert to GAL_SOP object if it fits
GAL_SOP #(
.WIDTH(WIDTH),
.DEPTH(DEPTH),
.TABLE(TABLE))
_TECHMAP_REPLACE_ (
.A(A),
.Y(Y)
);
end else begin // Otherwise split into two new SOP objects
wire partial;
\$__sop #(
.WIDTH(WIDTH),
.DEPTH(`PLA_MAX_PRODUCTS),
.TABLE(TABLE[2*WIDTH*`PLA_MAX_PRODUCTS-1:0])
) sop_partial (
.A(A),
.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
generate
genvar i, j;
if (DEPTH <= `PLA_MAX_PRODUCTS) begin // Convert to GAL_SOP object if it fits
GAL_SOP #(
.WIDTH(WIDTH),
.DEPTH(DEPTH),
.TABLE(TABLE)
) _TECHMAP_REPLACE_ (
.A(A),
.Y(Y)
);
end else begin // Otherwise split into two new SOP objects
wire partial;
\$__sop #(
.WIDTH(WIDTH),
.DEPTH(`PLA_MAX_PRODUCTS),
.TABLE(TABLE[2*WIDTH*`PLA_MAX_PRODUCTS-1:0])
) sop_partial (
.A(A),
.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
endmodule

32
techmaps/pla_olmc_int.v Normal file
View 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