当前位置:网站首页>【牛客网刷题系列 之 Verilog快速入门】~ 使用函数实现数据大小端转换
【牛客网刷题系列 之 Verilog快速入门】~ 使用函数实现数据大小端转换
2022-07-01 14:18:00 【AI很不错呦】
目录:
0. 前言
0.1 知识点考察
考察的是:
- 函数function的知识点;
- 理解大端小端。传送门
0.2 知识拓展
function和task的定义和区别?
这个问题之前总结过,直接老规矩,插眼,传送门
1. VL10 使用函数实现数据大小端转换
1.1 题目描述
在数字芯片设计中,经常把实现特定功能的模块编写成函数,在需要的时候再在主模块中调用,以提高代码的复用性和提高设计的层次,分别后续的修改。
请用函数实现一个4bit数据大小端转换的功能。实现对两个不同的输入分别转换并输出。
1.1.1 信号示意图

1.1.2 波形示意图
该题官方没有给出。
1.1.3 输入描述
clk:系统时钟
rst_n:异步复位信号,低电平有效
a,b:4bit位宽的无符号数
(注意的是:官方代码并没有声明clk和rst_n,小伙伴们提交的时候注意自己加一下!!!)
1.1.4 输出描述
c,d:4bit位宽的无符号数
(这里应该是官方笔误,是四位的就对了)
1.2 解题思路
主要还是考察function的细节点,题目本身不难,就是大端小端进行转换。这些知识点在本篇文章的前言部分已经有说明了,自行查看。
1.3 代码实现
`timescale 1ns/1ns
module function_mod(
input clk,
input rst_n,
input [3:0]a,
input [3:0]b,
output [3:0]c,
output [3:0]d
);
function [3:0] big22small;
input [3:0] big_small;
begin
big22small[0] = big_small[3];
big22small[1] = big_small[2];
big22small[2] = big_small[1];
big22small[3] = big_small[0];
end
endfunction
assign c = big22small(a);
assign d = big22small(b);
endmodule
1.4 测试文件
待更。。。
1.5 仿真波形
待更。。。
边栏推荐
- 那个很努力的学生,高考失败了……别慌!你还有一次逆袭机会!
- 2022 PMP project management examination agile knowledge points (6)
- Provincial election + noi Part 10 probability statistics and polynomials
- How to pass array parameters in get request
- 开源实习经验分享:openEuler软件包加固测试
- 微服务大行其道的今天,Service Mesh是怎样一种存在?
- Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
- C language ordering management system
- Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of its
- What class loading mechanisms does the JVM have?
猜你喜欢
随机推荐
基于算力驱动、数据与功能协同的分布式动态(协同)渲染/功能运行时
[repair version] imitating the template of I love watching movies website / template of ocean CMS film and television system
Use the right scene, get twice the result with half the effort! Full introduction to the window query function and usage scenarios of tdengine
SWT / anr problem - how to capture performance trace
QT社团管理系统
Research Report on the development trend and competitive strategy of the global powder filling machine industry
Research Report on the development trend and competitive strategy of the global facial wrinkle removal and beauty instrument industry
Research Report on the development trend and competitive strategy of the global aviation leasing service industry
Sorting learning sorting
[R language data science]: common evaluation indicators of machine learning
Research Report on the development trend and competitive strategy of the global navigation simulator industry
清华章毓晋老师新书:2D视觉系统和图像技术(文末送5本)
C language ordering management system
开源实习经验分享:openEuler软件包加固测试
Distributed dynamic (collaborative) rendering / function runtime based on computing power driven, data and function collaboration
sqlilabs less-8
Play with mongodb - build a mongodb cluster
C语言基础知识
App automation testing Kaiyuan platform appium runner
Oracle-数据库对象的使用









