Verilog之openMSP430(1)
2024-10-01 05:59:18
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
最新文章
- 解决:error: .repo/manifests/: contains uncommitted changes
- 从 IClassFactory 为 CLSID 为 {00024500-0000-0000-C000-000000000046} 的 COM 组件创建实例失败,原因是出现以下错误: 8001010a解决办法
- Java开发环境的配置与Hello World
- python 列表排序
- 关于cnas培训
- 19.Android之文件存储方法学习
- tcp粘包问题(封包)
- ASP.NET MVC中的拦截器
- Spring IOC 方式结合TESTGN测试用例,测试简单java的命令模式
- 【Stage3D学习笔记续】山寨Starling(一):从事件说起
- AS问题解决系列1—Unable to execute DX错误
- 笔记本PS/2键盘无法使用,试下这个方法
- 删除IE缓存中指定的文件
- 在 Windows Azure 上部署预配置 Oracle VM
- Windows Phone 选择器
- sql server int 列 NULLIF,isnull 判断是0还是1 ,如果是0就变成1
- docker-maven-plugin插件设置Docker的buildArgs
- fork/join概述
- vue 兼容性——ie家族不支持promise
- leecode第十四题(最长公共前缀)