00001 /********************************************************************************* 00002 * 00003 * Nordic Semiconductor ASA, Vestre Rosten 81, N-7075 TILLER, NORWAY 00004 * 00005 ********************************************************************************* 00006 * Project name : nrf4352 00007 * Project number : 1154352 00008 * File type : Encoder. 00009 * @author Markus Bakka Hjertø 00010 * Designers ver : $Id: Encoder.sv 92 2008-02-18 09:55:04Z nvlsi\mbh $ 00011 * Description : Encoder for DoxygenProject 00012 * Last fetched from repository location: 00013 * $URL: http://svn.nordicsemi.no/devmethod/mbh/DoxygenProject/codec/hdl/Encoder.sv $ 00014 * 00015 * SU : Jan Frode Lønnum (mailto:jfl@nordicsemi.no) 00016 * SU version : default_module.v,v 1.1 2001-09-07 00:07:53+02 rh Exp 00017 * DK release : dk_X.X.X 00018 * Installed date : Wed 29.11.2006 at 18:02:05 00019 * 00020 * Copyright (c) 2006 by Nordic Semiconductor ASA 00021 ********************************************************************************/ 00022 00071 module Encoder( 00072 output reg [3:0] binary_out , // 4 bit binary Output 00073 input wire [15:0] encoder_in , // 16-bit Input 00074 input wire enable // Enable for the encoder 00075 ); 00076 //--------------Code Starts Here----------------------- 00077 always_comb 00078 ENCODER : begin 00079 binary_out = 0; 00080 if (enable) begin 00081 case (encoder_in) 00082 16'h0002 : binary_out = 1; 00083 16'h0004 : binary_out = 2; 00084 16'h0008 : binary_out = 3; 00085 16'h0010 : binary_out = 4; 00086 16'h0020 : binary_out = 5; 00087 16'h0040 : binary_out = 6; 00088 16'h0080 : binary_out = 7; 00089 16'h0100 : binary_out = 8; 00090 16'h0200 : binary_out = 9; 00091 16'h0400 : binary_out = 10; 00092 16'h0800 : binary_out = 11; 00093 16'h1000 : binary_out = 12; 00094 16'h2000 : binary_out = 13; 00095 16'h4000 : binary_out = 14; 00096 16'h8000 : binary_out = 15; 00097 endcase 00098 end 00099 end 00100 00101 endmodule 00102