Verilog之openMSP430(1)
openMSP430_IO interrupt
Verilog file: omsp_gpio.v
//============================================================================
// 4) INTERRUPT GENERATION
//============================================================================ // Port 2 interrupt
//------------------ // Delay input // The p2in_dly stores former value of p2in, it will be used for edge detection
reg [:] p2in_dly;
always @ (posedge mclk or posedge puc_rst)
if (puc_rst) p2in_dly <= 'h00;
else p2in_dly <= p2in & P2_EN_MSK; // Edge detection // Now we can detect rising and falling edge easily by combining p2in and p2in_dly
wire [:] p2in_re = p2in & ~p2in_dly;
wire [:] p2in_fe = ~p2in & p2in_dly; // Set interrupt flag // p2ies register decide which edge is interrup signal; p2ifg_set is sent to p2ifg for interrupt flag
assign p2ifg_set = {p2ies[] ? p2in_fe[] : p2in_re[],
p2ies[] ? p2in_fe[] : p2in_re[],
p2ies[] ? p2in_fe[] : p2in_re[],
p2ies[] ? p2in_fe[] : p2in_re[],
p2ies[] ? p2in_fe[] : p2in_re[],
p2ies[] ? p2in_fe[] : p2in_re[],
p2ies[1] ? p2in_fe[] : p2in_re[],
p2ies[] ? p2in_fe[] : p2in_re[]} & P2_EN_MSK; // Generate CPU interrupt // Interrupt is generated when interrupt is enabled and p2ifg (interrupt flag) is available
assign irq_port2 = |(p2ie & p2ifg) & P2_EN[];
Assume P2_EN is 1'b1, interrupt is enabled(P2IE=1), interrupt edge is rising(P2IES=0), so the code is as following:
// Delay input
reg [:] p2in_dly;
always @ (posedge mclk or posedge puc_rst)
if (puc_rst) p2in_dly <= 'h00;
else p2in_dly <= p2in; // Edge detection
wire [:] p2in_re = p2in & ~p2in_dly; // Set interrupt flag
assign p2ifg_set = { p2in_re[],
p2in_re[],
p2in_re[],
p2in_re[],
p2in_re[],
p2in_re[],
p2in_re[],
p2in_re[] }; // Generate CPU interrupt
assign irq_port2 = | p2ifg;
P2IFG register is as following:
// P2IFG Register
//----------------
reg [:] p2ifg; wire p2ifg_wr = P2IFG[] ? reg_hi_wr[P2IFG] : reg_lo_wr[P2IFG];
wire [:] p2ifg_nxt = P2IFG[] ? per_din[:] : per_din[:];
wire [:] p2ifg_set; always @ (posedge mclk or posedge puc_rst)
if (puc_rst) p2ifg <= 'h00;
else if (p2ifg_wr) p2ifg <= (p2ifg_nxt | p2ifg_set) & P2_EN_MSK;
else p2ifg <= (p2ifg | p2ifg_set) & P2_EN_MSK;
Assume P2_EN is 1'b1; P2IFG='h2B, so P2IFG[0]=1; p2ifg_set = 8{1'b1}
// P2IFG Register
//----------------
reg [:] p2ifg; wire p2ifg_wr = reg_hi_wr[]; // If decoded address is P2IFG, then write it into data
wire [:] p2ifg_nxt = per_din[:]; // receive high byte data from openMSP
wire [:] p2ifg_set; always @ (posedge mclk or posedge puc_rst)
if (puc_rst) p2ifg <= 'h00;
else if (p2ifg_wr) p2ifg <= p2ifg_nxt | p2ifg_set; // write into
else p2ifg <= p2ifg | p2ifg_set; // read out
Verilog之openMSP430(1)的更多相关文章
- Verilog学习笔记简单功能实现(二)...............全加器
先以一位全加器为例:Xi.Yi代表两个加数,Cin是地位进位信号,Cout是向高位的进位信号.列表有: Xi Yi Cin Sum Cout 0 0 0 0 0 0 0 1 1 0 ...
- Verilog HDL模型的不同抽象级别
所谓不同的抽象类别,实际上是指同一个物理电路,可以在不同层次上用Verilog语言来描述.如果只从行为功能的角度来描述某一电路模块,就称作行为模块.如果从电路结构的角度来描述该电路模块,就称作结构模块 ...
- Verilog学习笔记基本语法篇(十二)········ 编译预处理
h Verilog HDL语言和C语言一样也提供编译预处理的功能.在Verilog中为了和一般的语句相区别,这些预处理语句以符号"`"开头,注意,这个字符位于主键盘的左上角,其对应 ...
- Verilog学习笔记基本语法篇(十一)········ 常用系统函数
1)系统任务:$monitor 格式: $monitor(p1,p2,p3...pn); $monitor; $monitoron; $monitoroff; 任务$monitor提供了监控输出列 ...
- FPGA作为从机与STM32进行SPI协议通信---Verilog实现 [转]
一.SPI协议简要介绍 SPI,是英语Serial Peripheral Interface的缩写,顾名思义就是串行外围设备接口.SPI,是一种高速的,全双工,同步的通信总线,并且在芯片的管脚上只占用 ...
- 基于Verilog HDL整数乘法器设计与仿真验证
基于Verilog HDL整数乘法器设计与仿真验证 1.预备知识 整数分为短整数,中整数,长整数,本文只涉及到短整数.短整数:占用一个字节空间,8位,其中最高位为符号位(最高位为1表示为负数,最高位为 ...
- system verilog中的跳转操作
在verilog中,使用disable声明来从执行流程中的某一点跳转到另一点.特别地,disable声明使执行流程跳转到标注名字的声明组末尾,或者一个任务的末尾. verilog中的disable命令 ...
- system verilog中的类型转换(type casting)、位宽转换(size casting)和符号转换(sign casting)
类型转换 verilog中,任何类型的任何数值都用来给任何类型赋值.verilog使用赋值语句自动将一种类型的数值转换为另一种类型. 例如,当一个wire类型赋值给一个reg类型的变量时,wire类型 ...
- 一段比较有意思的代码——介绍system verilog中的新增幅值语句
system verilog中新加了很多幅值语句,虽然都只适用于阻塞幅值,但是在某些场合中非常实用. 下面是一段有意思的代码,覆盖了一些用法. package definitions; typedef ...
随机推荐
- Django 模型层(标签、过滤器、模板的继承与导入)
过滤器/自定义过滤器 模板语法中的过滤器类似于python中的内置方法,在我们把数据从后端通过rander传入到前端html文件中之后,在前端我们可以通过模板语法,对传入的数据再进行以通骚操作. 首先 ...
- anaconda安装的TensorFlow版本没有model这个模块
一.采用git bash来安装,确认已经安装了git 二.手动找到TensorFlow的模块文件夹地址,若不知道,输入以下两行代码: import tensorflow as tf tf.__path ...
- Java 并行 (2): Monitor
转自:http://www.cnblogs.com/tomsheep/archive/2010/06/09/1754419.html 1. 什么是Monitor? Monitor其实是一种同步工具,也 ...
- 22.external version
主要知识点 基于external version进行乐观锁并发控制 es提供了一个feature,就是说,你可以不用它提供的内部_version版本号来进行并发控制,可以基于你自己维护的一个版本号来进 ...
- [vuejs短文]使用vue-transition制作小小轮播图
提示 本文是个人的一点小笔记,用来记录开发中遇到的轮播图问题和vue-transition问题. 会不断学习各种轮播图添加到本文当中 也有可能会上线,方便看效果 开始制作 超简易呼吸轮播 简单粗暴的使 ...
- Jquery语法基础
Jquery语法基础 一.Jquery一般语法格式为:$(selector).action() l 美元符号定义 jQuery (又称工厂函数) l 选择器(selector)“查询”和“查找” ...
- 0614MySQL的InnoDB索引原理详解
转自http://www.cnblogs.com/shijingxiang/articles/4743324.html MySQL的InnoDB索引原理详解 http://www.admin10000 ...
- 很实用的50个CSS代码片段
原文:50 Useful CSS Snippets Every Designer Should Have 面对每年如此多的 新趋势 ,保持行业的率先是个非常困难问题. 站点设计者和前 ...
- C++ exit 与 return 浅析
[摘要] 本文从代码形式.经常使用方式,相关概念,调用关系和比較分析,这5个维度浅析 exit 与 return 在C++的同样点与差别. [常见形式] exit(0): 正常执行程序并退出程序. ...
- 一个使用命令行编译Android项目的工具类
一个使用命令行编译Android项目的工具类 简单介绍 编译apk项目须要使用的几个工具,基本都在sdk中,它们各自是(Windows系统): 1.aapt.exe 资源打包工具 2.android. ...