Verilog八线 - 三线优先编码器设计(74LS148)
if语句法
//8线-3线优先编码器设计(74LS148)
//
//EI | A7 A6 A5 A4 A3 A2 A1 A0 | Y2 Y1 Y0 GS EO
//0 | 0 x x x x x x x | 0 0 0 0 1
//0 | 1 0 x x x x x x | 0 0 1 0 1
//0 | 1 1 0 x x x x x | 0 1 0 0 1
//0 | 1 1 1 0 x x x x | 0 1 1 0 1
//0 | 1 1 1 1 0 x x x | 1 0 0 0 1
//0 | 1 1 1 1 1 0 x x | 1 0 1 0 1
//0 | 1 1 1 1 1 1 0 x | 1 1 0 0 1
//0 | 1 1 1 1 1 1 1 0 | 1 1 1 0 1
//0 | 1 1 1 1 1 1 1 1 | 1 1 1 1 0
//1 | x x x x x x x x | 1 1 1 1 1 module encoder_83 (din, EI, GS, EO, dout);
input [:] din; //编码输入端data_in,低电平有效
input EI; //使能输入端EI(选通输入端),EI为 0 时芯片工作,即允许编码
output [:] dout; //编码输出端data_out
output GS; //片优先编码输出端,优先编码器工作工作状态标志GS,低电平有效
output EO; //使能输出端EO(选通输出端)
reg [:] dout;
reg GS, EO;
always @(din or EI)
if(EI) begin dout <= 'b111; GS <= 1; EO <= 1; end //所有输出端被锁存在高电平
else if (din[] == ) begin dout <= 'b000; GS <= 0; EO <= 1; end
else if (din[] == ) begin dout <= 'b001; GS <= 0; EO <= 1; end
else if (din[] == ) begin dout <= 'b010; GS <= 0; EO <= 1; end
else if (din[] == ) begin dout <= 'b011; GS <= 0; EO <= 1; end
else if (din[] == ) begin dout <= 'b100; GS <= 0; EO <= 1; end
else if (din[] == ) begin dout <= 'b101; GS <= 0; EO <= 1; end
else if (din[] == ) begin dout <= 'b110; GS <= 0; EO <= 1; end
else if (din[] == ) begin dout <= 'b111; GS <= 0; EO <= 1; end
else if (din == 'b11111111) begin dout <= 3'b111; GS <= ; EO <= ; end //芯片工作,但无编码输入
else begin dout <= 'b111; GS <= 1; EO <= 1; end //消除锁存器(latch)
endmodule //EI = 0 表示允许编码,否则所有输出端被封锁在高电平(控制芯片工作)
//EO = 0 表示电路工作,但无编码输入(用于级联)
//GS = 0 表示电路工作,且有编码输入(判断输入端是否有输入)

testbench:
`timescale ps/ ps
module encoder_83_vlg_tst();
reg EI;
reg [:] din;
wire EO;
wire GS;
wire [:] dout;
encoder_83 i1 (.EI(EI), .EO(EO), .GS(GS), .din(din), .dout(dout));
initial
begin
EI = ;
din = 'b11111111;
# EI = ;
# din = 'b01010101;
# din = 'b10101010;
# din = 'b11010101;
# din = 'b11101010;
# din = 'b11110101;
# din = 'b11111010;
# din = 'b11111101;
# din = 'b11111110;
# din = 'b11111111;
end
endmodule


case语句法
//8线-3线优先编码器设计(74LS148)
//
//EI | A7 A6 A5 A4 A3 A2 A1 A0 | Y2 Y1 Y0 GS EO
//0 | 0 x x x x x x x | 0 0 0 0 1
//0 | 1 0 x x x x x x | 0 0 1 0 1
//0 | 1 1 0 x x x x x | 0 1 0 0 1
//0 | 1 1 1 0 x x x x | 0 1 1 0 1
//0 | 1 1 1 1 0 x x x | 1 0 0 0 1
//0 | 1 1 1 1 1 0 x x | 1 0 1 0 1
//0 | 1 1 1 1 1 1 0 x | 1 1 0 0 1
//0 | 1 1 1 1 1 1 1 0 | 1 1 1 0 1
//0 | 1 1 1 1 1 1 1 1 | 1 1 1 1 0
//1 | x x x x x x x x | 1 1 1 1 1 module encoder_83_case (din, EI, GS, EO, dout);
input [:] din; //编码输入端data_in,低电平有效
input EI; //使能输入端EI(选通输入端),EI为 0 时芯片工作,即允许编码
output [:] dout; //编码输出端data_out
output GS; //片优先编码输出端,优先编码器工作工作状态标志GS,低电平有效
output EO; //使能输出端EO(选通输出端)
reg [:] dout;
reg GS, EO;
always @(din or EI)
if(EI)
begin dout <= 'b111; GS <= 1; EO <= 1; end //所有输出端被锁存在高电平
else
casez (din) //建议用casez语句,casez把z/?匹配成任意。 casex把z/?/x匹配成任意,x为仿真初态
'b0??????? : begin dout <= 3'b000; GS <= ; EO <= ; end //无关项建议用?表示,?是高阻态的另一种表示。?,z,Z是等价的
'b10?????? : begin dout <= 3'b001; GS <= ; EO <= ; end
'b110????? : begin dout <= 3'b010; GS <= ; EO <= ; end
'b1110???? : begin dout <= 3'b011; GS <= ; EO <= ; end
'b11110??? : begin dout <= 3'b100; GS <= ; EO <= ; end
'b111110?? : begin dout <= 3'b101; GS <= ; EO <= ; end
'b1111110? : begin dout <= 3'b110; GS <= ; EO <= ; end
'b11111110 : begin dout <= 3'b111; GS <= ; EO <= ; end
'b11111111 : begin dout <= 3'b111; GS <= ; EO <= ; end //芯片工作,但无编码输入
default : begin dout <= 'b111; GS <= 1; EO <= 1; end //消除锁存器(latch)
endcase
endmodule //EI = 0 表示允许编码,否则所有输出端被封锁在高电平(控制芯片工作)
//EO = 0 表示电路工作,但无编码输入(用于级联)
//GS = 0 表示电路工作,且有编码输入(判断输入端是否有输入)


如有错误还请指出,如有侵权还请告知,如需转载请注明出处!
本人博客:http://www.cnblogs.com/yllinux/
Verilog八线 - 三线优先编码器设计(74LS148)的更多相关文章
- 基于Verilog HDL 的数字时钟设计
基于Verilog HDL的数字时钟设计 一.实验内容: 利用FPGA实现数字时钟设计,附带秒表功能及时间设置功能.时间设置由开关S1和S2控制,分别是增和减.开关S3是模式选择:0是正常时钟 ...
- 从YouTube改版看“移动优先”——8个移动优先网站设计案例赏析
2011年,Luke Wroblewski大神提出了移动优先的设计理念.在当时看来这无疑是一个打破行业常规的新型设计原则.而在移动互联网大行其道的今天,谁遵守移动优先的设计理念,设计出最好的移动端网站 ...
- 『TensorFlow』降噪自编码器设计
背景简介 TensorFlow实现讲解 设计新思路: 1.使用类来记录整个网络: 使用_init_()属性来记录 网络超参数 & 网络框架 & 训练过程 使用一个隐式方法初始化网络参数 ...
- 『TensorFlow』单&双隐藏层自编码器设计
计算图设计 很简单的实践, 多了个隐藏层 没有上节的高斯噪声 网络写法由上节的面向对象改为了函数式编程, 其他没有特别需要注意的,实现如下: import numpy as np import mat ...
- 吴裕雄 PYTHON 神经网络——TENSORFLOW 双隐藏层自编码器设计处理MNIST手写数字数据集并使用TENSORBORD描绘神经网络数据2
import os import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data os.envi ...
- 吴裕雄 PYTHON 神经网络——TENSORFLOW 单隐藏层自编码器设计处理MNIST手写数字数据集并使用TensorBord描绘神经网络数据
import os import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from tensorflow ...
- 8-3编码器,3-8译码器的verilog实现
在数字系统中,由于采用二进制运算处理数据,因此通常将信息变成若干位二进制代码.在逻辑电路中,信号都是以高,低电平的形式输出.编码器:实现编码的数字电路,把输入的每个高低电平信号编成一组对应的二进制代码 ...
- Verilog设计技巧实例及实现
Verilog设计技巧实例及实现 1 引言 最近在刷HDLBits的过程中学习了一些Verilog的设计技巧,在这里予以整理.部分操作可能降低代码的可读性和Debug的难度,请大家根据实际情况进行使用 ...
- Verilog HDL 使用规范(一)
本博文参考:<大规模逻辑设计指导书>,对于写出规范的代码,培养良好的代码风格颇有裨益. wire and register 一个reg变量只能在一个always语句中赋值: 这个说明至关重 ...
随机推荐
- maven 发布 到 远程 tomcat
需要修改3个地方 首先 maven setting.xml 在 servers 节点 中 添加 一个 server <server> <id>devTomcat</id& ...
- JAVA Font类
java.awt.Font 设计字体显示效果 Font mf = new Font(String 字体,int 风格,int 字号); 字体:TimesRoman, Courier, Arial等 风 ...
- js css 点亮 星级评分
利用css 和 js 实现星级评分 <!DOCTYPE html> <html lang="en"> <head> <meta chars ...
- Python Pandas Merge, join and concatenate
Pandas提供了基于 series, DataFrame 和panel对象集合的连接/合并操作. Concatenating objects 先来看例子: from pandas import Se ...
- 转 如何在secureCRT上设置常用的快捷输出按钮栏听语音
https://jingyan.baidu.com/article/5d6edee2f32de199eadeec25.html 要注意secureCRT的版本,建议下载最新版本的软件 ...
- 单片机的图形UI
https://www.st.com/content/st_com/en/stm32-graphic-user-interface.html TouchGFX Designer:如今免费,资源占用10 ...
- maya2016无法安装卸载激活失败
AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...
- Murano Weekly Meeting 2015.10.06
Meeting time: 2015.October.6th 1:00~2:00 Chairperson: Kirill Zaitsev, from Mirantis Meeting summar ...
- 使用python将元组转换成列表,并替换其中元素
aa = (1, 2, 3, 4, 5, 6) b = [(x == 5 and 8 or x) for x in aa] z = map(lambda x: 8 if x == 5 else x, ...
- C#中正则表达式的构建与匹配
使用方法 [1]用用命名空间System.Text.RegularExpressions [2]构造正则表达式 在使用正则表达式时,要先构造正则表达式,这就用到了Regex类,其构建方式有两种: 基本 ...