2 Star 1 Fork 0

史峰/basic_verilog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
priority_enc.sv 1.60 KB
一键复制 编辑 原始数据 按行查看 历史
Konstantin Pavlov 提交于 2022-06-06 09:53 . Added fifo combiner
//------------------------------------------------------------------------------
// priority_enc.sv
// Konstantin Pavlov, pavlovconst@gmail.com
//------------------------------------------------------------------------------
// INFO -------------------------------------------------------------------------
// Completely combinational priority_encoder
//
// See also round_robin_enc.sv
// See also round_robin_performance_enc.sv
//
/* --- INSTANTIATION TEMPLATE BEGIN ---
priority_enc #(
.WIDTH( 32 ) // WIDTH must be >=2
) PE1 (
.id( ),
.od_valid( ),
.od_filt( ),
.od_bin( )
);
--- INSTANTIATION TEMPLATE END ---*/
module priority_enc #( parameter
WIDTH = 32,
WIDTH_W = $clogb2(WIDTH)
)(
input [WIDTH-1:0] id, // input data bus
output od_valid, // output valid (some bits are active)
output [WIDTH-1:0] od_filt, // filtered data (only one priority bit active)
output [WIDTH_W-1:0] od_bin // priority bit binary index
);
// reversed id[] data
// conventional operation of priority encoder is when MSB bits have a priority
logic [WIDTH-1:0] id_r;
reverse_vector #(
.WIDTH( WIDTH ) // WIDTH must be >=2
) reverse_b (
.in( id[WIDTH-1:0] ),
.out( id_r[WIDTH-1:0] )
);
leave_one_hot #(
.WIDTH( WIDTH )
) one_hot_b (
.in( id_r[WIDTH-1:0] ),
.out( od_filt[WIDTH-1:0] )
);
logic err_no_hot;
assign od_valid = ~err_no_hot;
pos2bin #(
.BIN_WIDTH( WIDTH_W )
) pos2bin_b (
.pos( od_filt[WIDTH-1:0] ),
.bin( od_bin[WIDTH_W-1:0] ),
.err_no_hot( err_no_hot ),
.err_multi_hot( )
);
`include "clogb2.svh"
endmodule
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Verilog
1
https://gitee.com/shi-feng-logic/basic_verilog.git
git@gitee.com:shi-feng-logic/basic_verilog.git
shi-feng-logic
basic_verilog
basic_verilog
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385