这里把利用verilog-a 模型实现迟滞比较器的方法记录一下。
关于迟滞比较器,在实际的模型的构建中主要是考虑利用@cross 语句来确定不同的翻转点, 这里需要注意的是初态的设置以保证翻转的触发。具体的verilog-a model描述如下
// VerilogA for comparator with hysteresis `include "constants.vams" `include "disciplines.vams"
module comparator (out,inp,inn); inout inp, inn; output out; electrical inp, inn, out;
parameter real offset = 0; // Offset voltage (V) parameter real hyst = 100m from [0:inf); // Hysteresis (V) parameter real thrlo = offset - 0.5*hyst; // Lower threshold voltage (V) parameter real thrhi = offset + 0.5*hyst; // Upper threshold voltage (V) parameter real vh=3.3; parameter real vl=0; parameter real ttol = 2p; parameter real td=20p; parameter real tt=10p; real n; analog begin @(initial_step) begin if (V(inp,inn)>=offset) n=1; else n=0 ; end @(cross(V(inp,inn)-thrhi, 1, ttol)) n = 1; @(cross(V(inp,inn)-thrlo, -1, ttol)) n = 0; V(out) <+ transition(n ? vh : vl, td, tt); end endmodule
这里的主要问题是模型只能用于瞬态的分析,考虑到迟滞比较器的应用情况,上面的模型基本还是够用的。我们可以通过仿真来看下模型是否工作,对其做瞬态分析(输入信号的缓慢斜升/降),可以绘制得到下面的迟滞窗口,可见工作正常
|