|
发表于 2008-4-16 19:37:50
|
显示全部楼层
verilog-a 的i/o 不支持总线。
`include "discipline.h"
`include "constants.h"
//--------------------
// nor
//
// - nor gate
//
// vin1, vin2: [V,A]
// vout: [V,A]
//
// INSTANCE parameters
// vlogic_high = output voltage for high [V]
// vlogic_low = output voltage for high [V]
// vtrans = voltages above this at input are considered high [V]
// tdel, trise, tfall = {usual}
//
module nor_gate(vin1, vin2, vout);
input vin1, vin2;
output vout;
electrical vin1, vin2, vout;
parameter real vlogic_high = 5;
parameter real vlogic_low = 0;
parameter real vtrans = 1.4;
parameter real tdel = 2u from [0:inf);
parameter real trise = 1u from (0:inf);
parameter real tfall = 1u from (0:inf);
real vout_val;
integer logic1, logic2;
analog begin
@ ( initial_step ) begin
if (vlogic_high < vlogic_low) begin
$display("Range specification error. vlogic_high = (%E) less than vlogic_low = (%E).\n", vlogic_high, vlogic_low );
$finish;
end
if (vtrans > vlogic_high || vtrans < vlogic_low) begin
$display("Inconsistent $threshold specification w/logic family.\n");
end
end
logic1 = V(vin1) > vtrans;
logic2 = V(vin2) > vtrans;
@ (cross(V(vin1) - vtrans, 1)) logic1 = 1;
@ (cross(V(vin1) - vtrans, -1)) logic1 = 0;
@ (cross(V(vin2) - vtrans, 1)) logic2 = 1;
@ (cross(V(vin2) - vtrans, -1)) logic2 = 0;
//
// define the logic function.
//
vout_val = (!(logic1 || logic2)) ? vlogic_high : vlogic_low;
V(vout) <+ transition( vout_val, tdel, trise, tfall);
end
endmodule |
|