diff options
author | Clifford Wolf <clifford@clifford.at> | 2013-01-05 11:13:26 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2013-01-05 11:13:26 +0100 |
commit | 7764d0ba1dcf064ae487ee985c43083a0909e7f4 (patch) | |
tree | 18c05b8729df381af71b707748ce1d605e0df764 /tests/asicworld/code_hdl_models_encoder_using_if.v |
initial import
Diffstat (limited to 'tests/asicworld/code_hdl_models_encoder_using_if.v')
-rw-r--r-- | tests/asicworld/code_hdl_models_encoder_using_if.v | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/asicworld/code_hdl_models_encoder_using_if.v b/tests/asicworld/code_hdl_models_encoder_using_if.v new file mode 100644 index 00000000..2c97ddba --- /dev/null +++ b/tests/asicworld/code_hdl_models_encoder_using_if.v @@ -0,0 +1,58 @@ +//----------------------------------------------------- +// Design Name : encoder_using_if +// File Name : encoder_using_if.v +// Function : Encoder using If +// Coder : Deepak Kumar Tala +//----------------------------------------------------- +module encoder_using_if( +binary_out , // 4 bit binary output +encoder_in , // 16-bit input +enable // Enable for the encoder +); +//-----------Output Ports--------------- +output [3:0] binary_out ; +//-----------Input Ports--------------- +input enable ; +input [15:0] encoder_in ; +//------------Internal Variables-------- +reg [3:0] binary_out ; +//-------------Code Start----------------- +always @ (enable or encoder_in) + begin + binary_out = 0; + if (enable) begin + if (encoder_in == 16'h0002) begin + binary_out = 1; + end if (encoder_in == 16'h0004) begin + binary_out = 2; + end if (encoder_in == 16'h0008) begin + binary_out = 3; + end if (encoder_in == 16'h0010) begin + binary_out = 4; + end if (encoder_in == 16'h0020) begin + binary_out = 5; + end if (encoder_in == 16'h0040) begin + binary_out = 6; + end if (encoder_in == 16'h0080) begin + binary_out = 7; + end if (encoder_in == 16'h0100) begin + binary_out = 8; + end if (encoder_in == 16'h0200) begin + binary_out = 9; + end if (encoder_in == 16'h0400) begin + binary_out = 10; + end if (encoder_in == 16'h0800) begin + binary_out = 11; + end if (encoder_in == 16'h1000) begin + binary_out = 12; + end if (encoder_in == 16'h2000) begin + binary_out = 13; + end if (encoder_in == 16'h4000) begin + binary_out = 14; + end if (encoder_in == 16'h8000) begin + binary_out = 15; + end + end +end + +endmodule |