verilog-A model for binary-to-thermometer decoder

Status
Not open for further replies.

sharkies

Member level 5
Joined
Jul 12, 2008
Messages
81
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
2,009
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


can somebody help me out ugh..
 

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
I guess you can put together the module...
 
Thank a bunch, problem solved
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…