1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-01-30 02:32:53 +08:00

Adding ASIC parameter to special library functions

- Needed to map to specific proprietary libraries
- Need to hide actual cells behind abstraction due to NDA
This commit is contained in:
Andreas Olofsson 2016-04-15 23:25:49 -04:00
parent 3314051934
commit 8b24139be1
8 changed files with 211 additions and 138 deletions

View File

@ -5,7 +5,9 @@
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_clockgate #(parameter DW = 1) // width of data
module oh_clockgate #(parameter DW = 1, // width of data
parameter ASIC = 0 // use ASIC lib
)
(
input nrst, // active low sync reset (synced to input clk)
input clk, // clock input
@ -14,6 +16,7 @@ module oh_clockgate #(parameter DW = 1) // width of data
output [DW-1:0] eclk// enabled clock output
);
wire [DW-1:0] en_sh;
wire [DW-1:0] en_sl;

View File

@ -5,7 +5,8 @@
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_csa32 #(parameter DW = 1 // data width
module oh_csa32 #(parameter DW = 1, // data width
parameter ASIC = 0 // use asic library
)
( input [DW-1:0] in0, //input
input [DW-1:0] in1,//input
@ -13,12 +14,25 @@ module oh_csa32 #(parameter DW = 1 // data width
output [DW-1:0] s, //sum
output [DW-1:0] c //carry
);
assign s[DW-1:0] = in0[DW-1:0] ^ in1[DW-1:0] ^ in2[DW-1:0];
assign c[DW-1:0] = (in0[DW-1:0] & in1[DW-1:0]) |
(in1[DW-1:0] & in2[DW-1:0]) |
(in2[DW-1:0] & in0[DW-1:0] );
generate
if(ASIC)
begin
asic_csa32 i_csa32[DW-1:0] (.s(s[DW-1:0]),
.c(c[DW-1:0]),
.in2(in2[DW-1:0]),
.in1(in1[DW-1:0]),
.in0(in0[DW-1:0]));
end
else
begin
assign s[DW-1:0] = in0[DW-1:0] ^ in1[DW-1:0] ^ in2[DW-1:0];
assign c[DW-1:0] = (in0[DW-1:0] & in1[DW-1:0]) |
(in1[DW-1:0] & in2[DW-1:0]) |
(in2[DW-1:0] & in0[DW-1:0] );
end
endgenerate
endmodule // oh_csa32

View File

@ -5,7 +5,9 @@
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_csa42 #( parameter DW = 1) // data width
module oh_csa42 #( parameter DW = 1 , // data width
parameter ASIC = 0 // use asic library
)
( input [DW-1:0] in0, //input
input [DW-1:0] in1,//input
input [DW-1:0] in2,//input
@ -16,26 +18,42 @@ module oh_csa42 #( parameter DW = 1) // data width
output [DW-1:0] cout //carry out
);
wire [DW-1:0] s_int;
generate
if(ASIC)
begin
asic_csa42 i_csa42[DW-1:0] (.s(s[DW-1:0]),
.cout(cout[DW-1:0]),
.c(c[DW-1:0]),
.cin(cin[DW-1:0]),
.in3(in3[DW-1:0]),
.in2(in2[DW-1:0]),
.in1(in1[DW-1:0]),
.in0(in0[DW-1:0]));
end
else
begin
wire [DW-1:0] s_int;
assign s[DW-1:0] = in0[DW-1:0] ^
in1[DW-1:0] ^
in2[DW-1:0] ^
in3[DW-1:0] ^
cin[DW-1:0];
assign s_int[DW-1:0] = in1[DW-1:0] ^
in2[DW-1:0] ^
in3[DW-1:0];
assign c[DW-1:0] = (in0[DW-1:0] & s_int[DW-1:0]) |
(in0[DW-1:0] & cin[DW-1:0]) |
(s_int[DW-1:0] & cin[DW-1:0]);
assign cout[DW-1:0] = (in1[DW-1:0] & in2[DW-1:0]) |
(in1[DW-1:0] & in3[DW-1:0]) |
(in2[DW-1:0] & in3[DW-1:0]);
end // else: !if(ASIC)
endgenerate
assign s[DW-1:0] = in0[DW-1:0] ^
in1[DW-1:0] ^
in2[DW-1:0] ^
in3[DW-1:0] ^
cin[DW-1:0];
assign s_int[DW-1:0] = in1[DW-1:0] ^
in2[DW-1:0] ^
in3[DW-1:0];
assign c[DW-1:0] = (in0[DW-1:0] & s_int[DW-1:0]) |
(in0[DW-1:0] & cin[DW-1:0]) |
(s_int[DW-1:0] & cin[DW-1:0]);
assign cout[DW-1:0] = (in1[DW-1:0] & in2[DW-1:0]) |
(in1[DW-1:0] & in3[DW-1:0]) |
(in2[DW-1:0] & in3[DW-1:0]);
endmodule // oh_csa42

View File

@ -5,8 +5,9 @@
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_dsync #(parameter DW = 1, // width of data
parameter PS = 3 // mnumber of sync stages
module oh_dsync #(parameter DW = 1, // width of data
parameter PS = 3, // mnumber of sync stages
parameter ASIC = 0 // use asic library
)
(
input clk, // clock
@ -15,36 +16,43 @@ module oh_dsync #(parameter DW = 1, // width of data
output [DW-1:0] dout // synchronized data
);
reg [DW-1:0] sync_pipe[PS:0]; //extra cycle for DV
// variable length synchronizer pipe
genvar i;
generate
for(i=0;i<(PS+1);i=i+1)
if(i==0)
always @ (posedge clk or negedge nreset)
if(!nreset)
sync_pipe[0][DW-1:0] <= 'b0;
else
sync_pipe[0][DW-1:0] <= din[DW-1:0];
else
always @ (posedge clk or negedge nreset)
if(!nreset)
sync_pipe[i][DW-1:0] <= 'b0;
else
sync_pipe[i][DW-1:0] <= sync_pipe[i-1][DW-1:0];
endgenerate
generate
if(ASIC)
begin
asic_dsync #(.DW(DW))
asic_dsync(.clk(clk),
.nreset(nreset),
.din(din[DW-1:0]),
.dout(dout[DW-1:0]));
end
else
begin
reg [DW-1:0] sync_pipe[PS:0]; //extra cycle for DV
genvar i;
for(i=0;i<(PS+1);i=i+1)
if(i==0)
always @ (posedge clk or negedge nreset)
if(!nreset)
sync_pipe[0][DW-1:0] <= 'b0;
else
sync_pipe[0][DW-1:0] <= din[DW-1:0];
else
always @ (posedge clk or negedge nreset)
if(!nreset)
sync_pipe[i][DW-1:0] <= 'b0;
else
sync_pipe[i][DW-1:0] <= sync_pipe[i-1][DW-1:0];
`ifdef TARGET_SIM
// randomize sync delay based on value in per bit delay register
// delay to be forced from testbench
reg [DW-1:0] delay = 0;
assign dout[DW-1:0] = (delay[DW-1:0] & sync_pipe[PS][DW-1:0]) | //extra cycle
(~delay[DW-1:0] & sync_pipe[PS-1][DW-1:0]); //default
// randomize sync delay based on value in per bit delay register
// delay to be forced from testbench
reg [DW-1:0] delay = 0;
assign dout[DW-1:0] = (delay[DW-1:0] & sync_pipe[PS][DW-1:0]) | //extra cycle
(~delay[DW-1:0] & sync_pipe[PS-1][DW-1:0]); //default
`else
assign dout[DW-1:0] = sync_pipe[PS-1][DW-1:0];
assign dout[DW-1:0] = sync_pipe[PS-1][DW-1:0];
`endif
end
endgenerate
endmodule // oh_dsync

View File

@ -8,6 +8,7 @@
module oh_memory_dp # (parameter DW = 104, //memory width
parameter DEPTH = 32, //memory depth
parameter PROJ = "", //project name
parameter ASIC = 0, // use ASIC lib
parameter MCW = 8, //repair/config vector width
parameter AW = $clog2(DEPTH) // address bus width
)
@ -36,12 +37,12 @@ module oh_memory_dp # (parameter DW = 104, //memory width
input [DW-1:0] bist_din // data input
);
`ifdef CFG_ASIC
//NOT IMPLEMENTED...
oh_memory_ram #(.DW(DW),
.DEPTH(DEPTH))
oh_memory_ram (//read port
generate
if(ASIC)
begin
oh_memory_ram #(.DW(DW),
.DEPTH(DEPTH))
i_sram (//read port
.rd_dout (rd_dout[DW-1:0]),
.rd_clk (rd_clk),
.rd_en (rd_en),
@ -52,23 +53,25 @@ module oh_memory_dp # (parameter DW = 104, //memory width
.wr_addr (wr_addr[AW-1:0]),
.wr_wem (wr_wem[DW-1:0]),
.wr_din (wr_din[DW-1:0]));
`else
oh_memory_ram #(.DW(DW),
.DEPTH(DEPTH))
oh_memory_ram (//read port
.rd_dout (rd_dout[DW-1:0]),
.rd_clk (rd_clk),
.rd_en (rd_en),
.rd_addr (rd_addr[AW-1:0]),
//write port
.wr_en (wr_en),
.wr_clk (wr_clk),
.wr_addr (wr_addr[AW-1:0]),
.wr_wem (wr_wem[DW-1:0]),
.wr_din (wr_din[DW-1:0]));
`endif
end // if (ASIC)
else
begin
oh_memory_ram #(.DW(DW),
.DEPTH(DEPTH))
oh_memory_ram (//read port
.rd_dout (rd_dout[DW-1:0]),
.rd_clk (rd_clk),
.rd_en (rd_en),
.rd_addr (rd_addr[AW-1:0]),
//write port
.wr_en (wr_en),
.wr_clk (wr_clk),
.wr_addr (wr_addr[AW-1:0]),
.wr_wem (wr_wem[DW-1:0]),
.wr_din (wr_din[DW-1:0]));
end // else: !if(ASIC)
endgenerate
endmodule // oh_memory_dp

View File

@ -5,10 +5,11 @@
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_memory_sp # (parameter DW = 104, //memory width
parameter DEPTH = 32, //memory depth
parameter PROJ = "", //project name
parameter MCW = 8 //repair/config vector width
module oh_memory_sp # (parameter DW = 104, // memory width
parameter DEPTH = 32, // memory depth
parameter PROJ = "", // project name
parameter ASIC = 0, // use ASIC lib
parameter MCW = 8 // repair/config vector width
)
(// memory interface (single port)
input clk, // clock
@ -35,51 +36,51 @@ module oh_memory_sp # (parameter DW = 104, //memory width
parameter AW = $clog2(DEPTH); // address bus width
`ifdef CFG_ASIC
//Actual IP hidden behind wrapper to protect the innocent
sram_sp #(.DW(DW),
.DEPTH(DEPTH),
.PROJ(PROJ),
.MCW(MCW))
sram_sp (// Outputs
.dout (dout[DW-1:0]),
// Inputs
.clk (clk),
.en (en),
.we (we),
.wem (wem[DW-1:0]),
.addr (addr[AW-1:0]),
.din (din[DW-1:0]),
.vdd (vdd),
.vddm (vddm),
.vss (vss),
.shutdown (shutdown),
.memconfig (memconfig[MCW-1:0]),
.memrepair (memrepair[MCW-1:0]),
.bist_en (bist_en),
.bist_we (bist_we),
.bist_wem (bist_wem[DW-1:0]),
.bist_addr (bist_addr[AW-1:0]),
.bist_din (bist_din[DW-1:0]));
`else
oh_memory_ram #(.DW(DW),
.DEPTH(DEPTH))
oh_memory_ram (//read port
.rd_dout (dout[DW-1:0]),
.rd_clk (clk),
.rd_addr (addr[AW-1:0]),
.rd_en (en & ~we),
//write port
.wr_clk (clk),
.wr_en (en & we),
.wr_addr (addr[AW-1:0]),
.wr_wem (wem[DW-1:0]),
.wr_din (din[DW-1:0]));
`endif
generate
if(ASIC)
begin
asic_sram_sp #(.DW(DW),
.DEPTH(DEPTH),
.PROJ(PROJ),
.MCW(MCW))
i_sram (// Outputs
.dout (dout[DW-1:0]),
// Inputs
.clk (clk),
.en (en),
.we (we),
.wem (wem[DW-1:0]),
.addr (addr[AW-1:0]),
.din (din[DW-1:0]),
.vdd (vdd),
.vddm (vddm),
.vss (vss),
.shutdown (shutdown),
.memconfig (memconfig[MCW-1:0]),
.memrepair (memrepair[MCW-1:0]),
.bist_en (bist_en),
.bist_we (bist_we),
.bist_wem (bist_wem[DW-1:0]),
.bist_addr (bist_addr[AW-1:0]),
.bist_din (bist_din[DW-1:0]));
end
else
begin
oh_memory_ram #(.DW(DW),
.DEPTH(DEPTH))
oh_memory_ram (//read port
.rd_dout (dout[DW-1:0]),
.rd_clk (clk),
.rd_addr (addr[AW-1:0]),
.rd_en (en & ~we),
//write port
.wr_clk (clk),
.wr_en (en & we),
.wr_addr (addr[AW-1:0]),
.wr_wem (wem[DW-1:0]),
.wr_din (din[DW-1:0]));
end
endgenerate
endmodule // oh_memory_sp

View File

@ -5,14 +5,25 @@
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_pwr_gate (input npower, // active low power on
input vdd, // input supply
output vddg // gated output supply
);
module oh_pwr_gate #(parameter ASIC = 0 // use ASIC lib
)
(input npower, // active low power on
input vdd, // input supply
output vddg // gated output supply
);
`ifdef TARGET_SIM
assign vddg = ((vdd===1'b1) && (npower===1'b0)) ? 1'b1 : 1'bX;
`else
generate
if(ASIC)
begin
asic_pwr_header i_header (.npower(npower),
.vdd(vdd),
.vddg(vddg));
end
endgenerate
`endif
endmodule // oh_pwr_gate

View File

@ -5,20 +5,35 @@
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_pwr_isolate #(parameter DW = 1) // width of data inputs
module oh_pwr_isolate #(parameter DW = 1, // width of data inputs
parameter ASIC = 0 // use ASIC lib
)
(
input vdd, // supply (set to 1 if valid)
input vss, // ground (set to 0 if valid)
input niso, // active low isolation signal
input [DW-1:0] in, // input signal
output [DW-1:0] out // buffered output signal
input niso,// active low isolation signal
input [DW-1:0] in, // input signal
output [DW-1:0] out // buffered output signal
);
`ifdef TARGET_SIM
assign out[DW-1:0] = ((vdd===1'b1) && (vss===1'b0)) ? ({(DW){niso}} & in[DW-1:0]):
{(DW){1'bX}};
`else
assign out[DW-1:0] = {(DW){niso}} & in[DW-1:0];
generate
if(ASIC)
begin
asic_iso i_iso [DW-1:0] (.vdd(vdd),
.vss(vss),
.in(in[DW-1:0]),
.out(out[DW-1:0]));
end
else
begin
assign out[DW-1:0] = {(DW){niso}} & in[DW-1:0];
end
endgenerate
`endif
endmodule // oh_buf