jchdl - GSL实例 - Mux4(使用Mux)
https://mp.weixin.qq.com/s/GrYJ4KXEFRoLLmLnAGoMSA
原理图
参考链接
https://github.com/wjcdx/jchdl/blob/master/src/org/jchdl/model/gsl/example/Mux4.java
1.创建Mux4.java, 并生成构造方法和logic()方法
2. 根据逻辑原理图,添加输入输出线
3. 在构造方法中搜集输入输出线并调用construct()方法
4. 在logic()方法中创建子节点并连线
5. 创建inst静态方法方便后续使用
6. 创建main方法执行验证
运行结果为:
四种组合逐个选择i0~i3中的值。
7. 生成Verilog
执行结果如下:
import org.jchdl.model.gsl.core.datatype.net.Wire;
import org.jchdl.model.gsl.core.meta.Node;
import org.jchdl.model.gsl.core.meta.PropagateManager;
import org.jchdl.model.gsl.core.value.Value;
import org.jchdl.model.gsl.operator.conditional.Mux;
public class Mux4 extends Node {
private Wire i0;
private Wire i1;
private Wire i2;
private Wire i3;
private Wire s1;
private Wire s0;
private Wire out;
private Wire o0 = new Wire();
private Wire o1 = new Wire();
public Mux4(Wire out, Wire i0, Wire i1, Wire i2, Wire i3, Wire s1, Wire s0) {
in(Wire.array(i0, i1, i2, i3, s1, s0));
out(out);
construct();
}
@Override
public void logic() {
i0 = new Wire(in(0));
i1 = new Wire(in(1));
i2 = new Wire(in(2));
i3 = new Wire(in(3));
s1 = new Wire(in(4));
s0 = new Wire(in(5));
out = new Wire(out(0));
Mux.inst(o0, i0, i1, s0);
Mux.inst(o1, i2, i3, s0);
Mux.inst(out, o0, o1, s1);
}
public static Mux4 inst(Wire out, Wire i0, Wire i1, Wire i2, Wire i3, Wire s1, Wire s0) {
return new Mux4(out, i0, i1, i2, i3, s1, s0);
}
public static void main(String[] args) {
Wire i0 = new Wire(Value.V0);
Wire i1 = new Wire(Value.V1);
Wire i2 = new Wire(Value.V0);
Wire i3 = new Wire(Value.V1);
Wire s1 = new Wire(Value.V0);
Wire s0 = new Wire(Value.V0);
Wire out = new Wire();
Mux4 mux4 = Mux4.inst(out, i0, i1, i2, i3, s1, s0);
PropagateManager.propagateParallel(i0, i1, i2, i3, s1, s0);
System.out.println("out: " + out.getValue().toString());
s1.assign(Value.V0);
s0.assign(Value.V1);
PropagateManager.propagateParallel(s1, s0);
System.out.println("out: " + out.getValue().toString());
s1.assign(Value.V1);
s0.assign(Value.V0);
PropagateManager.propagateParallel(s1, s0);
System.out.println("out: " + out.getValue().toString());
s1.assign(Value.V1);
s0.assign(Value.V1);
PropagateManager.propagateParallel(s1, s0);
System.out.println("out: " + out.getValue().toString());
mux4.toVerilog();
}
}
jchdl - GSL实例 - Mux4(使用Mux)的更多相关文章
- jchdl - GSL实例 - Mux4(使用WireVec简化输入线声明)
https://mp.weixin.qq.com/s/yJx_dV6ScUStJtPWVuD38w 原理图 参考链接 https://github.com/wjcdx/jchdl/blob/ma ...
- jchdl - GSL实例 - Mux4
https://mp.weixin.qq.com/s/hh0eExVFC6cxzpvNI1cA9A 使用门实现四选一选择器. 原理图 参考链接 https://github.com/wjcdx/ ...
- jchdl - GSL实例 - Add
https://mp.weixin.qq.com/s/6xcYYdYZTBPTf25xFluzBQ 使用FullAdder级联实现加法器 参考链接: https://github.com/wj ...
- jchdl - GSL实例 - DFlipFlop(D触发器)
https://mp.weixin.qq.com/s/7N3avTxTd2ZUnAcKg4w3Ig D触发器对边沿敏感,只有当相应的边沿出现时,才会触发D的值传播到输出Q. 引自:htt ...
- jchdl - GSL实例 - Div
因为对除法研究不深,这里略去不表. 有兴趣可以参考链接: https://github.com/wjcdx/jchdl/blob/master/src/org/jchdl/model/gsl/op ...
- jchdl - GSL实例 - MulC2(有符号数的乘法)
这里的实现,先把符号位取出来,使用两个正数相乘,然后在把符号加到乘积上. 参考链接 https://github.com/wjcdx/jchdl/blob/master/src/org/jch ...
- jchdl - GSL实例 - Mul(无符号数的乘法)
这里实现最原始的阵列乘法,逐位相乘然后加到一起. 参考链接 https://github.com/wjcdx/jchdl/blob/edcc3e098d4f1cb21677e86e87a114 ...
- jchdl - GSL实例 - LogicalLeft
https://mp.weixin.qq.com/s/WNm4bLWzZ0oWHWa7HQ6Y6w 逻辑左移,继承自Shifter类.只需要实现shift方法即可. 参考链接 https:// ...
- jchdl - GSL实例 - Shifter
https://mp.weixin.qq.com/s/ngQji-xi4FCCbL_2ihUi_A Shifter是移位节点的父类,定义了输入输出线,但是没有定义具体的移位方式,这个留给子类去实现 ...
随机推荐
- Linux查看redis占用内存的方法
redis-cli auth 密码info # Memory used_memory:13490096 //数据占用了多少内存(字节) used_memory_human:12.87M //数据占用了 ...
- ssm整合后打印日志查看执行sql语句
mybatis.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configura ...
- Oracle条件判断
一. if/else 语法:if 条件表达式 then语句块:if 条件表达式 then 语句块end if;elsif 条件表达式 then语句块:...else语句块:end if;举例:输入一个 ...
- 王颖奇 20171010129《面向对象程序设计(java)》第十二周学习总结
实验十二 图形程序设计 理论: 10.1 AWT与Swing简介 10.2 框架的创建10.3 图形程序设计10.4 显示图像 (具体学习总结在最后) 实验: 实验时间 2018-11-14 1.实 ...
- php时间输出结果减去一分钟
如: <?=date("m-d H:i",strtotime($rs["kgtime"]));?> 假设结果是09-03-23:30,如何让它变成0 ...
- VS Code的安装与配置
VS Code的安装与配置 Visual Studio Code(VS Code)是微软旗下的一个开源文本编辑器,支持Windows.macOS.Linux操作系统.数量众多.种类多样的插件极大提高了 ...
- 最简单的手机预览WEB移动端网页的方法
网上看了很多关于该问题的解决办法,各种各样的都有,个人也测试了一些, 最后总结出一个最简单且实用的方法. 1.安装nodejs node官网下载对应版本的nodejs,安装好了之后,在node.js执 ...
- [hdu5387 Clock]时钟夹角问题
题意:给一个时刻,求时针.分钟.秒针三者之间的夹角 思路:确定参照点,求出三者的绝对夹角,然后用差来得到它们之间的夹角,钝角情况用360.减去就行了. #include <map> #in ...
- 给bootstrap右边的菜单加上右键关闭
<ul class="rightmenu"> <li data-type="closethis">关闭当前</li> < ...
- 单线程和多线程执行对比—Python多线程编程
单线程和多线程执行对比 本章使用递归求斐波那契.阶乘与累加函数的执行来对比单线程与多线程: 斐波那契.阶乘与累加(mtfacfib.py): import threading from time ...