Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

One hot encoding with combo logic

Status
Not open for further replies.

cnivaz

Newbie level 6
Joined
Sep 22, 2006
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,382
how to check one hot encoding

Hello,
How to check the data , whether it is one hotted or not, with combo logic. Assume that the data bus width is 32 bit. I tried to implement in sequential logic , it consumed 32 clock cycles to find the result.


Thanks and Regards
Nivaz
 

Re: One hot encoding

Hi,

here is the code to decode one hot encoding :

module test(din,onehot_out);

input [31:0] din;
output onehot_out;

reg onehot_out;

function integer decode_onehot
input [31:0] data;
integer i,bits;
begin
decode_onehot = -1;
bits = 0;
for(i=0;i<=31;i=i+1)
if(data) begin
decode_onehot = i;
bits = bits + 1;
end
if(bits != 1)
$display("Error : data is not one hot encoded");
end
endfunction

always@(din)
begin
if(decode_onehot(din) > -1)
onehot_out = 1'b1;
else
onehot_out = 1'b0;
end

endmodule

Let me know if it doesnt work...

Regards,
dcreddy
 

Re: One hot encoding

cnivaz said:
Hello,
How to check the data , whether it is one hotted or not, with combo logic. Assume that the data bus width is 32 bit. I tried to implement in sequential logic , it consumed 32 clock cycles to find the result.


Thanks and Regards
Nivaz

If you use SVA or PSL, it is very simple:

Code:
  a1_one_hot : assert ($onehot(my_vec)) else $error ("my_vec is NOT one hot! %0b ", my_vec)

HTH
Ajeetha, CVC
www.noveldv.com
 

Re: One hot encoding

Hi,
can u pls give me description for " one hot encoding meaning"

Thanks
MRK
 

One hot encoding

hey
"one hot encoding" means that you provide separate output f/f for each state. This means at one time only one will be active.
Let sat you are designing a 3 bit counter.Normally the output will be of two bits(with one don't care) but with "one hot encoding" output will be three bits wide each bit will be on for a different state.

Regards
tronix
 

Re: One hot encoding

Hi,

Can One-Hot encoding makes Data Path Short.

If yes How.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top