FPGA学习笔记2.1——用Verilog实现74LS148的功能定义并测试

举报
nimo的小舔狗 发表于 2022/05/11 00:53:13 2022/05/11
【摘要】 设计思路: 0-7 编码输入端(低电平有效) EI 选通输入端(低电平有效) A0、A1、A2 三位二进制编码输出信号即编码 输 出 端(低电平有效) GS 片优先编码输出端即宽展端(低电平有效) EO 选通输出端,即使能输出端 74LS148真值表: 输入 输出 EI 0 1 2 3 4...

设计思路:

07 编码输入端(低电平有效)

EI 选通输入端(低电平有效)

A0A1A2 三位二进制编码输出信号即编码 (低电平有效)

GS 片优先编码输出端即宽展端(低电平有效)

EO 选通输出端,即使能输出端

74LS148真值表:

输入

输出

EI

0

1

2

3

4

5

6

7

A2

A1

A0

GS

EO

1

X

X

X

X

X

X

X

X

1

1

1

1

1

0

1

1

1

1

1

1

1

1

1

1

1

1

0

0

X

X

X

X

X

X

X

0

0

0

0

0

1

0

X

X

X

X

X

X

0

1

0

0

1

0

1

0

X

X

X

X

X

0

1

1

0

1

0

0

1

0

X

X

X

X

0

1

1

1

0

1

1

0

1

0

X

X

X

0

1

1

1

1

1

0

0

0

1

0

X

X

0

1

1

1

1

1

1

0

1

0

1

0

X

0

1

1

1

1

1

1

1

1

0

0

1

0

0

1

1

1

1

1

1

1

1

1

1

0

1

其中,1-高电平 ,0-低电平 ,X-任意

原理图: 

功能模块代码:

module code83(in8,out3,EI,GS,EO);
input[7:0] in8;
input EI;
output reg[2:0] out3;
output reg GS;
output reg EO;
always@(in8,EI)
begin
	out3=3'b111;
	EO=1;
	GS=1;
	if(~EI)
	begin
		GS=0;
		case(in8)
			8'b11111111:

			begin
				EO=0;
				GS=1;
				out3=3'b111;
			end
			8'b00000000: out3=3'b000;
			8'b10000000: out3=3'b001;
			8'b11000000: out3=3'b010;
			8'b11100000: out3=3'b011;
			8'b11110000: out3=3'b100;
			8'b11111000: out3=3'b101;
			8'b11111100: out3=3'b110;
			8'b11111110: out3=3'b111;
			default: out3=3'b111;
		endcase
	end
end
endmodule

测试模块代码:

// Copyright (C) 2017  Intel Corporation. All rights reserved.
// Your use of Intel Corporation's design tools, logic functions 
// and other software and tools, and its AMPP partner logic 
// functions, and any output files from any of the foregoing 
// (including device programming or simulation files), and any 
// associated documentation or information are expressly subject 
// to the terms and conditions of the Intel Program License 
// Subscription Agreement, the Intel Quartus Prime License Agreement,
// the Intel FPGA IP License Agreement, or other applicable license
// agreement, including, without limitation, that your use is for
// the sole purpose of programming logic devices manufactured by
// Intel and sold by Intel or its authorized distributors.  Please
// refer to the applicable agreement for further details.

// *****************************************************************************
// This file contains a Verilog test bench template that is freely editable to  
// suit user's needs .Comments are provided in each section to help the user    
// fill out necessary details.                                                  
// *****************************************************************************
// Generated on "03/30/2022 22:16:56"
                                                                                
// Verilog Test Bench template for design : code83
// 
// Simulation tool : ModelSim-Altera (Verilog)
// 

`timescale 1 ps/ 1 ps
module code83_vlg_tst();
// constants                                           
// general purpose registers
reg eachvec;
// test vector input registers
reg EI;
reg [7:0] in8;
// wires                                               
wire EO;
wire GS;
wire [2:0]  out3;

// assign statements (if any)                          
code83 i1 (
// port map - connection between master ports and signals/registers   
	.EI(EI),
	.EO(EO),
	.GS(GS),
	.in8(in8),
	.out3(out3)
);
initial                                                
begin                                                  
// code that executes only once                        
// insert code here --> begin                          
                                                       
// --> end                                             
$display("Running testbench");    
EI=1;in8=8'b0;
#5;
EI=0;
in8=8'b11111111;
#16 $stop;   
                
end                                                    
always                                                 
// optional sensitivity list                           
// @(event1 or event2 or .... eventn)                  
begin                                                  
// code executes for every event on sensitivity list   
// insert code here --> begin      
#2 $display("EI:%b; input:%b; output:%b GS:%b; EO:%b",EI,in8,out3,GS,EO);
in8=in8<<1;                    
                                                       
@eachvec;                                              
// --> end                                             
end                                                    
endmodule

运行图:

文章来源: blog.csdn.net,作者:渣渣ye,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/yyfloveqcw/article/details/123860639

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。