Skip to content

Commit

Permalink
First release to check build status
Browse files Browse the repository at this point in the history
  • Loading branch information
hpretl committed Feb 3, 2024
1 parent 3a9c7b7 commit 5ffec78
Show file tree
Hide file tree
Showing 12 changed files with 549 additions and 55 deletions.
4 changes: 2 additions & 2 deletions docs/info.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ There will be a better explanation in the future.

## How to test

Simply turn it on, and see the result.
Simply turn it on, and see the result. IO usage documented in the info.yml.

## External hardware

None needed.
Requires a logic analyzer or similar to inspect digital outputs.
57 changes: 31 additions & 26 deletions info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,48 @@ project:
tiles: "1x1" # Valid values: 1x1, 1x2, 2x2, 3x2, 4x2, 6x2 or 8x2

# Your top module name must start with "tt_um_". Make it unique by including your github username:
top_module: "tt_um_example"
top_module: "tt_um_hpretl_tt06_tempsens"

# List your project's source files here. Source files must be in ./src and you must list each source file separately, one per line:
source_files:
- "project.v"
- "tt_um_hpretl_tt06_tempsens.v"
- "tempsens.v"
- "tempsens_ctrl.v"
- "tempsens_core.v"
- "tempsens_vdac.v"
- "tempsens_vdac_cell.v"

# The pinout of your project. Leave unused pins blank. DO NOT delete or add any pins.
pinout:
# Inputs
ui[0]: ""
ui[1]: ""
ui[2]: ""
ui[3]: ""
ui[4]: ""
ui[5]: ""
ui[6]: ""
ui[7]: ""
ui[0]: "DAC code [0]"
ui[1]: "DAC code [1]"
ui[2]: "DAC code [2]"
ui[3]: "DAC code [3]"
ui[4]: "DAC code [4]"
ui[5]: "DAC code [5]"
ui[6]: "output selection [0]"
ui[7]: "output selection [1]"

# Outputs
uo[0]: ""
uo[1]: ""
uo[2]: ""
uo[3]: ""
uo[4]: ""
uo[5]: ""
uo[6]: ""
uo[7]: ""
uo[0]: "out[0] or out[8] or out[16]"
uo[1]: "out[1] or out[9] or out[17]"
uo[2]: "out[2] or out[10] or out[18]"
uo[3]: "out[3] or out[11] or out[19]"
uo[4]: "out[4] or out[12]"
uo[5]: "out[5] or out[13]"
uo[6]: "out[6] or out[14]"
uo[7]: "out[7] or out[15]"

# Bidirectional pins
uio[0]: ""
uio[1]: ""
uio[2]: ""
uio[3]: ""
uio[4]: ""
uio[5]: ""
uio[6]: ""
uio[7]: ""
uio[0]: "debug sel [0]"
uio[1]: "debug sel [1]"
uio[2]: "debug sel [2]"
uio[3]: "debug sel [3]"
uio[4]: "debug out [0]"
uio[5]: "debug out [1]"
uio[6]: "debug out [2]"
uio[7]: "debug out [3]"

# Do not change!
yaml_version: 6
6 changes: 5 additions & 1 deletion src/config.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ set ::env(PL_RESIZER_HOLD_SLACK_MARGIN) 0.1
set ::env(GLB_RESIZER_HOLD_SLACK_MARGIN) 0.05

# RUN_LINTER, LINTER_INCLUDE_PDK_MODELS - Disabling the linter is not recommended!
set ::env(RUN_LINTER) 1
set ::env(RUN_LINTER) 0
set ::env(LINTER_INCLUDE_PDK_MODELS) 1

# Configuration docs: https://openlane.readthedocs.io/en/latest/reference/configuration.html

# Avoid messing around with analog signals
set ::env(RSZ_DONT_TOUCH_RX) "_ana_"
set ::env(QUIT_ON_SYNTH_CHECKS) 0

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# !!! DO NOT CHANGE ANYTHING BELOW THIS POINT !!!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
24 changes: 0 additions & 24 deletions src/project.v

This file was deleted.

70 changes: 70 additions & 0 deletions src/tempsens.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2024 Harald Pretl
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This cell combines the digital control of the temperature sensor
// (which can be simulated digitally) with the analog part of the
// temperature sensor that has to be simulated analog. In this way
// a mixed-mode simulation can be setup efficiently.

`ifndef __TEMPSENS__
`define __TEMPSENS__

`default_nettype none
`include "../src/tempsens_ctrl.v"
`include "../src/tempsens_core.v"

module tempsens (
// main inputs
input wire reset,
input wire clk,
input wire [N_VDAC-1:0] i_dac_code,
input wire [3:0] i_dbg_sel,
// main outputs
output wire [N_TEMP-1:0] o_res,
output wire [3:0] o_dbg
);

localparam N_TEMP = 20;
localparam N_VDAC = 6;
localparam CAP_LOAD = 16;

// local interconnect wires
wire [N_VDAC-1:0] ts_dat;
wire ts_en;
wire ts_tempdelay;
wire ts_prechrgn;

tempsens_ctrl #( .N_TEMP(N_TEMP), .N_VDAC(N_VDAC) ) ts_ctrl (
.reset(reset),
.clk(clk),
.i_dac_code(i_dac_code),
.i_dbg_sel(i_dbg_sel),
.o_res(o_res),
.o_dbg(o_dbg),
.i_ts_tempdelay(ts_tempdelay),
.o_ts_en(ts_en),
.o_ts_dat(ts_dat),
.o_ts_prechrgn(ts_prechrgn)
);

tempsens_core #(.DAC_RESOLUTION(N_VDAC), .CAP_LOAD(CAP_LOAD)) ts_core (
.clk(clk),
.i_dac_data(ts_dat),
.i_dac_en(ts_en),
.i_precharge_n(ts_prechrgn),
.o_tempdelay(ts_tempdelay)
);

endmodule // tempsens
`endif
118 changes: 118 additions & 0 deletions src/tempsens_core.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// Copyright 2022-2024 Manuel Moser and Harald Pretl
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This cell implements a digitall-controlled delay cell (dcdel), which when
// operated in subthreshold has a strong temperature dependcy of the delay time.
// This effect can be used to implement e.g. a digital temperature sensor.
//
// IMPORTANT: Make sure that the synthesis and optimization tools do not mess
// with the resulting netlist, especially at the node `vout_ana_`!
//
// CHANGES
// 2023-12-31 (HP) Rename net _notouch_ to _ana_
// 2024-01-04 (HP) Improve simulation model to provide better results
// 2024-01-12 (HP) Rename to tempsens_core
// 2024-01-13 (HP) Add clk input and synchronization of output signal

`ifndef __TEMPSENS_CORE__
`define __TEMPSENS_CORE__

`default_nettype none
`timescale 1ns/1ns
`ifndef SIMULATION
`include "tempsens_vdac.v"
`endif
//`include "/foss/pdks/sky130A/libs.ref/sky130_fd_sc_hd/verilog/sky130_fd_sc_hd.v"
//`include "/foss/pdks/sky130A/libs.ref/sky130_fd_sc_hd/verilog/primitives.v"

module tempsens_core #( parameter DAC_RESOLUTION=6, parameter CAP_LOAD=16 )(
input wire clk,
input wire [DAC_RESOLUTION-1:0] i_dac_data,
input wire i_dac_en,
input wire i_precharge_n,
`ifdef SIMULATION
output reg o_tempdelay
`else
output wire o_tempdelay
`endif
);

// during precharging and measurement, o_tempdelay stays high
// a 1->0 transition marks the end of the measurement time

`ifdef SIMULATION
wire dac0, dac1, dac_change;
assign dac0 = ~|i_dac_data;
assign dac1 = &i_dac_data;

always @(*) begin
if (i_dac_en == 1'b0) begin
#1 o_tempdelay = 1'bx;
end else begin
if ((dac1 == 1'b1) && (i_precharge_n == 1'b0)) begin
// precharge
#1 o_tempdelay = 1'b1;
end

if ((dac0 == 1'b0) && (i_precharge_n == 1'b1)) begin
if (i_dac_data >25) begin
#10000 o_tempdelay = 1'b0;
end else if (i_dac_data < 25) begin
#200000 o_tempdelay = 1'b0;
end else #40000 o_tempdelay = 1'b0;
end
end
end
`else
// Voltage-mode digital-to-analog converter (VDAC)
(* keep = "true" *) wire dac_vout_ana_;
(* keep = "true" *) wire tempdelay_async;
(* keep = "true" *) tempsens_vdac #(.BITWIDTH(DAC_RESOLUTION)) dac (
.i_data(i_dac_data),
.i_enable(i_dac_en),
.vout_ana_(dac_vout_ana_)
);

// Digitally-controled delay cell (dcdel)
wire tie0 = 1'b0;
(* keep = "true" *) wire dcdel_capnode_ana_;
(* keep = "true" *) wire dcdel_out_n;
// verilator lint_off UNUSED
(* keep = "true" *) wire [CAP_LOAD-1:0] dummy_ana_;
// verilator lint_on UNSIGNED

(* keep = "true" *) sky130_fd_sc_hd__einvp_1 dcdc (.A(i_precharge_n), .TE(dac_vout_ana_), .Z(dcdel_capnode_ana_));
(* keep = "true" *) sky130_fd_sc_hd__inv_1 inv1 (.A(dcdel_capnode_ana_),.Y(dcdel_out_n));
(* keep = "true" *) sky130_fd_sc_hd__inv_1 inv2 (.A(dcdel_out_n),.Y(tempdelay_async));

genvar i;
generate
for (i=0; i < CAP_LOAD; i=i+1) begin : capload
(* keep = "true" *) sky130_fd_sc_hd__nand2_1 cap (.B(dcdel_capnode_ana_), .A(tie0), .Y(dummy_ana_[i]));
end
endgenerate

// We need to sync-in the async. delayed signal, do on falling clk edge
reg tempdelay_sync1, tempdelay_sync2;
assign o_tempdelay = tempdelay_sync2;

always @(negedge clk) begin
tempdelay_sync2 <= tempdelay_sync1;
tempdelay_sync1 <= tempdelay_async;
end

`endif

endmodule // tempsens_core
`endif
Loading

0 comments on commit 5ffec78

Please sign in to comment.