I am writing a verilog-A model for binary-to-thermometer decoder. NOT verilog!
For a beginner like me, this is quite tough...
I think I keep getting confused with all the verilog, verilog-ams, verilog-A syntax
compile errors everywhere,,
Really frustrating
I take a 3bit input, and need to output a 8bit...
I wrote a code that counts the total number of thermometer output signal that needs to be high
You can easily do it the generate construct, in the analog block. You first need to convert your binary input (say in[2:0]) into an integer (say sum) and then use a for loop as in the snippet below.
Code:
analog begin
sum = 0;
generate i (0,2)
sum=sum+((V(in[i])>VT)?1:0)*pow(2,i);
for (i=0; i<=7; i=i+1)
if(i<sum)
out_v[i]=1;
else
out_v[i]=0;
generate i (7,0)
V(out[i])<+transition(out_v[i],TD,TR,TF);
end